Пример #1
0
    // The CharacterAnimator calls this method, so we will do all of the AI processing within it
    public void UpdateInput(float elapsedTime)
    {
        // By default, have the enemy do nothing
        CharAnimator.CharInput.Horizontal = 0;
        CharAnimator.CharInput.Vertical   = 0;
        CharAnimator.CharInput.Jump       = Vector2.zero;
        CharAnimator.CharInput.Attack     = 0;
        CharAnimator.CharInput.Pickup     = false;

        // Based off the awareness level of the enemy, it'll do 1 of 3 things
        bool awarenessChanged = UpdateAwareness(elapsedTime);

        if (awarenessChanged)
        {
            Awareness.ChangeAwareness();
        }
        switch (Awareness.Level)
        {
        case EnemyAwareness.AwarenessLevel.Unaware:
            if (Settings.ShouldWander)
            {
                Wander(elapsedTime, awarenessChanged);
            }
            break;

        case EnemyAwareness.AwarenessLevel.Searching:
            Search(elapsedTime, awarenessChanged);
            break;

        case EnemyAwareness.AwarenessLevel.Chasing:
            Chase(elapsedTime, awarenessChanged);
            break;
        }
    }