예제 #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;
 }