Пример #1
0
 private StateContainer(NetServer peer,
                        GameState game, PlayerLookup players, IGameView view,
                        PlayerConnectionLookup connections)
     : base(peer, game, players, view)
 {
     this.connections = connections;
 }
Пример #2
0
 public ServerContinuousSynchronizer(GameState game, NetServer server, PlayerConnectionLookup connections)
     : base(game)
 {
     this.server                 = server;
     this.connections            = connections;
     this.timeToNextObjectUpdate = TimeSpan.One;
     this.timeToNextEcoUpdate    = TimeSpan.One;
 }
 public ServerContinuousSynchronizer(GameState game, NetServer server, PlayerConnectionLookup connections)
     : base(game)
 {
     this.server = server;
     this.connections = connections;
     this.timeToNextObjectUpdate = TimeSpan.One;
     this.timeToNextEcoUpdate = TimeSpan.One;
 }
Пример #4
0
 protected UnifiedRequestCommand(RequestType requestType, CommandType commandType,
     PlayerConnectionLookup connectionLookup, NetConnection connection, GameState game)
 {
     this.requestType = requestType;
     this.commandType = commandType;
     this.game = game;
     this.requester = game.Players[connectionLookup[connection]];
 }
Пример #5
0
            public RequestImplementation(PlayerConnectionLookup connectionLookup, NetConnection connection,
                                         NetBuffer buffer, GameState game)
                : base(RequestType.ShootDebugParticleFromPlanet, game, connectionLookup, connection)
            {
                var p = buffer.Read <RequestParameters>();

                this.body      = game.Bodies[p.BodyId];
                this.direction = p.Direction;
            }
Пример #6
0
        public BuildGameHandler(NetServer server, PlayerLookup players, PlayerConnectionLookup connections, Id <Player> ownID)
            : base(server, players, ownID, new ServerBehaviourProvider(server, connections))
        {
            this.stateBuilder = new StateContainer.Builder
            {
                Server      = server,
                Players     = players,
                Connections = connections,
            };
            var generator = new SimpleGenerator();

            var instructions = generator.Generate(players.Select(p => p.ID).ToList());

            // instructions may want to be spaced out in time in the future,
            // to prevent packet loss, and thus longer building time
            foreach (var instruction in instructions)
            {
                // build own game
                this.executeInstruction(instruction);

                if (connections.Count > 0)
                {
                    // instruct clients how to build game
                    var message = server.CreateMessage();
                    instruction.WriteMessage(message);
                    server.SendMessage(message, connections, NetDeliveryMethod.ReliableOrdered, 0);
                }
            }

            // send finish message and finish
            this.finish(this.stateBuilder);

            if (connections.Count > 0)
            {
                var finishMessage = server.CreateMessage();
                finishMessage.Write((byte)GenerationMessageType.FinishGenerating);
                server.SendMessage(finishMessage, connections, NetDeliveryMethod.ReliableOrdered, 0);
            }
        }
 public ServerCommandSender(NetServer server, PlayerConnectionLookup connections)
 {
     this.server = server;
     this.connections = connections;
 }
Пример #8
0
 protected BaseRequest(RequestType type, GameState game, PlayerConnectionLookup connectionLookup, NetConnection connection)
 {
     this.type      = type;
     this.game      = game;
     this.requester = game.Players[connectionLookup[connection]];
 }
Пример #9
0
 public Implementation(PlayerConnectionLookup connectionLookup, NetConnection connection, NetBuffer buffer, GameState game)
     : base(RequestType.EconomyValueInvestmentChanged, CommandType.EconomyValueInvestmentChanged, connectionLookup, connection, game)
 {
     this.p = buffer.Read <Parameters>();
 }
Пример #10
0
 public static IRequest Request(GameState game, PlayerConnectionLookup connectionLookup, NetConnection connection,
                                NetBuffer buffer)
 {
     return(new Implementation(connectionLookup, connection, buffer, game));
 }
Пример #11
0
 public ServerBehaviourProvider(NetServer server, PlayerConnectionLookup connections)
 {
     this.server        = server;
     this.connections   = connections;
     this.commandSender = new ServerCommandSender(server, connections);
 }
Пример #12
0
 public RequestReader(GameState game, PlayerConnectionLookup connections)
 {
     this.game        = game;
     this.connections = connections;
 }
 public ServerBehaviourProvider(NetServer server, PlayerConnectionLookup connections)
 {
     this.server = server;
     this.connections = connections;
     this.commandSender = new ServerCommandSender(server, connections);
 }
Пример #14
0
 public ServerCommandSender(NetServer server, PlayerConnectionLookup connections)
 {
     this.server      = server;
     this.connections = connections;
 }
Пример #15
0
 public RequestReader(GameState game, PlayerConnectionLookup connections)
 {
     this.game = game;
     this.connections = connections;
 }