1
0
Fork 0
Bildschirmflausch-LD41/Assets/Scripts/Room.cs

73 lines
1.5 KiB
C#
Raw Normal View History

2018-04-21 12:22:17 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2018-04-21 15:39:48 +02:00
public class Room : MonoBehaviour {
[SerializeField]
int width, height; // Gridsize for Generation
2018-04-21 16:13:59 +02:00
2018-04-21 15:39:48 +02:00
List<Door> doors;
2018-04-21 16:13:59 +02:00
List<Transform> spawnpoints;
2018-04-21 15:39:48 +02:00
[SerializeField]
GameObject doorsRootObject;
2018-04-21 16:13:59 +02:00
[SerializeField]
GameObject spawnpointRootObject;
2018-04-21 15:39:48 +02:00
[SerializeField]
private Objective objective;
2018-04-21 12:22:17 +02:00
// Use this for initialization
void Start () {
2018-04-21 15:39:48 +02:00
doors = new List<Door>();
foreach (Door d in doorsRootObject.GetComponentsInChildren<Door>())
{
doors.Add(d);
}
Debug.Log("Doors in Room: " + doors.Count);
2018-04-21 16:13:59 +02:00
spawnpoints = new List<Transform>();
foreach (Transform t in spawnpointRootObject.GetComponentsInChildren<Transform>())
{
if( t.gameObject != spawnpointRootObject)
{
spawnpoints.Add(t);
}
2018-04-21 16:13:59 +02:00
}
Debug.Log("Spawnpoints in Room: " + spawnpoints.Count);
2018-04-21 16:13:59 +02:00
}
2018-04-21 12:22:17 +02:00
public void SetObjective(Objective o)
{
objective = o;
}
2018-04-21 15:39:48 +02:00
2018-04-21 16:13:59 +02:00
public void Lock()
2018-04-21 15:39:48 +02:00
{
foreach (Door d in doors)
{
d.Lock();
}
}
2018-04-21 16:13:59 +02:00
public void Unlock()
2018-04-21 15:39:48 +02:00
{
foreach (Door d in doors)
{
d.Unlock();
}
}
public void OnPlayerEnter()
{
objective.Activate();
}
2018-04-21 16:13:59 +02:00
public List<Transform> GetSpawnpoints()
{
return spawnpoints;
}
2018-04-21 12:22:17 +02:00
}