using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class Game : MonoBehaviour { // Start is called before the first frame update [SerializeField] GameObject _cloudPrefab; const int NUM_CLOUDS = 6; const float START_X = 1300; [SerializeField] Text _victoryMessage; [SerializeField] Text _restartMessage; bool _victory = false; void Start() { _victoryMessage.enabled = false; _restartMessage.enabled = false; for (int i = 0; i < NUM_CLOUDS; ++i) { GameObject cloud = GameObject.Instantiate(_cloudPrefab); cloud.transform.position = new Vector3(Random.Range(START_X, START_X + 1920), cloud.transform.position.y, cloud.transform.position.z); } } public void Victory(string dragonName, Color color) { if (_victory) return; _victory = true; _restartMessage.enabled = true; _victoryMessage.enabled = true; _victoryMessage.text = dragonName.ToUpper() + " WINS!"; _victoryMessage.color = color; } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } } }