summaryrefslogtreecommitdiff
path: root/GameCode/UIHandler.cs
blob: 72d0b631ea7d94be96f96804e35d69ca1e46f7ab (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
using System;
using System.Collections;
using Sonigon;
using TMPro;
using UnityEngine;

public class UIHandler : MonoBehaviour
{
	[Header("Sounds")]
	public SoundEvent soundTextAppear;

	public SoundEvent soundTextDisappear;

	public static UIHandler instance;

	[Header("Settings")]
	public TextMeshProUGUI gameOverText;

	public GeneralParticleSystem gameOverTextPart;

	public GeneralParticleSystem roundBackgroundPart;

	public GeneralParticleSystem roundTextPart;

	public CodeAnimation roundCounterAnim;

	public RoundCounter roundCounter;

	public RoundCounter roundCounterSmall;

	public CodeAnimation roundCounterAnimSmall;

	public GameObject pickerObject;

	public GeneralParticleSystem pickerPart;

	public GeneralParticleSystem joinGamePart;

	public TextMeshProUGUI jointGameText;

	public PopUpHandler popUpHandler;

	private void Awake()
	{
		instance = this;
		popUpHandler = base.transform.root.GetComponentInChildren<PopUpHandler>();
	}

	public void ShowJoinGameText(string text, Color color)
	{
		SoundManager.Instance.Play(soundTextAppear, base.transform);
		if (text != "")
		{
			jointGameText.text = text;
		}
		if (color != Color.black)
		{
			joinGamePart.particleSettings.color = color;
		}
		joinGamePart.loop = true;
		joinGamePart.Play();
	}

	internal void SetNumberOfRounds(int roundsToWinGame)
	{
		roundCounter.SetNumberOfRounds(roundsToWinGame);
		roundCounterSmall.SetNumberOfRounds(roundsToWinGame);
	}

	public void HideJoinGameText()
	{
		SoundManager.Instance.Play(soundTextDisappear, base.transform);
		joinGamePart.Stop();
	}

	public void DisplayScreenText(Color color, string text, float speed)
	{
		gameOverTextPart.particleSettings.color = color;
		gameOverTextPart.duration = 60f / speed;
		gameOverTextPart.Play();
		gameOverText.text = text;
	}

	public void DisplayScreenTextLoop(string text)
	{
		gameOverTextPart.duration = 60f;
		gameOverTextPart.loop = true;
		gameOverTextPart.Play();
		gameOverText.text = text;
	}

	public void DisplayScreenTextLoop(Color color, string text)
	{
		gameOverTextPart.particleSettings.color = color;
		gameOverTextPart.duration = 60f;
		gameOverTextPart.loop = true;
		gameOverTextPart.Play();
		gameOverText.text = text;
	}

	public void StopScreenTextLoop()
	{
		gameOverTextPart.loop = false;
	}

	public void ShowAddPoint(Color color, string winTextBefore, string text, float speed)
	{
		gameOverTextPart.particleSettings.color = color;
		gameOverTextPart.duration = 60f / speed;
		gameOverTextPart.Play();
		StartCoroutine(DoShowAddPoint(winTextBefore, text));
	}

	private IEnumerator DoShowAddPoint(string winTextBefore, string text)
	{
		gameOverText.text = winTextBefore;
		yield return new WaitForSecondsRealtime(0.7f);
		gameOverText.text = text;
	}

	public void ShowRoundOver(int p1Rounds, int p2Rounds)
	{
		roundCounter.gameObject.SetActive(value: true);
		roundBackgroundPart.Play();
		roundTextPart.Play();
		roundCounterAnim.PlayIn();
		roundCounter.UpdateRounds(p1Rounds, p2Rounds);
	}

	public void ShowRoundCounterSmall(int p1Rounds, int p2Rounds, int p1Points, int p2Points)
	{
		roundCounterSmall.gameObject.SetActive(value: true);
		roundCounterSmall.UpdateRounds(p1Rounds, p2Rounds);
		roundCounterSmall.UpdatePoints(p1Points, p2Points);
		if (roundCounterAnimSmall.currentState != 0)
		{
			roundCounterAnimSmall.PlayIn();
		}
	}

	public void HideRoundCounterSmall()
	{
		roundCounterAnimSmall.PlayOut();
	}

	public void ShowPicker(int pickerID, PickerType pickerType = PickerType.Team)
	{
		pickerObject.SetActive(value: true);
		if (pickerType == PickerType.Team)
		{
			pickerPart.particleSettings.color = PlayerManager.instance.GetColorFromTeam(pickerID).winText;
		}
		if (pickerType == PickerType.Player)
		{
			pickerPart.particleSettings.color = PlayerManager.instance.GetColorFromPlayer(pickerID).winText;
		}
		pickerPart.loop = true;
		pickerPart.Play();
	}

	public void StopShowPicker()
	{
		StartCoroutine(DoStopShowPicker());
	}

	private IEnumerator DoStopShowPicker()
	{
		pickerPart.loop = false;
		yield return new WaitForSeconds(0.3f);
		pickerObject.SetActive(value: false);
	}

	internal void DisplayYesNoLoop(Player pickingPlayer, Action<PopUpHandler.YesNo> functionToCall)
	{
		popUpHandler.StartPicking(pickingPlayer, functionToCall);
	}
}