예제 #1
0
 internal bool checkValidDockCommand(MessageShipCommand msg)
 {
     if (msg.Command.CommandType == ShipCommandEnum.Dock && _model.DockedPlanet == null && _model.ShipState != ShipStateEnum.Docked)
     {
         return true;
     }
     return false;
 }
예제 #2
0
 internal bool checkValidSetDestinationCommand(MessageShipCommand msg)
 {
     if (msg.Command.CommandType == ShipCommandEnum.SetDestination)
     {
         return true;
     }
     return false;
 }
예제 #3
0
        internal bool ReceiveCommandForShip(MessageShipCommand msg)
        {
            bool success = false;
            ShipController sc = _shipCs[msg.ShipId];
            // check the ship *could* execute this command

            if (msg.Command.CommandType == ShipCommandEnum.Undock)
            {
                success = ShipUndock(msg, sc);
            }
            else if (msg.Command.CommandType == ShipCommandEnum.SetDestination)
            {
                success = ShipSetDestination(msg, sc);
            }
            else if (msg.Command.CommandType == ShipCommandEnum.Dock)
            {
                success = ShipDock(msg, sc);
            }

            return success;
        }
예제 #4
0
 private void receiveCommandForShip(MessageShipCommand msg)
 {
     bool success = _solarSystemC.ReceiveCommandForShip(msg);
     MessageShipResponse msr = new MessageShipResponse(success, msg, _curTick);
     Sender.Tell(msr);
 }
예제 #5
0
 private object pilotingShip(MessageTick tick)
 {
     if (isPilotingShip())
     {
         if (_model.CurrentShipDestinationScId != _memory.CurrentDestinationScId)
         {
             IMessageShipCommandData msd = new MessageShipSetDestination(ShipCommandEnum.SetDestination, _memory.CurrentDestinationScId);
             MessageShipCommand msc = new MessageShipCommand(msd, tick.Tick, _model.CurrentShipId);
             ScPlanet curDest = StarChart.GetPlanet(_memory.CurrentDestinationScId);
             //_actorTextOutput.Tell("Agent Piloting Ship towards " + curDest.Name);
             return msc;
         }
     }
     return null;
 }
예제 #6
0
 public MessageShipResponse(bool response, MessageShipCommand sentCommand, Int64 tickSent)
 {
     Response    = response;
     SentCommand = sentCommand;
     TickSent    = tickSent;
 }
예제 #7
0
 private bool ShipUndock(MessageShipCommand msg, ShipController sc)
 {
     bool success = false;
     if (sc.checkValidUndockCommand(msg))
     {
         _planetCs[sc.DockedPlanet.PlanetId].UndockShip(msg.ShipId);
         sc.Undock();
         success = true;
     }
     return success;
 }
예제 #8
0
 private bool ShipDock(MessageShipCommand msg, ShipController sc)
 {
     bool success = false;
     if (sc.checkValidDockCommand(msg))
     {
         Ship s = _model.Ships.Where(x => x.ShipId == msg.ShipId).First();
         _planetCs[sc.GetDestination.PlanetId].DockShip(s);
         sc.Dock();
         success = true;
     }
     return success;
 }
예제 #9
0
 private static bool ShipSetDestination(MessageShipCommand msg, ShipController sc)
 {
     bool success = false;
     if (sc.checkValidSetDestinationCommand(msg))
     {
         MessageShipSetDestination msd = (MessageShipSetDestination)msg.Command;
         sc.SetDestination(msd.DestinationScId);
         success = true;
     }
     return success;
 }
예제 #10
0
 public MessageShipResponse(bool response, MessageShipCommand sentCommand, Int64 tickSent)
 {
     Response = response;
     SentCommand = sentCommand;
     TickSent = tickSent;
 }