// Update is called once per frame void Update() { remainingTime -= Time.deltaTime; // updates time value // gets minutes, secodns and milliseconds int minutes, seconds, milliseconds; minutes = (int)remainingTime / 60; seconds = (int)remainingTime % 60; milliseconds = (int)((remainingTime - (int)remainingTime) * 100); if (remainingTime > 0) { textOverlay.text = minutes + ":" + seconds + ":" + milliseconds; } else { textOverlay.text = "0:00:00"; // Sets Gui to 0:0:00 player.ChangeHealth(-100); // Kills player } }
void Update() { // Must always face in the direction of the player on the horizontal plane // Must shoot a ray towards the player when they are in range, if they are the chase is on // If the player is found, run the soundclip for chargeup // Light up light from the erradication beam(point) // When the osund ends, shoot the beam, lighting up everything in that general direaction // If the player vere in a direct line from the ranged opponent, they take a large amount of damage // Lets the lights stay on for a certain perios of time if (lightOn) { if (waitTurnOffLights > waitingTimeLights) { lightOn = outerLight.enabled = innerLight.enabled = spotLight.enabled = false; waitTurnOffLights = 0; } else { waitTurnOffLights += Time.deltaTime; } } // Well, it places the lights in front of the player, which isn't exactly what it were supposed to do Vector3 playerPos = Camera.main.transform.position; // Gets player's position currentY = playerPos.y; // Sets currentY playerPos.y = 0; // Sets directional height to 0 transform.LookAt(playerPos); // Changes the direction the ranged opponent looks at to that of the player transform.position = transform.parent.position + transform.forward * distanceLight; if (targetFound) // Checks if it should start waiting to shoot the player { timeWaited += Time.deltaTime; if (timeWaited >= timeShooting) // If enough time have passed { // Updates lights lightOn = true; outerLight.enabled = spotLight.enabled = true; RaycastHit hit; transform.LookAt(Camera.main.transform.position); // Gets direction // Actual checks if (Physics.Raycast(transform.position, transform.forward, out hit)) { playerHealth enemy = hit.transform.GetComponent <playerHealth>(); // Checks if the hit target is the player if (enemy != null) // If it was indeed the player, they are in range and in direct line of sight to the ranged opponent { enemy.ChangeHealth(-erradicationDamage); // Updates health } } // Resets values timeWaited = 0; // Updates time passed targetFound = false; // Updates targetFound } } }