Пример #1
0
    public UpdateResult Update(out BattleAction decision)
    {
        UpdateResult result = Update();

        if (result == UpdateResult.Completed)
        {
            BattleMenu menu = Next;
            while (menu != null)
            {
                menu.Destruct();
                menu = menu.Next;
            }

            if (m_Next.Count == m_Command.Selections.Count)
            {
                // Destroy this menu
                Destruct();

                // Construct final decision using m_Command.Actions
                decision = m_Command.Construct(m_Agent, m_Selections);

                if (m_Command.Expends != BattleCommand.Type.None)
                {
                    string turn = "Turn:" + m_Command.Expends;
                    --m_Agent[turn];
                }

                return(result);
            }
            else
            {
                m_Next.Push(m_Command.Selections[m_Next.Count].Construct(m_Agent, m_Selections));
                Next.Construct();

                if (!(Next is BattleListMenu))
                {
                    Destruct();
                }
            }
        }

        decision = null;
        return(result);
    }
    public override BattleAction Update()
    {
        Dictionary <string, object> selections;
        BattleCommand command = m_Agent.Behaviour.Decide(m_Manager, m_Agent, out selections);

        if (command != null)
        {
            int t = int.MinValue;

            foreach (BattleCommandSelection selection in command.Selections)
            {
                BattleCommandTargetSelection targetSelection = selection as BattleCommandTargetSelection;

                if (targetSelection != null)
                {
                    string rangeType, targetType;
                    targetSelection.GetRangeAndTarget(m_Agent, selections, out rangeType, out targetType);
                    BattleManhattanDistanceZone range  = Skill.GetRange(rangeType, m_Agent);
                    BattleManhattanDistanceZone target = selections[targetSelection.id] as BattleManhattanDistanceZone;

                    m_Manager.Add(new BattleTargetSelect(new BattleQueueTime(t, ++t), range));
                    m_Manager.Add(new BattleTargetConfirm(new BattleQueueTime(t, ++t), range, target));
                }
            }

            // TODO

            if (command.Expends != BattleCommand.Type.None)
            {
                --m_Agent["Turn:" + command.Expends];
            }
            return(command.Construct(m_Agent, selections));
        }

        return(new BattleEndTurnAction(m_Agent));
    }