aboutsummaryrefslogtreecommitdiffstats
path: root/Assets/Scripts/LevelController.cs
diff options
context:
space:
mode:
authorNeil Kollack <nkollack@gmail.com>2022-04-16 16:33:55 -0500
committerNeil Kollack <nkollack@gmail.com>2022-04-16 16:33:55 -0500
commit5339e773f247bdf81fa3b30a4a03c748732b5046 (patch)
treedc733314de0dc1d261db2531c739788b167635b1 /Assets/Scripts/LevelController.cs
parent92690dd53e3bfc05bbd8b7338f6e57961eb08b93 (diff)
fix: feedback(easier trap section + better damage)
Diffstat (limited to 'Assets/Scripts/LevelController.cs')
-rw-r--r--Assets/Scripts/LevelController.cs46
1 files changed, 40 insertions, 6 deletions
diff --git a/Assets/Scripts/LevelController.cs b/Assets/Scripts/LevelController.cs
index 7c7355e..1b8bd47 100644
--- a/Assets/Scripts/LevelController.cs
+++ b/Assets/Scripts/LevelController.cs
@@ -1,12 +1,15 @@
using System.Collections;
using System.Collections.Generic;
+using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelController : MonoBehaviour
{
[SerializeField] GameObject treasure;
- // Start is called before the first frame update
+ [SerializeField] List<GameObject> enemies;
+
+ private string clone = "(Clone)";
public void StartGame()
{
@@ -15,13 +18,44 @@ public class LevelController : MonoBehaviour
public void ResetLevel()
{
+ //Destroy
Destroy(GameObject.Find("Boulder(Clone)"));
Destroy(GameObject.Find("BoobyTrapSpawnPoint(Clone)"));
- var currentTreasure = GameObject.Find("Treasure");
- if(currentTreasure)
- Destroy(currentTreasure);
- else
- Destroy(GameObject.Find("Treasure(Clone)"));
+ CloneDestroy("Treasure");
+ DestroyList(enemies);
+
+ //Instantiate
Instantiate(treasure);
+ InstantiateList(enemies);
+ }
+
+ private void CloneDestroy(string objectName)
+ {
+ var obj = GameObject.Find(objectName);
+ if (obj)
+ Destroy(obj);
+ else
+ {
+ obj = GameObject.Find(objectName + clone);
+ if (obj)
+ Destroy(GameObject.Find(objectName + clone));
+ }
+ }
+
+ private void DestroyList(List<GameObject> gameObjects)
+ {
+ foreach(GameObject obj in gameObjects)
+ {
+ CloneDestroy(obj.name);
+ }
+ }
+
+ private void InstantiateList(List<GameObject> gameObjects)
+ {
+ foreach (GameObject obj in gameObjects)
+ {
+ PrefabUtility.RevertPrefabInstance(obj, InteractionMode.AutomatedAction);
+ Instantiate(obj);
+ }
}
}