2018-04-21 15:18:53 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class EntityObjective : Objective{
|
2018-04-21 17:27:28 +02:00
|
|
|
|
List<GameObject> prefabList;
|
|
|
|
|
List<GameObject> entityList;
|
2018-04-21 15:18:53 +02:00
|
|
|
|
List<Transform> spawnPointList;
|
|
|
|
|
|
|
|
|
|
// Constructor
|
2018-04-21 17:27:28 +02:00
|
|
|
|
public EntityObjective(Room objectiveCaller, List<GameObject> prefabList) : base(objectiveCaller)
|
2018-04-21 15:18:53 +02:00
|
|
|
|
{
|
2018-04-21 17:27:28 +02:00
|
|
|
|
this.prefabList = prefabList;
|
2018-04-21 15:18:53 +02:00
|
|
|
|
spawnPointList = objectiveCaller.GetSpawnpoints ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Activates the objective to start progresstracking
|
2018-04-21 18:45:26 +02:00
|
|
|
|
public override void Activate()
|
2018-04-21 15:18:53 +02:00
|
|
|
|
{
|
|
|
|
|
Random newRand = new Random ();
|
2018-04-21 18:45:26 +02:00
|
|
|
|
Debug.Log("Activate");
|
2018-04-21 17:27:28 +02:00
|
|
|
|
foreach (GameObject i in prefabList)
|
|
|
|
|
{
|
2018-04-21 18:45:26 +02:00
|
|
|
|
Debug.Log("Instantiating Prefab");
|
2018-04-21 17:27:28 +02:00
|
|
|
|
GameObject tempObject = GameObject.Instantiate (i);
|
|
|
|
|
tempObject.transform.position = spawnPointList [Random.Range (0, spawnPointList.Count)].position;
|
|
|
|
|
}
|
2018-04-21 15:18:53 +02:00
|
|
|
|
|
|
|
|
|
objectiveCaller.Lock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Removes the entity from the list and completes the objective, if the list is empty
|
2018-04-21 17:27:28 +02:00
|
|
|
|
public void Remove(GameObject inputEntity)
|
2018-04-21 15:18:53 +02:00
|
|
|
|
{
|
|
|
|
|
entityList.Remove (inputEntity);
|
|
|
|
|
if (entityList.Count == 0)
|
|
|
|
|
objectiveCaller.Unlock ();
|
|
|
|
|
}
|
|
|
|
|
}
|