Пример #1
0
 // if there is a planned ability to activate, execute that ability
 public override void ChooseAbility()
 {
     if (plannedActionData != null)
     {
         AvailableAbilities[plannedActionData.GetAbilityIndex()].Execute(this, plannedActionData.GetAbilityDirection());
     }
     ChangeDirection(Direction.S);
     hasActed = true;
 }
Пример #2
0
    // this function is called when the EnemyUnit needs to know what it's going to do
    // it evaluates its possibleActions, selects the best one, and asks it to create ActionData to store
    public void NewActionData()
    {
        if (possibleActions.Count != 0)
        {
            // get data about the board-state, possible options, etc
            if (GetImmobilizedDuration() > 0 || GetDisabledDuration() > 0)
            {
                MoveableTiles = new Dictionary <Vector2Int, Direction>();
                MoveableTiles.Add(GetMapPosition(), Direction.NO_DIR);
            }
            else
            {
                MoveableTiles = FindMoveableTiles(MapController.instance.weightedMap);
            }

            foreach (AbilityOption option in possibleAbilities)
            {
                option.EvaluateAffectableTiles();
            }

            EnemyAction bestAction          = null;
            float       highestSignificance = 0.0f;

            // for each possible action:
            foreach (EnemyAction action in possibleActions)
            {
                // evaluate its significance level
                action.Evaluate();

                // check if it currently has the highest significance
                if (action.GetSignificance() > highestSignificance)
                {
                    bestAction          = action;
                    highestSignificance = action.GetSignificance();
                }
            }

            plannedActionData = bestAction.GetActionData();

            // This useful Debug statement will print to the console the details of what this Unit committed to doing
            Debug.Log(this.GetName() + " at Starting Position " + this.GetMapPosition()
                      + " has committed to moving to " + plannedActionData.GetEndingPosition() + " and using "
                      + this.AvailableAbilities[plannedActionData.GetAbilityIndex()] + " in direction "
                      + plannedActionData.GetAbilityDirection());
        }
    }