示例#1
0
    private void FeedbackOnAction(float feedback, ActionBase action)
    {
        Tuple <float, ActionBase> chosenAction = null;

        foreach (Tuple <float, ActionBase> tuple in _movesetScore)
        {
            if (tuple.Item2 == action)
            {
                chosenAction = tuple;
                break;
            }
        }

        if (chosenAction != null)
        {
            _movesetScore.Remove(chosenAction);

            float score = chosenAction.Item1 + feedback * _weight * _precision;

            if (!action.CheckCost(this._char))
            {
                score = 0;
            }

            if (score < 0)
            {
                score = 0;
            }
            else if (score > 2 * _precision)
            {
                score = _precision * 2;
            }
            _movesetScore.Add(new Tuple <float, ActionBase>(score, action));
        }
    }
    private void SetHeroAction()
    {
        HeroMenuAction menuAction = GetHeroMenuAction();

        menuAction.targetIndex    = this._commandSelector.GetChoice();
        menuAction.onBackCallback = this.OnActionChooseBackCallback;

        HeroActionChoice choice = menuAction.currentHeroChoices[menuAction.targetIndex];

        if (choice.choiceName == "Magic" && choice.action == null)
        {
            this._heroMenuActions.Push(new HeroMenuAction(MenuState.MAGIC));
            InitializeCommandCardActionUI(GetHeroActionChoices(ActionType.MAGIC));
        }
        else
        {
            ActionBase heroAction = choice.action;

            if (!heroAction.CheckCost(this._field.GetHeroPlayer()))
            {
                return;
            }

            this._ui.commandCardUI.SetConfirmed();

            if (heroAction.targetInfo.targetTeam != TargetTeam.NONE && heroAction.targetInfo.targetType != TargetType.RANDOM)
            {
                List <FightingEntity> possibleTargets = heroAction.GetAllPossibleActiveTargets(_field.GetHeroPlayer());
                switch (heroAction.targetInfo.targetType)
                {
                case TargetType.SINGLE:
                    this._ui.targetSelectionUI.InitializeTargetSelectionSingle(possibleTargets, 0, this._commandSelector);
                    break;

                case TargetType.ALL:
                    this._commandSelector.Initialize(0, 1, null);     // Only one choice
                    this._ui.targetSelectionUI.InitializeTargetSelectionAll(possibleTargets);
                    break;

                default:
                    Debug.LogError("ERROR: Did not consider target type");
                    break;
                }

                this._heroMenuActions.Push(new HeroMenuAction(MenuState.TARGET));
            }
            else if (heroAction.targetInfo.targetTeam == TargetTeam.NONE)
            {
                HeroActionConfirmed();
                GetHeroMenuAction().onBackCallback = this.OnActionChooseBackCallback;
                this._field.GetHeroPlayer().SetQueuedAction(heroAction, new List <int>());
                CheckExecuteTurn();
                this._field.GetHeroPlayer().PlaySound("confirm"); //TODO: Look towards consolidating use here
                this._heroMenuActions.Push(new HeroMenuAction(MenuState.WAITING));
            }
            else if (heroAction.targetInfo.targetType == TargetType.RANDOM)
            {
                HeroActionConfirmed();
                GetHeroMenuAction().onBackCallback = this.OnActionChooseBackCallback;
                this._field.GetHeroPlayer().SetQueuedAction(heroAction, new List <int> {
                    this._field.GetRandomEnemyObjectIndex()
                });
                CheckExecuteTurn();
                this._field.GetHeroPlayer().PlaySound("confirm"); //TODO: Look towards consolidating use here
                this._heroMenuActions.Push(new HeroMenuAction(MenuState.WAITING));
            }
            else
            {
                Debug.LogError("ERROR: Unexpected target type");
            }
        }
    }
示例#3
0
 public bool CanQueueAction(ActionBase action)
 {
     return(action != null && _action.CheckCost(this.user) && (GetTargets().Count > 0 || _action.targetInfo.targetType == TargetType.NONE));
 }