From 9e79eb619fcd8097a9ee3043984b2dec73901e3c Mon Sep 17 00:00:00 2001 From: Saibotk Date: Mon, 23 Apr 2018 16:59:39 +0200 Subject: [PATCH] Add Center methods on Room This should be changed as soon as positions are relative --- Assets/Scripts/GameController.cs | 6 +++++- Assets/Scripts/Room.cs | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index cf70356..76dd800 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -180,6 +180,7 @@ public class GameController : MonoBehaviour { doorRoot.name = "Doors"; doorRoot.transform.SetParent(goStart.transform); start = goStart.AddComponent(); + 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(); + finish.SetCenter(dg.end.GetCenter()); ltf.ForEach(x => { x.SetParent(doorRootf.transform); x.gameObject.GetComponent().SetParent(finish); @@ -227,6 +230,7 @@ public class GameController : MonoBehaviour { doorRootg.name = "Doors"; doorRootg.transform.SetParent(groom.transform); Room grom = groom.AddComponent(); + grom.SetCenter(gr.GetCenter()); ltg = ltg.FindAll(x => x.tag == "door"); ltg.ForEach(x => { x.SetParent(doorRootg.transform); diff --git a/Assets/Scripts/Room.cs b/Assets/Scripts/Room.cs index 825cd8c..ca118f1 100644 --- a/Assets/Scripts/Room.cs +++ b/Assets/Scripts/Room.cs @@ -8,6 +8,8 @@ public class Room : MonoBehaviour { GROUND, WALL, DOOR, ROCK } + Vector2Int center; + List doors; List spawnpoints; @@ -41,6 +43,23 @@ public class Room : MonoBehaviour { Unlock(); } + /// + /// Center point in Generation phase. + /// + /// + public void SetCenter(Vector2Int v) { + center = v; + } + + /// + /// Returns the Center as global from the generation. TODO change this + /// Is available after Generation and after Start Phase. + /// + /// + public Vector2Int GetCenter() { + return center; + } + /// /// Reloads the spawnpoints and doors. ///