Example #1
0
    void RunAway()
    {
        if (!HP.Alive)
        {
            currentState = EmeryState.Death;
            Agent.ResetPath();
            return;
        }
        if (distance > 3)
        {
            currentState = EmeryState.MovingToPoint;
            Agent.ResetPath();
            return;
        }

        /*else if (Vector3.Distance(transform.position, focusPoint.position) < 1f)
         * {
         *  currentState = EmeryState.Attack;
         *  Agent.ResetPath();
         *  return;
         * }*/
        if (isAgentDone())
        {
            Agent.ResetPath();
            float TempX = transform.position.x + Random.Range(-2.0f, 2.5f);
            float TempY;
            if (TempX < 6)
            {
                TempX = 6.0f;
            }
            if (TempX > 12)
            {
                Vector3 newPos = new Vector3(Random.Range(12.0f, 23.0f), 0, Random.Range(-9f, -3f));
                Agent.SetDestination(newPos);
                //Debug.Log(newPos);
                animator.SetFloat("Forward", 1.0f);
            }
            else
            {
                if (player.position.z > -6)
                {
                    TempY = -Mathf.Sqrt(9 - Mathf.Pow(TempX - 9, 2)) - 6;
                }
                else
                {
                    TempY = Mathf.Sqrt(9 - Mathf.Pow(TempX - 9, 2)) - 6;
                }
                Vector3 newPos = new Vector3(TempX, 0, TempY);
                Agent.SetDestination(newPos);
                //Debug.Log(newPos);
                animator.SetFloat("Forward", 1.0f);
            }
        }
    }
Example #2
0
 void Attack()
 {
     if (!HP.Alive)
     {
         currentState = EmeryState.Death;
         Agent.ResetPath();
         return;
     }
     if (distance <= 3)
     {
         currentState = EmeryState.Runaway;
         Agent.ResetPath();
         return;
     }
     animator.SetFloat("Forward", 0.0f);
     animator.SetBool("Eat", true);
     if (AttackTimer > AttackInterval)
     {
         playerHealth.GetHurt();
         AttackTimer = 0;
     }
 }
Example #3
0
 void MovingTo()
 {
     if (!HP.Alive)
     {
         currentState = EmeryState.Death;
         Agent.ResetPath();
         return;
     }
     if (distance <= 3)
     {
         currentState = EmeryState.Runaway;
         Agent.ResetPath();
         return;
     }
     else if (Vector3.Distance(transform.position, focusPoint.position) < 1f)
     {
         currentState = EmeryState.Attack;
         Agent.ResetPath();
         return;
     }
     Agent.SetDestination(focusPoint.position);
     animator.SetFloat("Forward", 1.0f);
 }