blob: 198c9b8e489a2c0446a5726e230e248636cc1806 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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();
}
}
}
|