Esempio n. 1
0
        void OnInitialDeployment(ClientToServerMessage message)
        {
            Map map = Game.Map;
            InitialDeploymentRequest deployment = message.InitialDeploymentSubmission;

            if (deployment == null)
            {
                throw new ServerClientException("Invalid initial deployment");
            }
            // Reset the deployment state/position of all units to enable players to re-submit their initial deployment
            PlayerState.ResetUnitDeploymentState();
            foreach (var unitPosition in deployment.Units)
            {
                Unit unit = PlayerState.GetUnit(unitPosition.UnitId);
                if (unit == null)
                {
                    throw new ServerClientException("Encountered an invalid unit ID in the initial deployment");
                }
                PlayerState.InitialUnitDeployment(unit, unitPosition.Position);
            }
            _RequestedFirstTurn = deployment.RequestedFirstTurn;
            PlayerState.State   = PlayerStateType.HasDeployedUnits;
            if (Opponent.HasDeployed())
            {
                // The opponent has already submitted their deployment
                // Both players are ready, start the game
                Game.StartGame();
            }
        }
Esempio n. 2
0
 public ClientToServerMessage(InitialDeploymentRequest deployment)
 {
     Type = ClientToServerMessageType.InitialDeployment;
     InitialDeploymentSubmission = deployment;
 }