1
0
Fork 0
Bildschirmflausch-LD41/Assets/Scripts/Objectives/EntityObjective.cs

39 lines
1.1 KiB
C#
Raw Normal View History

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
public override void Activate()
2018-04-21 15:18:53 +02:00
{
Random newRand = new Random ();
Debug.Log("Activate");
2018-04-21 17:27:28 +02:00
foreach (GameObject i in prefabList)
{
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 ();
}
}