Add Center methods on Room
This should be changed as soon as positions are relative
This commit is contained in:
parent
a131873f26
commit
9e79eb619f
2 changed files with 24 additions and 1 deletions
|
@ -180,6 +180,7 @@ public class GameController : MonoBehaviour {
|
||||||
doorRoot.name = "Doors";
|
doorRoot.name = "Doors";
|
||||||
doorRoot.transform.SetParent(goStart.transform);
|
doorRoot.transform.SetParent(goStart.transform);
|
||||||
start = goStart.AddComponent<Room>();
|
start = goStart.AddComponent<Room>();
|
||||||
|
start.SetCenter(dg.start.GetCenter());
|
||||||
lt = lt.FindAll(x => x.tag == "door");
|
lt = lt.FindAll(x => x.tag == "door");
|
||||||
lt.ForEach(x => {
|
lt.ForEach(x => {
|
||||||
x.SetParent(doorRoot.transform);
|
x.SetParent(doorRoot.transform);
|
||||||
|
@ -198,6 +199,7 @@ public class GameController : MonoBehaviour {
|
||||||
start.SetSpawnPointsRootObject(spawnpointRoot);
|
start.SetSpawnPointsRootObject(spawnpointRoot);
|
||||||
|
|
||||||
start.Reload();
|
start.Reload();
|
||||||
|
|
||||||
start.transform.SetParent(mapRoot.transform);
|
start.transform.SetParent(mapRoot.transform);
|
||||||
|
|
||||||
// Finish room
|
// Finish room
|
||||||
|
@ -209,6 +211,7 @@ public class GameController : MonoBehaviour {
|
||||||
doorRootf.transform.SetParent(goFinish.transform);
|
doorRootf.transform.SetParent(goFinish.transform);
|
||||||
ltf = ltf.FindAll(x => x.tag == "door");
|
ltf = ltf.FindAll(x => x.tag == "door");
|
||||||
finish = goFinish.AddComponent<Room>();
|
finish = goFinish.AddComponent<Room>();
|
||||||
|
finish.SetCenter(dg.end.GetCenter());
|
||||||
ltf.ForEach(x => {
|
ltf.ForEach(x => {
|
||||||
x.SetParent(doorRootf.transform);
|
x.SetParent(doorRootf.transform);
|
||||||
x.gameObject.GetComponent<Door>().SetParent(finish);
|
x.gameObject.GetComponent<Door>().SetParent(finish);
|
||||||
|
@ -227,6 +230,7 @@ public class GameController : MonoBehaviour {
|
||||||
doorRootg.name = "Doors";
|
doorRootg.name = "Doors";
|
||||||
doorRootg.transform.SetParent(groom.transform);
|
doorRootg.transform.SetParent(groom.transform);
|
||||||
Room grom = groom.AddComponent<Room>();
|
Room grom = groom.AddComponent<Room>();
|
||||||
|
grom.SetCenter(gr.GetCenter());
|
||||||
ltg = ltg.FindAll(x => x.tag == "door");
|
ltg = ltg.FindAll(x => x.tag == "door");
|
||||||
ltg.ForEach(x => {
|
ltg.ForEach(x => {
|
||||||
x.SetParent(doorRootg.transform);
|
x.SetParent(doorRootg.transform);
|
||||||
|
|
|
@ -8,6 +8,8 @@ public class Room : MonoBehaviour {
|
||||||
GROUND, WALL, DOOR, ROCK
|
GROUND, WALL, DOOR, ROCK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2Int center;
|
||||||
|
|
||||||
List<Door> doors;
|
List<Door> doors;
|
||||||
List<Transform> spawnpoints;
|
List<Transform> spawnpoints;
|
||||||
|
|
||||||
|
@ -41,6 +43,23 @@ public class Room : MonoBehaviour {
|
||||||
Unlock();
|
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>
|
/// <summary>
|
||||||
/// Reloads the spawnpoints and doors.
|
/// Reloads the spawnpoints and doors.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Reference in a new issue