init commit
This commit is contained in:
106
Assets/Scripts/Lesson_1/ExperimentChooser.cs
Normal file
106
Assets/Scripts/Lesson_1/ExperimentChooser.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ExperimentChooser : MonoBehaviour
|
||||
{
|
||||
public static ExperimentChooser Instance { get; private set; }
|
||||
|
||||
public Button experiment1Button;
|
||||
public Button experiment2Button;
|
||||
public Button experiment3Button;
|
||||
|
||||
[Header("All Experiments Objects")]
|
||||
public RunlinePlacer runlinePlacer;
|
||||
public TransitionSphere transitionSphere;
|
||||
public Transform spawnPoint;
|
||||
public Transform player;
|
||||
public GameObject runTrack;
|
||||
public GameObject amy;
|
||||
|
||||
[Header("First Experiment")]
|
||||
public Stopwatch stopwatch;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else if (Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
experiment1Button.interactable = true;
|
||||
experiment2Button.interactable = false;
|
||||
experiment3Button.interactable = false;
|
||||
|
||||
experiment1Button.onClick.AddListener(StartExperiment1);
|
||||
experiment2Button.onClick.AddListener(StartExperiment2);
|
||||
experiment3Button.onClick.AddListener(StartExperiment3);
|
||||
}
|
||||
|
||||
private void StartExperiment1()
|
||||
{
|
||||
player.position = spawnPoint.position + Vector3.up * 2f;
|
||||
transitionSphere.PlayAnimation();
|
||||
runTrack.SetActive(true);
|
||||
amy.SetActive(true);
|
||||
runlinePlacer.gameObject.SetActive(true);
|
||||
player.gameObject.GetComponent<PlayerMovement>().SetPlayerEarthSpeed();
|
||||
Lesson1Controller.Instance.SetForestSkybox();
|
||||
|
||||
experiment1Button.interactable = false;
|
||||
if (Lesson1Controller.Instance.activeExperiment == 2) experiment2Button.interactable = true;
|
||||
if (Lesson1Controller.Instance.activeExperiment == 3)
|
||||
{
|
||||
experiment2Button.interactable = true;
|
||||
experiment3Button.interactable = true;
|
||||
}
|
||||
Lesson1Controller.Instance.activeExperiment = 1;
|
||||
stopwatch.isCounting = false;
|
||||
stopwatch.arrow.transform.localRotation = stopwatch.arrowStartRotation;
|
||||
runlinePlacer.RuntimePlace();
|
||||
}
|
||||
|
||||
private void StartExperiment2()
|
||||
{
|
||||
player.position = spawnPoint.position + Vector3.up * 2f;
|
||||
transitionSphere.PlayAnimation();
|
||||
runTrack.SetActive(true);
|
||||
runlinePlacer.gameObject.SetActive(true);
|
||||
amy.SetActive(true);
|
||||
player.gameObject.GetComponent<PlayerMovement>().SetPlayerEarthSpeed();
|
||||
Lesson1Controller.Instance.SetForestSkybox();
|
||||
|
||||
experiment1Button.interactable = true;
|
||||
experiment2Button.interactable = false;
|
||||
if (Lesson1Controller.Instance.activeExperiment == 3) experiment3Button.interactable = true;
|
||||
|
||||
Lesson1Controller.Instance.activeExperiment = 2;
|
||||
stopwatch.isCounting = false;
|
||||
stopwatch.arrow.transform.localRotation = stopwatch.arrowStartRotation;
|
||||
runlinePlacer.RuntimePlace();
|
||||
}
|
||||
|
||||
private void StartExperiment3()
|
||||
{
|
||||
player.position = spawnPoint.position + Vector3.up * 2f;
|
||||
transitionSphere.PlayAnimation();
|
||||
runTrack.SetActive(false);
|
||||
amy.SetActive(false);
|
||||
runlinePlacer.RuntimePlace();
|
||||
runlinePlacer.gameObject.SetActive(false);
|
||||
player.gameObject.GetComponent<PlayerMovement>().SetPlayerLunarSpeed();
|
||||
Lesson1Controller.Instance.SetLunarSkybox();
|
||||
|
||||
experiment1Button.interactable = true;
|
||||
experiment2Button.interactable = true;
|
||||
experiment3Button.interactable = false;
|
||||
|
||||
Lesson1Controller.Instance.activeExperiment = 3;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user