init commit
This commit is contained in:
43
Assets/Scripts/Lesson_1/Stopwatch.cs
Normal file
43
Assets/Scripts/Lesson_1/Stopwatch.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Stopwatch : MonoBehaviour
|
||||
{
|
||||
public GameObject arrow;
|
||||
public AmyRunScript amy;
|
||||
|
||||
public Quaternion arrowStartRotation;
|
||||
private float rotationSpeed = 360f / 60f;
|
||||
public bool isCounting = false;
|
||||
|
||||
private float timeCounted = 0f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
arrowStartRotation = arrow.transform.localRotation;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Lesson1Controller.Instance.activeExperiment == 0) return;
|
||||
if (isCounting)
|
||||
{
|
||||
arrow.transform.Rotate(0f, rotationSpeed * Time.deltaTime, 0f);
|
||||
timeCounted += Time.deltaTime;
|
||||
}
|
||||
if (timeCounted >= 60f && Lesson1Controller.Instance.activeExperiment == 1) ExperimentChooser.Instance.experiment2Button.interactable = true;
|
||||
|
||||
if (Input.GetMouseButtonDown(0)) isCounting = !isCounting;
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
arrow.transform.localRotation = arrowStartRotation;
|
||||
isCounting = false;
|
||||
if (Lesson1Controller.Instance.activeExperiment < 3) amy.PlaceOnStartAngle();
|
||||
}
|
||||
|
||||
if (Lesson1Controller.Instance.activeExperiment < 3)
|
||||
{
|
||||
if(isCounting) amy.StartRun();
|
||||
else amy.StopRun();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user