Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using TMPro;
  6.  
  7. public class ObjectiveFeed : MonoBehaviour
  8. {
  9. public GameObject victoryPanel;
  10. Enemy[] enemy;
  11. List<Enemy> enemies = new List<Enemy>();
  12. PlayerMovement player;
  13. private int enemyCount;
  14. private bool won = false;
  15. public TextMeshProUGUI Objectivefeed;
  16. public bool Objective1;
  17. public bool Objective2;
  18. public bool Objective3;
  19. public bool Objective4;
  20. public bool Objective5;
  21. List<Obj> Objectives = new List<Obj>();
  22.  
  23. // Start is called before the first frame update
  24. void Start()
  25. {
  26. Objectivefeed.GetComponent<TextMeshProUGUI>();
  27. Mission1();
  28.  
  29. }
  30.  
  31. // Update is called once per frame
  32. void Update()
  33. {
  34. EnemySearch();
  35.  
  36. }
  37. public void Mission1()
  38. {
  39. Objectivefeed.text = "Kill All Zombies in The Square";
  40. if (enemies.Count == 0 && won == false)//Victory Condition
  41. {
  42.  
  43. Win();
  44. Objective2 = true;
  45. Debug.Log("Victory");
  46. }
  47.  
  48. for (int i = 0; i < enemies.Count; i++)
  49. {
  50. if (enemies[i].enabled == false)
  51. {
  52. enemies.RemoveAt(i);
  53. //enemyCount--;
  54. }
  55. }
  56. }
  57. public void Mission2()
  58. {
  59. if (Objective2 == true)
  60. {
  61. Objectivefeed.text = "Speak To The Head Villager";
  62.  
  63. }
  64. }
  65. public void Win()
  66. {
  67. won = true;
  68. Cursor.lockState = CursorLockMode.None;
  69. victoryPanel.gameObject.SetActive(true);
  70. player.gameObject.BroadcastMessage("SetPause", true);
  71. foreach (Enemy en in enemies)
  72. {
  73. en.gameObject.BroadcastMessage("SetPause", true);
  74. }
  75. }
  76.  
  77. public void EnemySearch()
  78. {
  79.  
  80. enemy = FindObjectsOfType<Enemy>();
  81. foreach (Enemy en in enemy)
  82. {
  83. enemies.Add(en);
  84. //enemyCount++;
  85. }
  86. enemyCount = enemies.Capacity;
  87. player = FindObjectOfType<PlayerMovement>();
  88. }
  89.  
  90. public void EnemyCount()
  91. {
  92. //enemyCount = enemies.Capacity;
  93.  
  94. if (enemies.Count == 0 && won == false)//Victory Condition
  95. {
  96. Win();
  97. }
  98.  
  99. for (int i = 0; i < enemies.Count; i++)
  100. {
  101. if (enemies[i].enabled == false)
  102. {
  103. enemies.RemoveAt(i);
  104. //enemyCount--;
  105. }
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement