Пример #1
0
        void OnDeployUnit(ClientToServerMessage message)
        {
            UnitDeployment deployment = message.UnitDeployment;

            if (deployment == null)
            {
                throw new ServerClientException("Invalid unit deployment");
            }
            Unit unit = PlayerState.GetUnit(deployment.Unit.UnitId);

            if (unit == null)
            {
                throw new ServerClientException("Encountered an invalid unit ID in a deployment request");
            }
            PlayerState.DeployUnit(unit, deployment.Unit.Position);
            ServerToClientMessage broadcast = new ServerToClientMessage(deployment);

            BroadcastMessage(broadcast);
        }
Пример #2
0
 public ServerToClientMessage(UnitDeployment deployment)
 {
     Type           = ServerToClientMessageType.UnitDeployed;
     UnitDeployment = deployment;
 }
Пример #3
0
 public ClientToServerMessage(UnitDeployment deployment)
 {
     Type           = ClientToServerMessageType.DeployUnit;
     UnitDeployment = deployment;
 }