Merge branch 'master' into feature/guard-cameras
This commit is contained in:
commit
d05a0a88d0
23 changed files with 3679 additions and 1858 deletions
53
Project Undercover/Assets/Animation/Static/WinAnimation.anim
Normal file
53
Project Undercover/Assets/Animation/Static/WinAnimation.anim
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!74 &7400000
|
||||||
|
AnimationClip:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 0}
|
||||||
|
m_Name: WinAnimation
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Legacy: 1
|
||||||
|
m_Compressed: 0
|
||||||
|
m_UseHighQualityCurve: 1
|
||||||
|
m_RotationCurves: []
|
||||||
|
m_CompressedRotationCurves: []
|
||||||
|
m_EulerCurves: []
|
||||||
|
m_PositionCurves: []
|
||||||
|
m_ScaleCurves: []
|
||||||
|
m_FloatCurves: []
|
||||||
|
m_PPtrCurves: []
|
||||||
|
m_SampleRate: 60
|
||||||
|
m_WrapMode: 0
|
||||||
|
m_Bounds:
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
m_Extent: {x: 0, y: 0, z: 0}
|
||||||
|
m_ClipBindingConstant:
|
||||||
|
genericBindings: []
|
||||||
|
pptrCurveMapping: []
|
||||||
|
m_AnimationClipSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||||
|
m_AdditiveReferencePoseTime: 0
|
||||||
|
m_StartTime: 0
|
||||||
|
m_StopTime: 1
|
||||||
|
m_OrientationOffsetY: 0
|
||||||
|
m_Level: 0
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_HasAdditiveReferencePose: 0
|
||||||
|
m_LoopTime: 1
|
||||||
|
m_LoopBlend: 0
|
||||||
|
m_LoopBlendOrientation: 0
|
||||||
|
m_LoopBlendPositionY: 0
|
||||||
|
m_LoopBlendPositionXZ: 0
|
||||||
|
m_KeepOriginalOrientation: 0
|
||||||
|
m_KeepOriginalPositionY: 1
|
||||||
|
m_KeepOriginalPositionXZ: 0
|
||||||
|
m_HeightFromFeet: 0
|
||||||
|
m_Mirror: 0
|
||||||
|
m_EditorCurves: []
|
||||||
|
m_EulerEditorCurves: []
|
||||||
|
m_HasGenericRootTransform: 0
|
||||||
|
m_HasMotionFloatCurves: 0
|
||||||
|
m_GenerateMotionCurves: 0
|
||||||
|
m_Events: []
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4dbdeb1d49187544091d6198b5d7d807
|
||||||
|
timeCreated: 1508048262
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,7 +1,8 @@
|
||||||
using UnityEngine;
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public struct HSBColor
|
public struct HSBColor : IEquatable<HSBColor>
|
||||||
{
|
{
|
||||||
public float h;
|
public float h;
|
||||||
public float s;
|
public float s;
|
||||||
|
@ -221,4 +222,9 @@ public struct HSBColor
|
||||||
|
|
||||||
Debug.Log("164,82,84 .... 0.643137f, 0.321568f, 0.329411f :" + ToColor(new HSBColor(new Color(0.643137f, 0.321568f, 0.329411f))));
|
Debug.Log("164,82,84 .... 0.643137f, 0.321568f, 0.329411f :" + ToColor(new HSBColor(new Color(0.643137f, 0.321568f, 0.329411f))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Equals(HSBColor other)
|
||||||
|
{
|
||||||
|
return Mathf.Abs((h - other.h)) < 0.01f && Mathf.Abs((s - other.s)) < 0.01f && Mathf.Abs((b - other.b)) < 0.01f && Mathf.Abs((a - other.a)) < 0.01f;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -144,7 +144,7 @@ Camera:
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_ClearFlags: 1
|
m_ClearFlags: 1
|
||||||
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
|
m_BackGroundColor: {r: 0.25, g: 0.25, b: 0.25, a: 0}
|
||||||
m_NormalizedViewPortRect:
|
m_NormalizedViewPortRect:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
x: 0
|
x: 0
|
||||||
|
|
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,7 +67,6 @@ MonoBehaviour:
|
||||||
- SetIsInteractingRPC
|
- SetIsInteractingRPC
|
||||||
- SetSelectedInteractionRPC
|
- SetSelectedInteractionRPC
|
||||||
- SetCharacterColorRPC
|
- SetCharacterColorRPC
|
||||||
- SetOwner
|
- ShowWinScreen
|
||||||
- AddPlayer
|
- CaughtSpy
|
||||||
- RemovePlayer
|
|
||||||
DisableAutoOpenWizard: 1
|
DisableAutoOpenWizard: 1
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -47,6 +47,6 @@ public class Interaction : ScriptableObject
|
||||||
//--------------------------------- Result functions ---------------------------------
|
//--------------------------------- Result functions ---------------------------------
|
||||||
void SpyMissionComplete(StateController controller)
|
void SpyMissionComplete(StateController controller)
|
||||||
{
|
{
|
||||||
Debug.Log("Completed mission");
|
ScorePanelController.CompleteMission();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class State : ScriptableObject
|
||||||
if (decisionSucceeded)
|
if (decisionSucceeded)
|
||||||
{
|
{
|
||||||
controller.TransitionToState(transitions[i].trueState);
|
controller.TransitionToState(transitions[i].trueState);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,6 @@ public class StateController : SelectableObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiates interaction with other StateController
|
|
||||||
public void InitiateInteractionWithSelectedObject()
|
public void InitiateInteractionWithSelectedObject()
|
||||||
{
|
{
|
||||||
if (SelectedObject == this)
|
if (SelectedObject == this)
|
||||||
|
@ -153,7 +152,6 @@ public class StateController : SelectableObject
|
||||||
return SelectedObject.Interactor != this;
|
return SelectedObject.Interactor != this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void FinishInteraction()
|
public void FinishInteraction()
|
||||||
{
|
{
|
||||||
if (IsInteracting)
|
if (IsInteracting)
|
||||||
|
@ -184,8 +182,6 @@ public class StateController : SelectableObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void StartRoaming()
|
public void StartRoaming()
|
||||||
{
|
{
|
||||||
_roamCoroutine = StartCoroutine(Roam());
|
_roamCoroutine = StartCoroutine(Roam());
|
||||||
|
|
|
@ -9,16 +9,7 @@ public class GameManager : Photon.PunBehaviour {
|
||||||
public GameObject guardController;
|
public GameObject guardController;
|
||||||
public GameObject spyPrefab, NPCPrefab, cameraRigPrefab;
|
public GameObject spyPrefab, NPCPrefab, cameraRigPrefab;
|
||||||
public int numNpcs = 9;
|
public int numNpcs = 9;
|
||||||
public int spyMissionsComplete = 0;
|
|
||||||
public float waitBetweenMissions = 5.0f;
|
|
||||||
public bool onMissionCooldown = false;
|
|
||||||
public Text missionsCompleteText;
|
|
||||||
public GameObject winPanel;
|
|
||||||
public GameObject guardPanel;
|
|
||||||
public GameObject spyPanel;
|
|
||||||
public GameObject guardCameraPanel;
|
|
||||||
public Text winText;
|
|
||||||
private int numOfMissions = 3;
|
|
||||||
|
|
||||||
public override void OnLeftRoom()
|
public override void OnLeftRoom()
|
||||||
{
|
{
|
||||||
|
@ -69,19 +60,6 @@ public class GameManager : Photon.PunBehaviour {
|
||||||
PhotonNetwork.Instantiate(NPCPrefab.name, randPos, Quaternion.identity, 0);
|
PhotonNetwork.Instantiate(NPCPrefab.name, randPos, Quaternion.identity, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CompleteMission()
|
|
||||||
{
|
|
||||||
if (!PhotonNetwork.isMasterClient || onMissionCooldown)
|
|
||||||
return;
|
|
||||||
StartCoroutine(MissionCooldown());
|
|
||||||
spyMissionsComplete++;
|
|
||||||
photonView.RPC("CompleteMissionRPC", PhotonTargets.All, spyMissionsComplete);
|
|
||||||
|
|
||||||
if (spyMissionsComplete >= numOfMissions)
|
|
||||||
photonView.RPC("ShowSpiesWinScreen", PhotonTargets.All);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PunRPC]
|
[PunRPC]
|
||||||
|
@ -89,32 +67,4 @@ public class GameManager : Photon.PunBehaviour {
|
||||||
{
|
{
|
||||||
Instantiate(NPCPrefab, pos, Quaternion.identity);
|
Instantiate(NPCPrefab, pos, Quaternion.identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
[PunRPC]
|
|
||||||
void CompleteMissionRPC(int missionsCompleted)
|
|
||||||
{
|
|
||||||
spyMissionsComplete = missionsCompleted;
|
|
||||||
missionsCompleteText.text = spyMissionsComplete + "/3";
|
|
||||||
}
|
|
||||||
|
|
||||||
[PunRPC]
|
|
||||||
void ShowSpiesWinScreen()
|
|
||||||
{
|
|
||||||
winPanel.SetActive(true);
|
|
||||||
winText.text = "SPIES WIN!";
|
|
||||||
}
|
|
||||||
|
|
||||||
[PunRPC]
|
|
||||||
void ShowGuardsWinScreen()
|
|
||||||
{
|
|
||||||
winPanel.SetActive(true);
|
|
||||||
winText.text = "GUARDS WIN!";
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator MissionCooldown()
|
|
||||||
{
|
|
||||||
onMissionCooldown = true;
|
|
||||||
yield return new WaitForSeconds(waitBetweenMissions);
|
|
||||||
onMissionCooldown = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
|
||||||
|
public class WinAnimationController : MonoBehaviour {
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Image _spySprite, _guardSprite, _starSprite, _backgroundPanel;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Text _winText;
|
||||||
|
|
||||||
|
private static WinAnimationController _controller;
|
||||||
|
|
||||||
|
delegate T GetDelegate<T>();
|
||||||
|
delegate void SetDelegate<T>(T value);
|
||||||
|
|
||||||
|
|
||||||
|
public class Vector3Ref
|
||||||
|
{
|
||||||
|
public Vector3 refVar;
|
||||||
|
public Vector3Ref(ref Vector3 refVar)
|
||||||
|
{
|
||||||
|
this.refVar = refVar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (guardsOrSpies)
|
||||||
|
{
|
||||||
|
_guardSprite.gameObject.SetActive(true);
|
||||||
|
_spySprite.gameObject.SetActive(false);
|
||||||
|
_winText.text = "Guards\nWin!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
winnerTrans = _spySprite.rectTransform;
|
||||||
|
_spySprite.gameObject.SetActive(true);
|
||||||
|
_guardSprite.gameObject.SetActive(false);
|
||||||
|
_winText.text = "Spies\nWin!";
|
||||||
|
}
|
||||||
|
|
||||||
|
StartCoroutine(FadeOutBackground(1));
|
||||||
|
|
||||||
|
// Initialize positions
|
||||||
|
Vector2 initialPos = winnerTrans.localPosition;
|
||||||
|
RectTransform starTrans = _starSprite.rectTransform;
|
||||||
|
Vector2 starSize = starTrans.sizeDelta;
|
||||||
|
starTrans.sizeDelta = new Vector2(0, 0);
|
||||||
|
winnerTrans.localPosition = new Vector2(0, Screen.height/2 + winnerTrans.sizeDelta.y / 2.0f);
|
||||||
|
|
||||||
|
// Smoothly animate drop down for winnerTrans
|
||||||
|
GetDelegate<Vector2> getter = () => { return winnerTrans.localPosition; };
|
||||||
|
SetDelegate<Vector2> setter = v => { winnerTrans.localPosition = v; };
|
||||||
|
yield return StartCoroutine(SmoothVector2Lerp(getter, setter, winnerTrans.localPosition, initialPos, 2.0f));
|
||||||
|
|
||||||
|
// Spin the star simultaneously
|
||||||
|
StartCoroutine(SpinStar(20.0f));
|
||||||
|
|
||||||
|
// Smoothly animate star reveal
|
||||||
|
getter = () => { return starTrans.sizeDelta; };
|
||||||
|
setter = v => { starTrans.sizeDelta = v; };
|
||||||
|
yield return StartCoroutine(SmoothVector2Lerp(getter, setter, starTrans.sizeDelta, starSize, 4.0f));
|
||||||
|
|
||||||
|
// Reveal Win Text
|
||||||
|
yield return StartCoroutine(RevealWinText(1));
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator SmoothVector2Lerp(GetDelegate<Vector2> getter, SetDelegate<Vector2> setter, Vector2 initial, Vector2 final, float speed)
|
||||||
|
{
|
||||||
|
setter(initial);
|
||||||
|
Vector2 yVelocity = final - initial;
|
||||||
|
float magnitude = yVelocity.magnitude;
|
||||||
|
yVelocity = yVelocity.normalized;
|
||||||
|
Vector2 overShotFinal = final + (yVelocity * magnitude * 0.1f);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Vector2 newVec = Vector2.Lerp(getter(), overShotFinal, Time.deltaTime * speed);
|
||||||
|
Vector2 checkDireciton = (final - newVec).normalized;
|
||||||
|
if (checkDireciton != yVelocity)
|
||||||
|
{
|
||||||
|
newVec = final;
|
||||||
|
setter(newVec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setter(newVec);
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
}
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator SpinStar(float speed)
|
||||||
|
{
|
||||||
|
float spin = 0.0f;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
spin += Time.deltaTime * speed;
|
||||||
|
_starSprite.rectTransform.localRotation = Quaternion.Euler(0, 0, spin);
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator FadeOutBackground(float speed)
|
||||||
|
{
|
||||||
|
float time = 0.0f;
|
||||||
|
float limit = 0.5f;
|
||||||
|
while (time < limit)
|
||||||
|
{
|
||||||
|
_backgroundPanel.color = new Color(0, 0, 0, time);
|
||||||
|
float elapsedTime = Time.deltaTime * speed;
|
||||||
|
time += elapsedTime;
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
}
|
||||||
|
_backgroundPanel.color = new Color(0, 0, 0, limit);
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator RevealWinText(float speed)
|
||||||
|
{
|
||||||
|
float time = 0.0f;
|
||||||
|
float limit = 1.0f;
|
||||||
|
while (time < limit)
|
||||||
|
{
|
||||||
|
_winText.color = new Color(1, 1, 1, time);
|
||||||
|
float elapsedTime = Time.deltaTime * speed;
|
||||||
|
time += elapsedTime;
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
}
|
||||||
|
_winText.color = new Color(1, 1, 1, limit);
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7649e1dc9bb2cf240a4dcccdcb51d1d0
|
||||||
|
timeCreated: 1508041492
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -53,7 +53,7 @@ public class InteractionPanelController : MonoBehaviour {
|
||||||
var data = new InteractionData(interaction, false);
|
var data = new InteractionData(interaction, false);
|
||||||
optionsList.Add(data);
|
optionsList.Add(data);
|
||||||
}
|
}
|
||||||
if (controller.SelectedObject.CompareTag("Spy"))
|
if (true || controller.SelectedObject.CompareTag("Spy"))
|
||||||
{
|
{
|
||||||
foreach (Interaction interaction in controller.SelectedObject.spyInteractions)
|
foreach (Interaction interaction in controller.SelectedObject.spyInteractions)
|
||||||
{
|
{
|
||||||
|
|
176
Project Undercover/Assets/Scripts/UI/ScorePanelController.cs
Normal file
176
Project Undercover/Assets/Scripts/UI/ScorePanelController.cs
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class ScorePanelController : Photon.PunBehaviour {
|
||||||
|
|
||||||
|
public Text _timerText;
|
||||||
|
public Image _guardScore, _spyScore;
|
||||||
|
|
||||||
|
private int _numOfMissions = 3, _maxGuardPoints = 3;
|
||||||
|
private int _missionsComplete = 0, _numGuardPoints = 0;
|
||||||
|
private float waitBetweenMissions = 5.0f;
|
||||||
|
private bool onMissionCooldown = false;
|
||||||
|
|
||||||
|
private float _initalScoreWidth;
|
||||||
|
private static ScorePanelController ActivePanel;
|
||||||
|
|
||||||
|
void Start () {
|
||||||
|
if (!ActivePanel)
|
||||||
|
ActivePanel = this;
|
||||||
|
else
|
||||||
|
Debug.LogError("Two ScorePanelControllers in the scene");
|
||||||
|
StartCoroutine(TimerUpdate());
|
||||||
|
|
||||||
|
// Initialize scorebar variables
|
||||||
|
_initalScoreWidth = _spyScore.rectTransform.sizeDelta.x;
|
||||||
|
_spyScore.rectTransform.sizeDelta = new Vector2(-1, _spyScore.rectTransform.sizeDelta.y);
|
||||||
|
_guardScore.rectTransform.sizeDelta = new Vector2(-1, _guardScore.rectTransform.sizeDelta.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CompleteMission()
|
||||||
|
{
|
||||||
|
if (ActivePanel.onMissionCooldown)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ActivePanel.photonView.RPC("CompleteMissionRPC", PhotonTargets.All);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Coroutines
|
||||||
|
IEnumerator TimerUpdate()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
int seconds = (int)Time.timeSinceLevelLoad;
|
||||||
|
int minutes = seconds / 60;
|
||||||
|
seconds = seconds % 60;
|
||||||
|
string timeString = "";
|
||||||
|
if (seconds < 10)
|
||||||
|
timeString = minutes.ToString() + ":0" + seconds.ToString();
|
||||||
|
else
|
||||||
|
timeString = minutes.ToString() + ":" + seconds.ToString();
|
||||||
|
_timerText.text = timeString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IncreaseScoreBarAnimation(Image scoreBar, float progress)
|
||||||
|
{
|
||||||
|
Color originalColor = scoreBar.color;
|
||||||
|
var flashCoroutine = StartCoroutine(FlashScoreBar(scoreBar));
|
||||||
|
float targetWidth = _initalScoreWidth * progress;
|
||||||
|
float overshotWidth = targetWidth * 1.2f;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Vector2 sizeDelta = scoreBar.rectTransform.sizeDelta;
|
||||||
|
float newWidth = Mathf.Lerp(sizeDelta.x, overshotWidth, Time.deltaTime * 0.8f);
|
||||||
|
if (sizeDelta.x < targetWidth)
|
||||||
|
{
|
||||||
|
scoreBar.rectTransform.sizeDelta = new Vector2(newWidth, sizeDelta.y);
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scoreBar.rectTransform.sizeDelta = new Vector2(targetWidth, sizeDelta.y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator FlashScoreBar(Image scoreBar)
|
||||||
|
{
|
||||||
|
Color darkerColor = scoreBar.color;
|
||||||
|
darkerColor.r *= 0.5f;
|
||||||
|
darkerColor.g *= 0.5f;
|
||||||
|
darkerColor.b *= 0.5f;
|
||||||
|
HSBColor darkColor = HSBColor.FromColor(darkerColor);
|
||||||
|
HSBColor flashColor = HSBColor.FromColor(Color.yellow);
|
||||||
|
HSBColor currentColor = darkColor;
|
||||||
|
bool pingPong = true;
|
||||||
|
float time = 0.0f;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
float elapsedTime = Time.deltaTime * 2.0f;
|
||||||
|
if (pingPong)
|
||||||
|
time += elapsedTime;
|
||||||
|
else
|
||||||
|
time -= elapsedTime;
|
||||||
|
time = Mathf.Clamp01(time);
|
||||||
|
if (time == 0.0f)
|
||||||
|
pingPong = true;
|
||||||
|
else if (time == 1.0f)
|
||||||
|
pingPong = false;
|
||||||
|
|
||||||
|
currentColor = HSBColor.Lerp(darkColor, flashColor, time);
|
||||||
|
scoreBar.color = currentColor.ToColor();
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator ResetScoreBarColor(Image scoreBar, Color originalColor)
|
||||||
|
{
|
||||||
|
float time = 0.0f;
|
||||||
|
HSBColor startColor = HSBColor.FromColor(scoreBar.color);
|
||||||
|
HSBColor endColor = HSBColor.FromColor(originalColor);
|
||||||
|
HSBColor currentColor = startColor;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
time += Time.deltaTime * 2.0f;
|
||||||
|
time = Mathf.Clamp01(time);
|
||||||
|
currentColor = HSBColor.Lerp(startColor, endColor, time);
|
||||||
|
scoreBar.color = currentColor.ToColor();
|
||||||
|
if (time >= 0.90f)
|
||||||
|
{
|
||||||
|
scoreBar.color = originalColor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
}
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator MissionCooldown()
|
||||||
|
{
|
||||||
|
onMissionCooldown = true;
|
||||||
|
yield return new WaitForSeconds(waitBetweenMissions);
|
||||||
|
onMissionCooldown = false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PunRPC
|
||||||
|
[PunRPC]
|
||||||
|
void CompleteMissionRPC()
|
||||||
|
{
|
||||||
|
Debug.Log("Mission Completed!");
|
||||||
|
_missionsComplete++;
|
||||||
|
StartCoroutine(MissionCooldown());
|
||||||
|
StartCoroutine(IncreaseScoreBarAnimation(_spyScore, (float)_missionsComplete / _numOfMissions));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PunRPC]
|
||||||
|
void CaughtSpy()
|
||||||
|
{
|
||||||
|
Debug.Log("Spy Caught!");
|
||||||
|
_numGuardPoints++;
|
||||||
|
StartCoroutine(MissionCooldown());
|
||||||
|
StartCoroutine(IncreaseScoreBarAnimation(_spyScore, (float)_missionsComplete / _numOfMissions));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PunRPC]
|
||||||
|
void ShowWinScreen(bool guardsOrSpies)
|
||||||
|
{
|
||||||
|
WinAnimationController.ActiveController.PlayWinAnimation(guardsOrSpies);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ed9bfa14979ce36469ee284add674c83
|
||||||
|
timeCreated: 1508017086
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Project Undercover/Assets/Sprites/Spy.png
Normal file
BIN
Project Undercover/Assets/Sprites/Spy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
82
Project Undercover/Assets/Sprites/Spy.png.meta
Normal file
82
Project Undercover/Assets/Sprites/Spy.png.meta
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 51df7eb9a0e478c4f8393a275e950f17
|
||||||
|
timeCreated: 1508015222
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 4
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: -1
|
||||||
|
wrapW: -1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
platformSettings:
|
||||||
|
- buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
- buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Project Undercover/Assets/Sprites/Star.png
Normal file
BIN
Project Undercover/Assets/Sprites/Star.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
82
Project Undercover/Assets/Sprites/Star.png.meta
Normal file
82
Project Undercover/Assets/Sprites/Star.png.meta
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 77ec7f18eba605440a6da4ebcad55f18
|
||||||
|
timeCreated: 1508042231
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 4
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: -1
|
||||||
|
wrapW: -1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 0
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
platformSettings:
|
||||||
|
- buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
- buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Project Undercover/Assets/Sprites/guard.png
Normal file
BIN
Project Undercover/Assets/Sprites/guard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
82
Project Undercover/Assets/Sprites/guard.png.meta
Normal file
82
Project Undercover/Assets/Sprites/guard.png.meta
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a47b41bbfb07e2b4ca148f318e944056
|
||||||
|
timeCreated: 1508015222
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 4
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: -1
|
||||||
|
wrapW: -1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
platformSettings:
|
||||||
|
- buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
- buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Reference in a new issue