From 5fb051bf022f329227ac4770ae57c8b380d327a7 Mon Sep 17 00:00:00 2001 From: Robin Ruud Kristensen <robin1998@hotmail.no> Date: Sat, 10 Dec 2022 10:10:13 +0100 Subject: [PATCH] added check for when all bosses have been defeated --- MrBigsock/Assets/Code/FollowPlayer.cs | 31 +++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/MrBigsock/Assets/Code/FollowPlayer.cs b/MrBigsock/Assets/Code/FollowPlayer.cs index 89d4fe1e..0a4ad569 100644 --- a/MrBigsock/Assets/Code/FollowPlayer.cs +++ b/MrBigsock/Assets/Code/FollowPlayer.cs @@ -12,8 +12,9 @@ namespace Bigsock private NeighbourMapGenerator neighborMapGenerator; [SerializeField] private CinemachineConfiner2D cameraMap; + [SerializeField] GameObject VictoryScreen; - private int levels = 1; + private int levels = 0; Vector3 offset = new Vector3(0, 0, -10); @@ -25,8 +26,10 @@ namespace Bigsock GameObject[] Chest; List<GameObject> chests; GameObject stair; + int finalLevel = 2; private int roomNr = 0; bool stairs_down; + int h = 0; void Start() { @@ -42,23 +45,43 @@ namespace Bigsock } stairs_down = stair.GetComponent<Stairs>().stairs_touch; stair.SetActive(false); + } void LateUpdate() { boss = GameObject.FindGameObjectsWithTag("Boss"); enemies = GameObject.FindGameObjectsWithTag((roomNr).ToString()); - if (boss.Length == 0 && levels <= 1) + + if (boss.Length == 0 && levels < 2) { + if (!stair.activeInHierarchy) + { + Debug.Log("hei"); + levels++; + } stair.SetActive(true); stairs_down = stair.GetComponent<Stairs>().stairs_touch; + + } + if (levels == finalLevel && h == 0) + { + Time.timeScale = 0; + GameObject canvas = GameObject.Find("Canvas"); + if(canvas != null) + { + Instantiate(VictoryScreen, canvas.transform); + h++; + } } + + if (stairs_down) { roomNr = 0; - foreach(GameObject c in chests) + foreach (GameObject c in chests) { DestroyImmediate(c); } @@ -80,7 +103,7 @@ namespace Bigsock } } stair.SetActive(false); - levels++; + } int i = 0; -- GitLab