private void Update() { if (!spawning) { spawning = true; InvokeRepeating("SpawnNext", waitTime, interval); } if (Time.timeSinceLevelLoad > nextActionTime)//Next wave timer { nextActionTime += period; if (downTimer >= 1) { downTimer--; currentWaveText.text = "Wave " + currentWave + " in: " + downTimer.ToString(); } } if (currentWave == maxWave && GameObject.FindGameObjectWithTag("Enemy") == null) // Check if there is no enemy left in the final wave. { GameObject button = GameObject.FindGameObjectWithTag("UI"); ingameButtons = button.GetComponent <IngameButtons>(); ingameButtons.winScreen.SetActive(true); } }
private void Start() { GameObject gameObject = GameObject.FindGameObjectWithTag("UI"); ingameButtons = gameObject.GetComponent <IngameButtons>(); gameObject = GameObject.FindGameObjectWithTag("MainCamera"); playerHandler = gameObject.GetComponent <PlayerHandler>(); }
public void ContinueButtonClick() { GameObject button = GameObject.FindGameObjectWithTag("UI"); mybuttons = button.GetComponent <IngameButtons>(); mybuttons.PlayButtonSound(); //optionsButtonsClickSound.Play(); optionsMenu.gameObject.SetActive(false); Time.timeScale = 1; // Starts the game again when Continue is pressed. print("Continue Button pressed."); }
void Update() { if (enemiesInRange.Count != 0) { enemyToShoot = enemiesInRange[0]; if (enemyToShoot != null) { target = enemyToShoot.transform; } else { enemiesInRange.Remove(enemyToShoot); } if (ammo != 0) { try { //Smooth rotation Vector3 direction = target.position - transform.position; Quaternion lookRotation = Quaternion.LookRotation(direction); Vector3 rotation = Quaternion.Lerp(rotatingPart.rotation, lookRotation, Time.deltaTime * Rotation).eulerAngles; rotatingPart.rotation = Quaternion.Euler(0f, rotation.y, 0f); } catch (MissingReferenceException) { } } } if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform == click.transform) { GameObject button = GameObject.FindGameObjectWithTag("UI"); //check if turret is clicked and show upgrade menu. ingameButtons = button.GetComponent <IngameButtons>(); ingameButtons.TurretUpgrade(transform.parent.gameObject, "turretUpgrade1"); ammo = ammoMax; } } } if (ammo > 0 && changeTexture.GetComponent <Renderer>().material.mainTexture != textures[2]) // if ammo is > 0 and the texture is not changed change it. { ChangeTexture(textures[2]); } if (ammo == 0 && Time.time > nextActionTime)// Blink texture every seconed { nextActionTime += period; if (changeTexture.GetComponent <Renderer>().material.mainTexture != textures[1]) { ChangeTexture(textures[1]); } else if (changeTexture.GetComponent <Renderer>().material.mainTexture == textures[1]) { ChangeTexture(textures[0]); } } }
private void Awake() { instance = this; normalTime = true; }