コード例 #1
0
        public List <TriggeredOrder> ExecuteOrder(EncounterState state)
        {
            var unit = state.GetUnit(this.UnitId);

            if (this.OrderType == OrderType.ADVANCE)
            {
                unit.StandingOrder = UnitOrder.ADVANCE;
                return(null);
            }
            else if (this.OrderType == OrderType.OPEN_MANIPULE)
            {
                var firstUnit = state.GetEntityById(unit.EntityIdInForPositionZero);

                unit.UnitFormation = FormationType.MANIPULE_OPENED;
                unit.StandingOrder = UnitOrder.REFORM;
                // TODO: dumb hack to make blocks line up
                var firstUnitPos = firstUnit.GetComponent <PositionComponent>().EncounterPosition;
                if (unit.UnitFacing == FormationFacing.SOUTH)
                {
                    unit.RallyPoint = new EncounterPosition(firstUnitPos.X + 1, firstUnitPos.Y);
                }
                else if (unit.UnitFacing == FormationFacing.WEST)
                {
                    unit.RallyPoint = new EncounterPosition(firstUnitPos.X, firstUnitPos.Y + 1);
                }
                else
                {
                    unit.RallyPoint = firstUnitPos;
                }
                return(null);
            }
            else if (this.OrderType == OrderType.ROUT)
            {
                unit.StandingOrder = UnitOrder.ROUT;
                return(null);
            }
            else if (this.OrderType == OrderType.DECLARE_VICTORY)
            {
                state.NotifyArmyVictory();
                return(null);
            }
            else if (this.OrderType == OrderType.DECLARE_DEFEAT)
            {
                state.NotifyArmyDefeat();
                return(null);
            }
            else if (this.OrderType == OrderType.PRINT)
            {
                GD.Print("!!!!!!! PRINT ORDER EXECUTED !!!!!!!!!");
                return(null);
            }
            else if (this.OrderType == OrderType.PREPARE_SWEEP_NEXT_LANE)
            {
                return(OrderFns.ExecutePREPARE_SWEEP_NEXT_LANE(state, unit));
            }
            else if (this.OrderType == OrderType.ROTATE_AND_REFORM_AT)
            {
                if (this.NewPosition == null)
                {
                    unit.RallyPoint = unit.AveragePosition;
                }
                else
                {
                    unit.RallyPoint = this.NewPosition.Value;
                }
                unit.UnitFacing    = this.NewFacing;
                unit.StandingOrder = UnitOrder.REFORM;
                return(null);
            }
            else
            {
                throw new NotImplementedException("lol: " + this.OrderType);
            }
        }