Esempio n. 1
0
        private void Update()
        {
            if (isDead && !CheckForRevive())
            {
                return;
            }
            CheckForDeath();
            switch (currentMode)
            {
            case MovementMode.Attack:
                if (attack.InRange)
                {
                    waypoints.Stop();
                }
                else if (attack.GetTarget() == null)
                {
                    currentMode = MovementMode.Idle;
                }
                else
                {
                    waypoints.GoDirectlyTo(attack.GetTarget().gameObject.transform.position);
                }
                break;

            case MovementMode.Move:
                if (agent.enabled)
                {
                    agent.isStopped = false;
                }
                if (waypoints.IsIdle())
                {
                    currentMode = MovementMode.Idle;
                }
                break;

            case MovementMode.AttackMove:
                if (agent.enabled)
                {
                    agent.isStopped = attack.AttackNearestTarget();
                }
                if (waypoints.IsIdle())
                {
                    currentMode = MovementMode.Idle;
                }
                break;

            case MovementMode.Idle:
                attack.AttackNearestTarget();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }