summaryrefslogtreecommitdiff
path: root/GameCode/PopUpHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'GameCode/PopUpHandler.cs')
-rw-r--r--GameCode/PopUpHandler.cs97
1 files changed, 97 insertions, 0 deletions
diff --git a/GameCode/PopUpHandler.cs b/GameCode/PopUpHandler.cs
new file mode 100644
index 0000000..198c9b8
--- /dev/null
+++ b/GameCode/PopUpHandler.cs
@@ -0,0 +1,97 @@
+using System;
+using UnityEngine;
+
+public class PopUpHandler : MonoBehaviour
+{
+ public enum YesNo
+ {
+ Yes,
+ No
+ }
+
+ public CurveAnimation yesAnim;
+
+ public CurveAnimation noAnim;
+
+ public bool isPicking;
+
+ public GeneralParticleSystem yesPart;
+
+ public GeneralParticleSystem noPart;
+
+ public GeneralInput playerInput;
+
+ private Action<YesNo> fToCall;
+
+ private YesNo currentYesNo;
+
+ private void Start()
+ {
+ }
+
+ public void StartPicking(Player player, Action<YesNo> functionToCall)
+ {
+ PlayerManager.instance.RevivePlayers();
+ PlayerManager.instance.SetPlayersSimulated(simulated: true);
+ isPicking = true;
+ fToCall = functionToCall;
+ yesPart.particleSettings.color = PlayerManager.instance.GetColorFromTeam(player.teamID).winText;
+ noPart.particleSettings.color = PlayerManager.instance.GetColorFromTeam(player.teamID).winText;
+ yesPart.loop = true;
+ yesPart.Play();
+ yesAnim.PlayIn();
+ noPart.loop = true;
+ noPart.Play();
+ }
+
+ private void DonePicking()
+ {
+ fToCall(currentYesNo);
+ isPicking = false;
+ noPart.loop = false;
+ yesPart.loop = false;
+ }
+
+ private void Update()
+ {
+ if (!isPicking)
+ {
+ return;
+ }
+ for (int i = 0; i < PlayerManager.instance.players.Count; i++)
+ {
+ if (PlayerManager.instance.players[i].data.view.IsMine)
+ {
+ playerInput = PlayerManager.instance.players[i].data.input;
+ if (playerInput.stickPressDir == GeneralInput.StickDirection.Left && currentYesNo != 0)
+ {
+ currentYesNo = YesNo.Yes;
+ UpdateUI();
+ }
+ if (playerInput.stickPressDir == GeneralInput.StickDirection.Right && currentYesNo != YesNo.No)
+ {
+ currentYesNo = YesNo.No;
+ UpdateUI();
+ }
+ if (playerInput.acceptWasPressed)
+ {
+ DonePicking();
+ }
+ }
+ }
+ }
+
+ private void UpdateUI()
+ {
+ if (currentYesNo == YesNo.Yes)
+ {
+ yesAnim.PlayIn();
+ noAnim.PlayOut();
+ }
+ else
+ {
+ yesAnim.PlayOut();
+ noAnim.PlayIn();
+ }
+ }
+}