start work on microgames
This commit is contained in:
parent
ef733054ef
commit
ecff3c6b69
6 changed files with 105 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ public class LevelSwitcher : MonoBehaviour
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[SerializeField] private int mapSceneIndex;
|
[SerializeField] private int mapSceneIndex;
|
||||||
|
[SerializeField] private int microGameSceneIndex;
|
||||||
public void LoadMap(Map requestedMap, int exitIndex)
|
public void LoadMap(Map requestedMap, int exitIndex)
|
||||||
{
|
{
|
||||||
SceneManager.LoadScene(mapSceneIndex);
|
SceneManager.LoadScene(mapSceneIndex);
|
||||||
|
|
@ -34,4 +35,13 @@ public class LevelSwitcher : MonoBehaviour
|
||||||
{
|
{
|
||||||
SceneManager.LoadScene(sceneIndex);
|
SceneManager.LoadScene(sceneIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadMicroGame(MicroGameHandler gameToLoad)
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene(microGameSceneIndex);
|
||||||
|
Instantiate(gameToLoad);
|
||||||
|
//instantiate the handler
|
||||||
|
//go from there
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
Assets/Scripts/Microgame.meta
Normal file
8
Assets/Scripts/Microgame.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f2ee0c3446febbd66a9270737b9fe8f4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
46
Assets/Scripts/Microgame/MarisaPotionMaker.cs
Normal file
46
Assets/Scripts/Microgame/MarisaPotionMaker.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class MarisaPotionMaker : MicroGameHandler
|
||||||
|
{
|
||||||
|
public Potion currentPotion;
|
||||||
|
public List<Potion> requestedPotions = new();
|
||||||
|
public List<Potion> completedPotions = new();
|
||||||
|
public List<Potion> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Microgame/MarisaPotionMaker.cs.meta
Normal file
2
Assets/Scripts/Microgame/MarisaPotionMaker.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 69306313583628d9894309e3e9345c73
|
||||||
37
Assets/Scripts/Microgame/MicroGameHandler.cs
Normal file
37
Assets/Scripts/Microgame/MicroGameHandler.cs
Normal file
|
|
@ -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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Microgame/MicroGameHandler.cs.meta
Normal file
2
Assets/Scripts/Microgame/MicroGameHandler.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0f68dbe088efc507bba0135717e2ef08
|
||||||
Loading…
Add table
Add a link
Reference in a new issue