Skip to content
Snippets Groups Projects
Commit 123d47f6 authored by Robin Ruud Kristensen's avatar Robin Ruud Kristensen
Browse files

fix looped generation. Fix: reset stair_down value to false and destroying existing stairs

parent d3c80528
No related branches found
No related tags found
1 merge request!79Ruud1
...@@ -41,27 +41,36 @@ namespace Bigsock ...@@ -41,27 +41,36 @@ namespace Bigsock
c.SetActive(false); c.SetActive(false);
} }
stairs_down = stair.GetComponent<Stairs>().stairs_touch; stairs_down = stair.GetComponent<Stairs>().stairs_touch;
stair.SetActive(false);
} }
void LateUpdate() void LateUpdate()
{ {
boss = GameObject.FindGameObjectsWithTag("Boss"); boss = GameObject.FindGameObjectsWithTag("Boss");
enemies = GameObject.FindGameObjectsWithTag((roomNr).ToString()); enemies = GameObject.FindGameObjectsWithTag((roomNr).ToString());
stairs_down = stair.GetComponent<Stairs>().stairs_touch; if (boss.Length == 0 && levels <= 1)
{
stair.SetActive(true);
stairs_down = stair.GetComponent<Stairs>().stairs_touch;
}
if (boss.Length == 0 && levels <= 1 && stairs_down) if (stairs_down)
{ {
roomNr = 0; roomNr = 0;
foreach(GameObject c in chests) foreach(GameObject c in chests)
{ {
Destroy(c); Destroy(c);
} }
DestroyImmediate(stair);
chests.Clear(); chests.Clear();
TilemapGenerator.resetMaps(); TilemapGenerator.resetMaps();
TilemapGenerator.SetRoomIDZero(); TilemapGenerator.SetRoomIDZero();
player.transform.position = new Vector3(9,5,0); player.transform.position = new Vector3(9,5,0);
neighborMapGenerator.RunProceduralGeneration(); neighborMapGenerator.RunProceduralGeneration();
Chest = GameObject.FindGameObjectsWithTag("Chest"); Chest = GameObject.FindGameObjectsWithTag("Chest");
stair = GameObject.Find("Stairs(Clone)");
stairs_down = stair.GetComponent<Stairs>().stairs_touch;
foreach (GameObject c in Chest) foreach (GameObject c in Chest)
{ {
if(c != null) if(c != null)
...@@ -70,6 +79,7 @@ namespace Bigsock ...@@ -70,6 +79,7 @@ namespace Bigsock
chests.Add(c); chests.Add(c);
} }
} }
stair.SetActive(false);
levels++; levels++;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment