| | | 1 | | using System; |
| | | 2 | | using System.Collections; |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using TMPro; |
| | | 5 | | using UnityEngine; |
| | | 6 | | using UnityEngine.SceneManagement; |
| | | 7 | | |
| | | 8 | | public class XRTarget : MonoBehaviour { |
| | | 9 | | |
| | | 10 | | public float health; |
| | | 11 | | |
| | | 12 | | public TextMeshPro livesText; |
| | | 13 | | |
| | | 14 | | public GameObject deathScreen; |
| | | 15 | | |
| | | 16 | | public GameObject LocomotionSystem; |
| | | 17 | | |
| | | 18 | | public GameObject ray_Right; |
| | | 19 | | public GameObject ray_Left; |
| | | 20 | | |
| | | 21 | | public GameObject TeleportManagerLeft; |
| | | 22 | | public GameObject TeleportManagerRight; |
| | | 23 | | |
| | | 24 | | public GameObject[] enemies; |
| | | 25 | | |
| | | 26 | | |
| | | 27 | | void Update() |
| | 24682 | 28 | | { |
| | 24682 | 29 | | livesText.text = "Health: " + health; |
| | | 30 | | |
| | 28028 | 31 | | if(health <= 0) { |
| | 3346 | 32 | | if (deathScreen.activeSelf) |
| | 3344 | 33 | | { |
| | 3344 | 34 | | enemies = GameObject.FindGameObjectsWithTag("Enemy"); |
| | | 35 | | |
| | 10032 | 36 | | foreach (GameObject enemy in enemies){ |
| | 0 | 37 | | enemy.SetActive(false); |
| | 0 | 38 | | } |
| | | 39 | | |
| | 3344 | 40 | | ray_Right.SetActive(true); |
| | 3344 | 41 | | ray_Left.SetActive(true); |
| | | 42 | | |
| | 3344 | 43 | | LocomotionSystem.SetActive(false); |
| | | 44 | | |
| | 3344 | 45 | | TeleportManagerLeft.SetActive(false); |
| | 3344 | 46 | | TeleportManagerRight.SetActive(false); |
| | | 47 | | |
| | 3344 | 48 | | deathScreen.SetActive(true); |
| | | 49 | | |
| | 3344 | 50 | | StartCoroutine(Wait()); |
| | | 51 | | |
| | | 52 | | //SceneManager.LoadScene(0); |
| | 3344 | 53 | | } |
| | | 54 | | else |
| | 2 | 55 | | { |
| | 2 | 56 | | if (!deathScreen.activeSelf) |
| | 2 | 57 | | { |
| | | 58 | | |
| | 2 | 59 | | enemies = GameObject.FindGameObjectsWithTag("Enemy"); |
| | | 60 | | |
| | 36 | 61 | | foreach (GameObject enemy in enemies){ |
| | 10 | 62 | | enemy.SetActive(false); |
| | 10 | 63 | | } |
| | | 64 | | |
| | | 65 | | |
| | 2 | 66 | | ray_Right.SetActive(true); |
| | 2 | 67 | | ray_Left.SetActive(true); |
| | | 68 | | |
| | 2 | 69 | | LocomotionSystem.SetActive(false); |
| | | 70 | | |
| | 2 | 71 | | TeleportManagerLeft.SetActive(false); |
| | 2 | 72 | | TeleportManagerRight.SetActive(false); |
| | | 73 | | |
| | 2 | 74 | | deathScreen.SetActive(true); |
| | | 75 | | |
| | 2 | 76 | | StartCoroutine(Wait()); |
| | | 77 | | |
| | | 78 | | //SceneManager.LoadScene(0); |
| | 2 | 79 | | } |
| | | 80 | | |
| | 2 | 81 | | } |
| | | 82 | | |
| | 3346 | 83 | | } |
| | 24682 | 84 | | } |
| | | 85 | | |
| | | 86 | | |
| | | 87 | | IEnumerator Wait() |
| | 3346 | 88 | | { |
| | | 89 | | //yield on a new YieldInstruction that waits for 5 seconds. |
| | 3346 | 90 | | yield return new WaitForSecondsRealtime(5); |
| | 2002 | 91 | | } |
| | | 92 | | |
| | | 93 | | |
| | | 94 | | /// 'Hits' the target for a certain amount of damage |
| | 49 | 95 | | public void Hit(float damage) { |
| | 49 | 96 | | health -= damage; |
| | 49 | 97 | | } |
| | | 98 | | |
| | | 99 | | } |