Ejemplo n.º 1
0
 public void Update()
 {
     if (mage.stateMachine.currentState == ChaseState.getInstance())
     {
         Chase(mage.enemy);
     }
     else if (mage.stateMachine.currentState == FleeState.getInstance())
     {
         Flee(mage.enemy);
     }
 }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     //transform.LookAt(enemy);
     enemy = FindClosestEnemy();
     if (
         Vector3.Distance(transform.position, enemy.transform.position) >= attackDistance
         )
     {
         Debug.Log("GO TOWARD ENEMY");
         //Approach(enemy);
         if (stateMachine.currentState != AttackState.getInstance())
         {
             stateMachine.ChangeState(ChaseState.getInstance());
         }
     }
     if (
         Vector3.Distance(transform.position, enemy.transform.position) <= attackDistance &&
         Vector3.Distance(transform.position, enemy.transform.position) > runDistance
         )
     {
         Debug.Log("ATTACK ENEMY");
         if (stateMachine.currentState != AttackState.getInstance())
         {
             stateMachine.ChangeState(AttackState.getInstance());
         }
     }
     if (Vector3.Distance(transform.position, enemy.transform.position) <= runDistance)
     {
         Debug.Log("FLEE FROM ENEMY");
         //Flee(enemy);
         if (stateMachine.currentState != FleeState.getInstance())
         {
             stateMachine.ChangeState(FleeState.getInstance());
         }
     }
 }