Пример #1
0
        private static List<CommandState> GetCommandStateList(IList<IBattleCommand> commandList)
        {
            const int O = 0; // 使用可能
            const int X = 1; // 使用不可能
            const int N = 2; // 非表示
            var commandEnableTable = new[,] {
                // 移動, 攻撃, 魔法, 特技, 待機
                { O, O, O, O, O }, // 初期
                { X, O, X, O, O }, // 移動済み
                { X, X, X, X, O }, // 行動済み
            };

            var stateTransion = new[,] {
                // 移動, 攻撃, 魔法, 特技, 待機
                { 1, 2, 2, 2, 2 }, // 初期
                { 2, 2, 2, 2, 2 }, // 移動済み
                { 2, 2, 2, 2, 2 }, // 行動済み	HACK: 本当は不要?
            };

            var states = new List<CommandState>();
            foreach (var commandEnable in commandEnableTable.GetRows())
            {
                var cmds = new List<CommandInfo>();
                commandEnable.ForEach((enable, i) => {
                    if (enable != N)
                        cmds.Add(new CommandInfo(commandList[i], enable == O));
                });

                var state = new CommandState();
                state.CommandInfos = cmds;
                states.Add(state);
            }

            stateTransion.GetRows().ForEach((trans, i) => {
                var transTable = new Dictionary<IBattleCommand, CommandState>();
                commandEnableTable.GetRow(i)
                    .Zip(trans)
                    .ForEach((t, j) => {
                        // 使用可能ならば状態遷移を生成
                        if (t.Item1 == O)
                            transTable.Add(commandList[j], states[t.Item2]);
                    });
                states[i].Transition = transTable;
            });

            return states;
        }
Пример #2
0
 public Action SaveCommandState()
 {
     var backup = _commandState;
     return () => _commandState = backup;
 }
Пример #3
0
 public void ChangeCommandState(IBattleCommand cmd)
 {
     _commandState = _commandState.Transition[cmd];
 }
Пример #4
0
 public void ResetCommandState()
 {
     _commandState = _initCommandState;
 }
Пример #5
0
 public WarUnit(Unit unit, WarSide warSide, CommandState initState, Area area)
 {
     _unit = unit;
     // ステータスの生成
     CreateStatus();
     // コマンド状態の初期化
     _initCommandState = _commandState = initState;
     _visible = true;
     _unit = unit;
     unit.Acted = true;
     _magicLevels = new ListIndexer<AttackType, byte>(unit.MagicLevel, i => (int)i - (int)AttackType.火);
     _side = warSide;
     _conditions = new ConditionSet(this);
     _area = area;
 }