From ecff3c6b69e6f7218771c8933a076bd2d055b76d Mon Sep 17 00:00:00 2001 From: myondev Date: Thu, 3 Sep 2026 08:59:35 -0700 Subject: [PATCH] start work on microgames --- Assets/Scripts/LevelSwitcher.cs | 10 ++++ Assets/Scripts/Microgame.meta | 8 ++++ Assets/Scripts/Microgame/MarisaPotionMaker.cs | 46 +++++++++++++++++++ .../Microgame/MarisaPotionMaker.cs.meta | 2 + Assets/Scripts/Microgame/MicroGameHandler.cs | 37 +++++++++++++++ .../Microgame/MicroGameHandler.cs.meta | 2 + 6 files changed, 105 insertions(+) create mode 100644 Assets/Scripts/Microgame.meta create mode 100644 Assets/Scripts/Microgame/MarisaPotionMaker.cs create mode 100644 Assets/Scripts/Microgame/MarisaPotionMaker.cs.meta create mode 100644 Assets/Scripts/Microgame/MicroGameHandler.cs create mode 100644 Assets/Scripts/Microgame/MicroGameHandler.cs.meta diff --git a/Assets/Scripts/LevelSwitcher.cs b/Assets/Scripts/LevelSwitcher.cs index aa6d7f6..0297550 100644 --- a/Assets/Scripts/LevelSwitcher.cs +++ b/Assets/Scripts/LevelSwitcher.cs @@ -21,6 +21,7 @@ public class LevelSwitcher : MonoBehaviour #endregion [SerializeField] private int mapSceneIndex; + [SerializeField] private int microGameSceneIndex; public void LoadMap(Map requestedMap, int exitIndex) { SceneManager.LoadScene(mapSceneIndex); @@ -34,4 +35,13 @@ public class LevelSwitcher : MonoBehaviour { SceneManager.LoadScene(sceneIndex); } + + public void LoadMicroGame(MicroGameHandler gameToLoad) + { + SceneManager.LoadScene(microGameSceneIndex); + Instantiate(gameToLoad); + //instantiate the handler + //go from there + + } } diff --git a/Assets/Scripts/Microgame.meta b/Assets/Scripts/Microgame.meta new file mode 100644 index 0000000..60970d1 --- /dev/null +++ b/Assets/Scripts/Microgame.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f2ee0c3446febbd66a9270737b9fe8f4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Microgame/MarisaPotionMaker.cs b/Assets/Scripts/Microgame/MarisaPotionMaker.cs new file mode 100644 index 0000000..df69eab --- /dev/null +++ b/Assets/Scripts/Microgame/MarisaPotionMaker.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +public class MarisaPotionMaker : MicroGameHandler +{ + public Potion currentPotion; + public List requestedPotions = new(); + public List completedPotions = new(); + public List failedPotions = new(); //bad to have 3 lists but whatever. + public int currentPotionIndex; + + public class Potion + { + public string[] chemicals; + } + + public void AddChemical(string chemical) + { + if (currentPotion.chemicals[currentPotionIndex+1] == chemical ) + { + currentPotionIndex++; + if (currentPotion.chemicals.Length > currentPotionIndex) + { + CompletePotion(currentPotion, true); + } + } + else + { + CompletePotion(currentPotion, false); + } + } + + public void CompletePotion(Potion potion, bool success) + { + requestedPotions.Remove(potion); //doesn't work if there's multiple of the same potion.... + if (success) + { + completedPotions.Add(potion); + } + else + { + failedPotions.Add(potion); + } + } +} diff --git a/Assets/Scripts/Microgame/MarisaPotionMaker.cs.meta b/Assets/Scripts/Microgame/MarisaPotionMaker.cs.meta new file mode 100644 index 0000000..a83b68c --- /dev/null +++ b/Assets/Scripts/Microgame/MarisaPotionMaker.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 69306313583628d9894309e3e9345c73 \ No newline at end of file diff --git a/Assets/Scripts/Microgame/MicroGameHandler.cs b/Assets/Scripts/Microgame/MicroGameHandler.cs new file mode 100644 index 0000000..074ce25 --- /dev/null +++ b/Assets/Scripts/Microgame/MicroGameHandler.cs @@ -0,0 +1,37 @@ +using System; +using UnityEngine; + +public class MicroGameHandler : MonoBehaviour +{ + public float timeLimit; + private float currentTime; + public int score; + public int minimumScore; + public bool loseOnTimeLimit; + private void Update() + { + currentTime -= Time.deltaTime; + if (currentTime < 0) + { + TimeOut(); + } + } + + private void TimeOut() + { + if (loseOnTimeLimit || (minimumScore > 0 && score < minimumScore)) + { + FailGame(); + } + } + + public void FailGame() + { + + } + + public void WinGame() + { + + } +} diff --git a/Assets/Scripts/Microgame/MicroGameHandler.cs.meta b/Assets/Scripts/Microgame/MicroGameHandler.cs.meta new file mode 100644 index 0000000..6ba079c --- /dev/null +++ b/Assets/Scripts/Microgame/MicroGameHandler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0f68dbe088efc507bba0135717e2ef08 \ No newline at end of file