spies trigger win animation after 3 complete missions

This commit is contained in:
Steven 2017-10-17 01:39:47 -05:00
parent 0c4f170fb8
commit 45dda740a0
6 changed files with 3030 additions and 2769 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2e0806d99e91f374fb64a63401c2eb5d
timeCreated: 1508220435
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -67,4 +67,6 @@ MonoBehaviour:
- SetIsInteractingRPC - SetIsInteractingRPC
- SetSelectedInteractionRPC - SetSelectedInteractionRPC
- SetCharacterColorRPC - SetCharacterColorRPC
- ShowWinScreen
- CaughtSpy
DisableAutoOpenWizard: 1 DisableAutoOpenWizard: 1

File diff suppressed because it is too large Load diff

View file

@ -8,13 +8,12 @@ using UnityEngine.UI;
public class WinAnimationController : MonoBehaviour { public class WinAnimationController : MonoBehaviour {
[SerializeField] [SerializeField]
private Image _spySprite, _guardSprite, _starSprite; private Image _spySprite, _guardSprite, _starSprite, _backgroundPanel;
[SerializeField] [SerializeField]
private Text _winText; private Text _winText;
[SerializeField] private static WinAnimationController _controller;
private Image _winAnimationPanel;
delegate T GetDelegate<T>(); delegate T GetDelegate<T>();
delegate void SetDelegate<T>(T value); delegate void SetDelegate<T>(T value);
@ -29,12 +28,49 @@ public class WinAnimationController : MonoBehaviour {
} }
} }
void Start () { private void Awake()
StartCoroutine(WinAnimation(false)); {
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) IEnumerator WinAnimation(bool guardsOrSpies)
{ {
SetActive(true);
_winText.gameObject.SetActive(true); _winText.gameObject.SetActive(true);
_starSprite.gameObject.SetActive(true); _starSprite.gameObject.SetActive(true);
RectTransform winnerTrans = _guardSprite.rectTransform; RectTransform winnerTrans = _guardSprite.rectTransform;
@ -119,12 +155,12 @@ public class WinAnimationController : MonoBehaviour {
float limit = 0.5f; float limit = 0.5f;
while (time < limit) while (time < limit)
{ {
_winAnimationPanel.color = new Color(0, 0, 0, time); _backgroundPanel.color = new Color(0, 0, 0, time);
float elapsedTime = Time.deltaTime * speed; float elapsedTime = Time.deltaTime * speed;
time += elapsedTime; time += elapsedTime;
yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame();
} }
_winAnimationPanel.color = new Color(0, 0, 0, limit); _backgroundPanel.color = new Color(0, 0, 0, limit);
yield return null; yield return null;
} }

View file

@ -6,15 +6,11 @@ using UnityEngine.UI;
public class ScorePanelController : Photon.PunBehaviour { public class ScorePanelController : Photon.PunBehaviour {
public Text _timerText, winText; public Text _timerText;
public Image _guardScore, _spyScore; public Image _guardScore, _spyScore;
public Text missionsCompleteText;
public GameObject winPanel;
public GameObject guardPanel;
public GameObject spyPanel;
private int _numOfMissions = 3; private int _numOfMissions = 3, _maxGuardPoints = 3;
private int _missionsComplete = 0; private int _missionsComplete = 0, _numGuardPoints = 0;
private float waitBetweenMissions = 5.0f; private float waitBetweenMissions = 5.0f;
private bool onMissionCooldown = false; private bool onMissionCooldown = false;
@ -83,6 +79,11 @@ public class ScorePanelController : Photon.PunBehaviour {
} }
StopCoroutine(flashCoroutine); StopCoroutine(flashCoroutine);
StartCoroutine(ResetScoreBarColor(scoreBar, originalColor)); 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; yield return null;
} }
@ -154,22 +155,21 @@ public class ScorePanelController : Photon.PunBehaviour {
_missionsComplete++; _missionsComplete++;
StartCoroutine(MissionCooldown()); StartCoroutine(MissionCooldown());
StartCoroutine(IncreaseScoreBarAnimation(_spyScore, (float)_missionsComplete / _numOfMissions)); StartCoroutine(IncreaseScoreBarAnimation(_spyScore, (float)_missionsComplete / _numOfMissions));
/*if (_missionsComplete >= _numOfMissions)
photonView.RPC("ShowSpiesWinScreen", PhotonTargets.All);*/
} }
[PunRPC] [PunRPC]
void ShowSpiesWinScreen() void CaughtSpy()
{ {
winPanel.SetActive(true); Debug.Log("Spy Caught!");
winText.text = "SPIES WIN!"; _numGuardPoints++;
StartCoroutine(MissionCooldown());
StartCoroutine(IncreaseScoreBarAnimation(_spyScore, (float)_missionsComplete / _numOfMissions));
} }
[PunRPC] [PunRPC]
void ShowGuardsWinScreen() void ShowWinScreen(bool guardsOrSpies)
{ {
winPanel.SetActive(true); WinAnimationController.ActiveController.PlayWinAnimation(guardsOrSpies);
winText.text = "GUARDS WIN!";
} }
#endregion #endregion