From dc5d28124529a900ae6450ed740f223f900e2307 Mon Sep 17 00:00:00 2001 From: lordmizel Date: Mon, 23 Apr 2018 22:23:15 +0200 Subject: [PATCH] [LCS-67] Waz now has dying animation. --- ShowPT/Assets/Scripts/AIWazI.cs | 11 +++++++++-- ShowPT/Assets/Scripts/Waz.cs | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ShowPT/Assets/Scripts/AIWazI.cs b/ShowPT/Assets/Scripts/AIWazI.cs index 58fc8459..e8d8e728 100644 --- a/ShowPT/Assets/Scripts/AIWazI.cs +++ b/ShowPT/Assets/Scripts/AIWazI.cs @@ -60,10 +60,13 @@ public enum state state NPCstate; private Animator animWaz; + Waz wazScript; + // Use this for initialization void Start () { navMeshAgent = this.GetComponent (); animWaz = this.GetComponent (); + wazScript = this.GetComponent (); if (navMeshAgent == null) { @@ -117,6 +120,7 @@ void Update () break; case state.I_SEE_YOU: + animWaz.SetBool ("walking", true); LookAtSomething (aggressiveDestination); spotLight.color = Color.red; navMeshAgent.SetDestination (aggressiveDestination); @@ -126,7 +130,7 @@ void Update () { navMeshAgent.SetDestination (gameObject.transform.position); navMeshAgent.isStopped = true; - if (myTurrets != null) + if (myTurrets != null && !wazScript.imAlreadyDead) { myTurrets.active = true; } @@ -144,9 +148,10 @@ void Update () break; case state.SHOOTING: + animWaz.SetBool ("walking", false); navMeshAgent.SetDestination (aggressiveDestination); LookAtSomething (aggressiveDestination); - if (!CanSeePlayer () || navMeshAgent.remainingDistance > shootingDistance) + if (!CanSeePlayer () || navMeshAgent.remainingDistance > shootingDistance || wazScript.imAlreadyDead) { navMeshAgent.isStopped = false; if (myTurrets != null) @@ -158,6 +163,7 @@ void Update () break; case state.I_HEAR_YOU: + animWaz.SetBool ("walking", true); spotLight.color = Color.yellow; if (navMeshAgent.remainingDistance <= 1.0f && !CanSeePlayer()) { @@ -168,6 +174,7 @@ void Update () break; case state.ALERT: + animWaz.SetBool ("walking", false); spotLight.color = Color.yellow; Vector3 rotation = new Vector3 (0f, alertRotation, 0f); gameObject.transform.Rotate (rotation * Time.deltaTime); diff --git a/ShowPT/Assets/Scripts/Waz.cs b/ShowPT/Assets/Scripts/Waz.cs index ab9e9197..562204f0 100644 --- a/ShowPT/Assets/Scripts/Waz.cs +++ b/ShowPT/Assets/Scripts/Waz.cs @@ -4,9 +4,13 @@ public class Waz : Enemy { + Animator wazAnimator; + public bool imAlreadyDead = false; + // Use this for initialization void Start() { + wazAnimator = gameObject.GetComponent (); ctrAudio = GameObject.FindGameObjectWithTag("CtrlAudio").GetComponent(); hitAudio = ctrAudio.hit; } @@ -15,6 +19,12 @@ void Start() void Update() { shoot(); + + if(imAlreadyDead && wazAnimator.GetCurrentAnimatorStateInfo (0).normalizedTime > 1) + { + Destroy (gameObject); + ScoreController.addDead (ScoreController.Enemy.WAZ); + } } public override void getHit(int damage) @@ -30,8 +40,10 @@ public override void checkHealth() { if (enemyHealth <= 0f) { - Destroy(gameObject); - ScoreController.addDead(ScoreController.Enemy.WAZ); + if (!imAlreadyDead) { + wazAnimator.SetTrigger ("dying"); + imAlreadyDead = true; + } } } }