diff --git a/MrBigsock/Assets/Code/FollowPlayer.cs b/MrBigsock/Assets/Code/FollowPlayer.cs index 585f910a41f99783eb6335217ee86fa7834b2e6d..27a60b5df8a800a2c41a1a4305adde96baaee77f 100644 --- a/MrBigsock/Assets/Code/FollowPlayer.cs +++ b/MrBigsock/Assets/Code/FollowPlayer.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; using Cinemachine; using UnityEngine; using UnityEngine.Tilemaps; @@ -23,35 +24,77 @@ namespace Bigsock GameObject[] boss; GameObject player; - GameObject door; - GameObject stairs; + GameObject[] enemies; + GameObject[] Chest; + List<GameObject> chests; + private int roomNr = 0; void Start() { + chests = new List<GameObject>(); neighborMapGenerator.RunProceduralGeneration(); player = GameObject.Find("BigSock"); + Chest = GameObject.FindGameObjectsWithTag("Chest"); + foreach(GameObject c in Chest) + { + chests.Add(c); + c.SetActive(false); + } } void LateUpdate() { boss = GameObject.FindGameObjectsWithTag("Boss"); - stairs = GameObject.Find("stairs(clone)"); + enemies = GameObject.FindGameObjectsWithTag((roomNr).ToString()); if (boss.Length == 0 && levels <= 1 && Input.GetKey(KeyCode.Return)) { - neighborMapGenerator.RunProceduralGeneration(); - player.transform.position = new Vector3(9, 5, 0); - levels++; + roomNr = 0; + foreach(GameObject c in chests) + { + Destroy(c); + } + chests.Clear(); + TilemapGenerator.resetMaps(); + TilemapGenerator.SetRoomIDZero(); + neighborMapGenerator.RunProceduralGeneration(); + Chest = GameObject.FindGameObjectsWithTag("Chest"); + Debug.Log("Size: " + Chest.Length); + foreach (GameObject c in Chest) + { + if(c != null) + { + c.SetActive(false); + chests.Add(c); + } + } + player.transform.position = new Vector3(9, 5, 0); + levels++; } + int i = 0; if(i == 0) { cameraMap.InvalidateCache(); i++; } + + if (enemies.Length == 0) + { + chests[roomNr + (6*(levels - 1))].SetActive(true); + if(roomNr + 1 < NeighbourMapGenerator.GetRoomListCount() - 1) + { + roomNr++; + } + } } private void OnDestroy() { + roomNr = 0; + foreach (GameObject c in chests) + { + Destroy(c); + } NeighbourMapGenerator.ClearRoomList(); TilemapGenerator.SetRoomIDZero(); TilemapGenerator.resetMaps();