spies trigger win animation after 3 complete missions
This commit is contained in:
parent
0c4f170fb8
commit
45dda740a0
6 changed files with 3030 additions and 2769 deletions
2797
Project Undercover/Assets/Resources/GameUI.prefab
Normal file
2797
Project Undercover/Assets/Resources/GameUI.prefab
Normal file
File diff suppressed because it is too large
Load diff
9
Project Undercover/Assets/Resources/GameUI.prefab.meta
Normal file
9
Project Undercover/Assets/Resources/GameUI.prefab.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2e0806d99e91f374fb64a63401c2eb5d
|
||||
timeCreated: 1508220435
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 100100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -67,4 +67,6 @@ MonoBehaviour:
|
|||
- SetIsInteractingRPC
|
||||
- SetSelectedInteractionRPC
|
||||
- SetCharacterColorRPC
|
||||
- ShowWinScreen
|
||||
- CaughtSpy
|
||||
DisableAutoOpenWizard: 1
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -8,13 +8,12 @@ using UnityEngine.UI;
|
|||
public class WinAnimationController : MonoBehaviour {
|
||||
|
||||
[SerializeField]
|
||||
private Image _spySprite, _guardSprite, _starSprite;
|
||||
private Image _spySprite, _guardSprite, _starSprite, _backgroundPanel;
|
||||
|
||||
[SerializeField]
|
||||
private Text _winText;
|
||||
|
||||
[SerializeField]
|
||||
private Image _winAnimationPanel;
|
||||
private static WinAnimationController _controller;
|
||||
|
||||
delegate T GetDelegate<T>();
|
||||
delegate void SetDelegate<T>(T value);
|
||||
|
@ -29,12 +28,49 @@ public class WinAnimationController : MonoBehaviour {
|
|||
}
|
||||
}
|
||||
|
||||
void Start () {
|
||||
StartCoroutine(WinAnimation(false));
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
ActiveController = this;
|
||||
}
|
||||
|
||||
public void PlayWinAnimation(bool guardsOrSpies)
|
||||
{
|
||||
StartCoroutine(WinAnimation(guardsOrSpies));
|
||||
}
|
||||
|
||||
private void SetActive(bool active)
|
||||
{
|
||||
_spySprite.gameObject.SetActive(active);
|
||||
_guardSprite.gameObject.SetActive(active);
|
||||
_starSprite.gameObject.SetActive(active);
|
||||
_winText.gameObject.SetActive(active);
|
||||
_backgroundPanel.gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
public static WinAnimationController ActiveController
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_controller)
|
||||
return _controller;
|
||||
else
|
||||
{
|
||||
Debug.LogError("There is no WinAnimationController in the scene");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!_controller)
|
||||
_controller = value;
|
||||
else
|
||||
Debug.LogError("There is no WinAnimationController in the scene");
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator WinAnimation(bool guardsOrSpies)
|
||||
{
|
||||
SetActive(true);
|
||||
_winText.gameObject.SetActive(true);
|
||||
_starSprite.gameObject.SetActive(true);
|
||||
RectTransform winnerTrans = _guardSprite.rectTransform;
|
||||
|
@ -119,12 +155,12 @@ public class WinAnimationController : MonoBehaviour {
|
|||
float limit = 0.5f;
|
||||
while (time < limit)
|
||||
{
|
||||
_winAnimationPanel.color = new Color(0, 0, 0, time);
|
||||
_backgroundPanel.color = new Color(0, 0, 0, time);
|
||||
float elapsedTime = Time.deltaTime * speed;
|
||||
time += elapsedTime;
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
_winAnimationPanel.color = new Color(0, 0, 0, limit);
|
||||
_backgroundPanel.color = new Color(0, 0, 0, limit);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,15 +6,11 @@ using UnityEngine.UI;
|
|||
|
||||
public class ScorePanelController : Photon.PunBehaviour {
|
||||
|
||||
public Text _timerText, winText;
|
||||
public Text _timerText;
|
||||
public Image _guardScore, _spyScore;
|
||||
public Text missionsCompleteText;
|
||||
public GameObject winPanel;
|
||||
public GameObject guardPanel;
|
||||
public GameObject spyPanel;
|
||||
|
||||
private int _numOfMissions = 3;
|
||||
private int _missionsComplete = 0;
|
||||
private int _numOfMissions = 3, _maxGuardPoints = 3;
|
||||
private int _missionsComplete = 0, _numGuardPoints = 0;
|
||||
private float waitBetweenMissions = 5.0f;
|
||||
private bool onMissionCooldown = false;
|
||||
|
||||
|
@ -83,6 +79,11 @@ public class ScorePanelController : Photon.PunBehaviour {
|
|||
}
|
||||
StopCoroutine(flashCoroutine);
|
||||
StartCoroutine(ResetScoreBarColor(scoreBar, originalColor));
|
||||
if (_numGuardPoints >= _maxGuardPoints)
|
||||
photonView.RPC("ShowWinScreen", PhotonTargets.All, true);
|
||||
else if (_missionsComplete >= _numOfMissions)
|
||||
photonView.RPC("ShowWinScreen", PhotonTargets.All, false);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
|
@ -154,22 +155,21 @@ public class ScorePanelController : Photon.PunBehaviour {
|
|||
_missionsComplete++;
|
||||
StartCoroutine(MissionCooldown());
|
||||
StartCoroutine(IncreaseScoreBarAnimation(_spyScore, (float)_missionsComplete / _numOfMissions));
|
||||
/*if (_missionsComplete >= _numOfMissions)
|
||||
photonView.RPC("ShowSpiesWinScreen", PhotonTargets.All);*/
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void ShowSpiesWinScreen()
|
||||
void CaughtSpy()
|
||||
{
|
||||
winPanel.SetActive(true);
|
||||
winText.text = "SPIES WIN!";
|
||||
Debug.Log("Spy Caught!");
|
||||
_numGuardPoints++;
|
||||
StartCoroutine(MissionCooldown());
|
||||
StartCoroutine(IncreaseScoreBarAnimation(_spyScore, (float)_missionsComplete / _numOfMissions));
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void ShowGuardsWinScreen()
|
||||
void ShowWinScreen(bool guardsOrSpies)
|
||||
{
|
||||
winPanel.SetActive(true);
|
||||
winText.text = "GUARDS WIN!";
|
||||
WinAnimationController.ActiveController.PlayWinAnimation(guardsOrSpies);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
Reference in a new issue