1
0
Fork 0

Add Center methods on Room

This should be changed as soon as positions are relative
This commit is contained in:
Saibotk 2018-04-23 16:59:39 +02:00
parent a131873f26
commit 9e79eb619f
2 changed files with 24 additions and 1 deletions

View file

@ -180,6 +180,7 @@ public class GameController : MonoBehaviour {
doorRoot.name = "Doors";
doorRoot.transform.SetParent(goStart.transform);
start = goStart.AddComponent<Room>();
start.SetCenter(dg.start.GetCenter());
lt = lt.FindAll(x => x.tag == "door");
lt.ForEach(x => {
x.SetParent(doorRoot.transform);
@ -196,8 +197,9 @@ public class GameController : MonoBehaviour {
spawn.transform.SetParent(spawnpointRoot.transform);
spawn.transform.position = new Vector3(dg.start.GetCenter().x, dg.start.GetCenter().y, 0);
start.SetSpawnPointsRootObject(spawnpointRoot);
start.Reload();
start.transform.SetParent(mapRoot.transform);
// Finish room
@ -209,6 +211,7 @@ public class GameController : MonoBehaviour {
doorRootf.transform.SetParent(goFinish.transform);
ltf = ltf.FindAll(x => x.tag == "door");
finish = goFinish.AddComponent<Room>();
finish.SetCenter(dg.end.GetCenter());
ltf.ForEach(x => {
x.SetParent(doorRootf.transform);
x.gameObject.GetComponent<Door>().SetParent(finish);
@ -227,6 +230,7 @@ public class GameController : MonoBehaviour {
doorRootg.name = "Doors";
doorRootg.transform.SetParent(groom.transform);
Room grom = groom.AddComponent<Room>();
grom.SetCenter(gr.GetCenter());
ltg = ltg.FindAll(x => x.tag == "door");
ltg.ForEach(x => {
x.SetParent(doorRootg.transform);

View file

@ -8,6 +8,8 @@ public class Room : MonoBehaviour {
GROUND, WALL, DOOR, ROCK
}
Vector2Int center;
List<Door> doors;
List<Transform> spawnpoints;
@ -41,6 +43,23 @@ public class Room : MonoBehaviour {
Unlock();
}
/// <summary>
/// Center point in Generation phase.
/// </summary>
/// <param name="v"></param>
public void SetCenter(Vector2Int v) {
center = v;
}
/// <summary>
/// Returns the Center as global from the generation. TODO change this
/// Is available after Generation and after Start Phase.
/// </summary>
/// <returns></returns>
public Vector2Int GetCenter() {
return center;
}
/// <summary>
/// Reloads the spawnpoints and doors.
/// </summary>