LegitTeddyBears

LoadLevel

Jun 3rd, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class LoadLevel : MonoBehaviour {
  7.    
  8.     protected int m_objectiveCount;
  9.     public List<GameObject> ObjectivesList;
  10.     protected List<GameObject> m_EnemyObjectives;
  11.     protected List<GameObject> m_Objectives;
  12.  
  13.     private void Start()
  14.     {
  15.         m_Objectives = new List<GameObject>(GameObject.FindGameObjectsWithTag("Objective"));
  16.         foreach (GameObject m_Objectives in m_Objectives)
  17.         {
  18.             ObjectivesList.Add(m_Objectives);
  19.         }
  20.         m_EnemyObjectives = new List<GameObject>(GameObject.FindGameObjectsWithTag("Enemy-Objective"));
  21.         foreach (GameObject m_EnemyObjectives in m_EnemyObjectives)
  22.         {
  23.             ObjectivesList.Add(m_EnemyObjectives);
  24.         }
  25.  
  26.         m_objectiveCount = ObjectivesList.Count;
  27.     }
  28.  
  29.     public void ListUpdate()
  30.     {
  31.         m_Objectives = new List<GameObject>(GameObject.FindGameObjectsWithTag("Objective"));
  32.         foreach (GameObject m_Objectives in m_Objectives)
  33.         {
  34.             ObjectivesList.Add(m_Objectives);
  35.         }
  36.         m_EnemyObjectives = new List<GameObject>(GameObject.FindGameObjectsWithTag("Enemy-Objective"));
  37.  
  38.         foreach (GameObject m_EnemyObjectives in m_EnemyObjectives)
  39.         {
  40.             ObjectivesList.Add(m_EnemyObjectives);
  41.         }
  42.        
  43.         m_objectiveCount = ObjectivesList.Count;
  44.        
  45.     }
  46.  
  47.     public void ObjectiveComplete()
  48.     {
  49.         {
  50.             if (m_objectiveCount == 0)
  51.             {
  52.                 if (GameObject.Find("AI_Testing") != null)
  53.                 {
  54.                     SceneManager.LoadSceneAsync("Win");
  55.                 }
  56.             }
  57.             else
  58.             {
  59.                 Debug.Log("Enemy Down!");
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment