Example #1
0
    public EnemyDecision GetDecision()
    {
        UnitTracker ut = GetComponent <UnitTracker>();

        switch (behaviour)
        {
        case EnemyBehaviour.IDLE:
            //In this state, enemies will simply stand still, and will not attack (will still counterattack)
            return(new EnemyDecision());

        case EnemyBehaviour.HOLD:
            //In this state, enemies will stay in place, and will not move. They will attack anything in their immediate range,
            //but will not move to attack a unit
            return(FindBestAttackAt(ut.GetLocation()));

        case EnemyBehaviour.WAIT:
            //In this state, enemies will stay in place, but will move to attack any enemies they can move to and attack
            return(FindBestMoveAttack(ut.PossibleMovement()));

        case EnemyBehaviour.SEEK:
            //In this state, enemies will stay in place, but will move to attack any enemies they can move to and attack
            //If there are no enemies to attack, enemies will move towards their goal
            EnemyDecision bestCombat = FindBestMoveAttack(ut.PossibleMovement());
            if (bestCombat.pass)
            {
                return(FindBestMove(new Vector3Int(0, 0, 0)));
            }
            else
            {
                return(bestCombat);
            }
        }

        print("???");
        return(new EnemyDecision());
    }