using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// Objective, where the goal is to "remove" all Entitys, how is defined by the Entity itself. /// public class EntityObjective : Objective { List prefabList; List entityList; /// /// Creates a new instance of an EntityObjective. /// /// /// public EntityObjective(Room caller, List prefabList) : base(caller) { this.entityList = new List(); this.prefabList = prefabList; } /// /// Handle activation code for a goal. /// /// Player public override void ActivateGoal(Player ply) { base.ActivateGoal(ply); foreach ( GameObject i in prefabList ) { Debug.Log("[ROOMS] Spawning Entity..."); GameObject tempObject = GameObject.Instantiate(i); List spawnPointList = room.GetSpawnpoints(); tempObject.transform.position = spawnPointList[Random.Range(0, spawnPointList.Count)].position; entityList.Add(tempObject); } room.Lock(); } /// /// Removes an Entity from the list. And checks if the goal was reached. /// /// Entity public void RemoveEntity(Entity e) { if ( e == null ) return; entityList.Remove(e.gameObject); UpdateGoal(); } /// /// Tracks / Updates the progess of a goal. /// public override void UpdateGoal() { // Goal: if ( entityList.Count == 0 ) ReachedGoal(); } }