Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- public class ObjectiveFeed : MonoBehaviour
- {
- public GameObject victoryPanel;
- Enemy[] enemy;
- List<Enemy> enemies = new List<Enemy>();
- PlayerMovement player;
- private int enemyCount;
- private bool won = false;
- public TextMeshProUGUI Objectivefeed;
- public bool Objective1;
- public bool Objective2;
- public bool Objective3;
- public bool Objective4;
- public bool Objective5;
- List<Obj> Objectives = new List<Obj>();
- // Start is called before the first frame update
- void Start()
- {
- Objectivefeed.GetComponent<TextMeshProUGUI>();
- Mission1();
- }
- // Update is called once per frame
- void Update()
- {
- EnemySearch();
- }
- public void Mission1()
- {
- Objectivefeed.text = "Kill All Zombies in The Square";
- if (enemies.Count == 0 && won == false)//Victory Condition
- {
- Win();
- Objective2 = true;
- Debug.Log("Victory");
- }
- for (int i = 0; i < enemies.Count; i++)
- {
- if (enemies[i].enabled == false)
- {
- enemies.RemoveAt(i);
- //enemyCount--;
- }
- }
- }
- public void Mission2()
- {
- if (Objective2 == true)
- {
- Objectivefeed.text = "Speak To The Head Villager";
- }
- }
- public void Win()
- {
- won = true;
- Cursor.lockState = CursorLockMode.None;
- victoryPanel.gameObject.SetActive(true);
- player.gameObject.BroadcastMessage("SetPause", true);
- foreach (Enemy en in enemies)
- {
- en.gameObject.BroadcastMessage("SetPause", true);
- }
- }
- public void EnemySearch()
- {
- enemy = FindObjectsOfType<Enemy>();
- foreach (Enemy en in enemy)
- {
- enemies.Add(en);
- //enemyCount++;
- }
- enemyCount = enemies.Capacity;
- player = FindObjectOfType<PlayerMovement>();
- }
- public void EnemyCount()
- {
- //enemyCount = enemies.Capacity;
- if (enemies.Count == 0 && won == false)//Victory Condition
- {
- Win();
- }
- for (int i = 0; i < enemies.Count; i++)
- {
- if (enemies[i].enabled == false)
- {
- enemies.RemoveAt(i);
- //enemyCount--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement