Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Casa\Adrián Meizoso committed Apr 23, 2018
2 parents 70977cd + dc5d281 commit f99e103
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 9 additions & 2 deletions ShowPT/Assets/Scripts/AIWazI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ public enum state
state NPCstate;
private Animator animWaz;

Waz wazScript;

// Use this for initialization
void Start () {
navMeshAgent = this.GetComponent<NavMeshAgent> ();
animWaz = this.GetComponent<Animator> ();
wazScript = this.GetComponent<Waz> ();

if (navMeshAgent == null)
{
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand All @@ -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)
Expand All @@ -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())
{
Expand All @@ -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);
Expand Down
16 changes: 14 additions & 2 deletions ShowPT/Assets/Scripts/Waz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

public class Waz : Enemy
{
Animator wazAnimator;
public bool imAlreadyDead = false;

// Use this for initialization
void Start()
{
wazAnimator = gameObject.GetComponent<Animator> ();
ctrAudio = GameObject.FindGameObjectWithTag("CtrlAudio").GetComponent<CtrlAudio>();
hitAudio = ctrAudio.hit;
}
Expand All @@ -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)
Expand All @@ -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;
}
}
}
}

0 comments on commit f99e103

Please sign in to comment.