コード例 #1
0
ファイル: Client.cs プロジェクト: albinmartin/monostrategy
        private void HandleInGameCommands(String[] message, String plainText)
        {
            //In game
            GameCommandTypes messageType = GameCommandTypes.Chat;
            int clientID = -1;
            int lockstep = -1;

            String[] data = { "-1" };

            try
            {
                messageType = (GameCommandTypes)Convert.ToInt32(message[1]);
                clientID    = Convert.ToInt32(message[2]);
                lockstep    = Convert.ToInt32(message[3]);
                data        = message[4].Split(' ');
            }
            catch
            {
                Console.WriteLine("CLIENT: Network error 3");
            }
            finally
            {
                switch (messageType)
                {
                case GameCommandTypes.Chat:
                    Console.WriteLine(message[4]);
                    break;

                case GameCommandTypes.SpawnAgent:
                    commandManager.AddCommand(new SpawnAgentCommand(lockstep, int.Parse(data[0]), int.Parse(data[1]), int.Parse(data[2]), int.Parse(data[3])));
                    world.AgentCount++;
                    break;
                }
            }
        }
コード例 #2
0
 public GameCommand(GameCommandTypes type, Type subPhase, string rawParameters)
 {
     Type          = type;
     SubPhase      = subPhase;
     RawParameters = rawParameters;
     Parameters    = new JSONObject(rawParameters);
 }
コード例 #3
0
    public static GameCommand GenerateGameCommand(string textjson, bool isRpc = false)
    {
        JSONObject       json        = new JSONObject(textjson);
        GameCommandTypes commandType = (GameCommandTypes)Enum.Parse(typeof(GameCommandTypes), json["command"].str);
        Type             subPhase    = System.Type.GetType(json["subphase"].str);
        string           parameters  = json["parameters"].ToString();

        return(GenerateGameCommand(commandType, subPhase, parameters, isRpc));
    }
コード例 #4
0
ファイル: Server.cs プロジェクト: albinmartin/monostrategy
        private void HandleInGameRequests(String[] message, String plainText)
        {
            //In game
            GameCommandTypes messageType = GameCommandTypes.Chat;
            int clientID = -1;
            int lockstep = -1;

            String[] data = { "-1" };

            try
            {
                messageType = (GameCommandTypes)Convert.ToInt32(message[1]);
                clientID    = Convert.ToInt32(message[2]);
                lockstep    = Convert.ToInt32(message[3]);
                data        = message[4].Split(' ');
            }
            catch
            {
            }
            finally
            {
                switch (messageType)
                {
                case GameCommandTypes.Chat:
                    Console.WriteLine(message[4]);
                    ForwardMessage(plainText);
                    break;

                case GameCommandTypes.SpawnAgent:
                    commandManager.AddCommand(new SpawnAgentCommand(lockstep, int.Parse(data[0]), int.Parse(data[1]), int.Parse(data[2]), world.AgentCount));
                    plainText += " " + (world.AgentCount).ToString();
                    world.AgentCount++;
                    ForwardMessage(plainText);
                    break;
                }
            }
        }
コード例 #5
0
 public DamageDeckSyncCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #6
0
 public ConfirmCritCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #7
0
 public HotacFreeTargetLockCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #8
0
ファイル: Request.cs プロジェクト: albinmartin/monostrategy
 protected Request(GameCommandTypes commandType, int lockstep)
 {
     this.lockstep    = lockstep;
     this.clientID    = GameEngine.GetInstance().Client.ClientID;
     this.commandType = (int)commandType;
 }
コード例 #9
0
 public SquadsSyncCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #10
0
 public ShipPlacementCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #11
0
 public ActIvateAndMoveCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #12
0
 public CancelShipSelectionCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #13
0
 public SyncDiceResultsCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #14
0
 public SelectShipCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #15
0
 public DecisionCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #16
0
    public static GameCommand GenerateGameCommand(GameCommandTypes commandType, Type subPhase, string parameters = null, bool isRpc = false)
    {
        GameCommand command = null;

        switch (commandType)
        {
        case GameCommandTypes.DamageDecksSync:
            command = new DamageDeckSyncCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SquadsSync:
            command = new SquadsSyncCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.Decision:
            command = new DecisionCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ObstaclePlacement:
            command = new ObstaclePlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ShipPlacement:
            command = new ShipPlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.AssignManeuver:
            command = new AssignManeuverCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.PressNext:
            command = new PressNextCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ActivateAndMove:
            command = new ActIvateAndMoveCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.DeclareAttack:
            command = new DeclareAttackCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.DiceModification:
            command = new DiceModificationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectShip:
            command = new SelectShipCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncDiceResults:
            command = new SyncDiceResultsCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncDiceRerollSelected:
            command = new SyncDiceRerollSelectedCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ConfirmCrit:
            command = new ConfirmCritCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ConfirmDiceCheck:
            command = new ConfirmDiceCheckCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.PressSkip:
            command = new PressSkipCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.HotacSwerve:
            command = new HotacSwerveCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.HotacFreeTargetLock:
            command = new HotacFreeTargetLockCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncPlayerWithInitiative:
            command = new SyncPlayerWithInitiativeCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SystemActivation:
            command = new SystemActivationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.CombatActivation:
            command = new CombatActivationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectObstacle:
            command = new SelectObstacleCommand(commandType, subPhase, parameters);
            break;

        default:
            Console.Write("Constructor for GameCommand is not found", LogTypes.Errors, true, "red");
            break;
        }

        string receivedString = (isRpc) ? " (rpc)": "";

        Console.Write("Command is generated" + receivedString + ": " + command.Type, LogTypes.GameCommands, false, "aqua");

        return(command);
    }
コード例 #17
0
 public static void SendCommand(GameCommandTypes commandType, Type subPhase, string parameters = null)
 {
     SendCommand(GenerateGameCommand(commandType, subPhase, parameters));
 }
コード例 #18
0
 public PressNextCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #19
0
 public DiceModificationCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #20
0
 public SyncPlayerWithInitiativeCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #21
0
 public HotacSwerveCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #22
0
 public MoveObstacleCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #23
0
 public CombatActivationCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #24
0
 public SelectShipToAssignManeuverCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #25
0
 public SyncDiceRerollSelectedCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #26
0
 public DeclareAttackCommand(GameCommandTypes type, Type subPhase, string rawParameters) : base(type, subPhase, rawParameters)
 {
 }
コード例 #27
0
    public static GameCommand GenerateGameCommand(GameCommandTypes commandType, Type subPhase, string parameters = null, bool isRpc = false)
    {
        GameCommand command = null;

        switch (commandType)
        {
        case GameCommandTypes.DamageDecksSync:
            command = new DamageDeckSyncCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SquadsSync:
            command = new SquadsSyncCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.Decision:
            command = new DecisionCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ObstaclePlacement:
            command = new ObstaclePlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ShipPlacement:
            command = new ShipPlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.AssignManeuver:
            command = new AssignManeuverCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.PressNext:
            command = new PressNextCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ActivateAndMove:
            command = new ActivateAndMoveCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectShipToAssignManeuver:
            command = new SelectShipToAssignManeuverCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.DeclareAttack:
            command = new DeclareAttackCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.DiceModification:
            command = new DiceModificationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectShip:
            command = new SelectShipCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncDiceResults:
            command = new SyncDiceResultsCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncDiceRerollSelected:
            command = new SyncDiceRerollSelectedCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ConfirmCrit:
            command = new ConfirmCritCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ConfirmDiceCheck:
            command = new ConfirmDiceCheckCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.PressSkip:
            command = new PressSkipCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncPlayerWithInitiative:
            command = new SyncPlayerWithInitiativeCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SystemActivation:
            command = new SystemActivationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.CombatActivation:
            command = new CombatActivationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectObstacle:
            command = new SelectObstacleCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.BombPlacement:
            command = new BombPlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.MoveObstacle:
            command = new MoveObstacleCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.CancelShipSelection:
            command = new CancelShipSelectionCommand(commandType, subPhase, parameters);
            break;

        default:
            break;
        }

        return(command);
    }