public void SingleStep() { currentNow = serverClock.GetNow(); EndPoint sender = serverTransport.CreateEndPoint(); byte[] data = serverTransport.Recv(256, ref sender); if (data != null) { //process command byte gameCommand = data[0]; Console.WriteLine("command received: {0}", data[0]); if (commandsTable.ContainsKey(gameCommand)) { Console.WriteLine("{0} : {1}", data[0], commandsTable[gameCommand].Method); commandsTable[gameCommand](data, sender); } else { Console.WriteLine("{0} : Command Invalid", data[0], commandsTable[gameCommand].Method); GameClient badClient = new GameClient(sender, this); if (clientsTable.ContainsValue(badClient)) { badClient.UpdateMalus(); } } foreach (ServerRoom room in serverRooms.Values) { room.Update(); } } }
public void SingleStep() { currentNow = serverClock.GetNow(); EndPoint sender = transport.CreateEndPoint(); byte[] data = transport.Recv(256, ref sender); if (data != null) { byte gameCommand = data[0]; if (commandsTab.ContainsKey(gameCommand)) { commandsTab[gameCommand](data, sender); } } foreach (GameClient client in clientsTab.Values) { client.Process(); } foreach (GameObject gameObject in gameObjectsTab.Values) { gameObject.Tick(); } if (checkMalusTimer <= Now) { CheckMalus(); } }
public void SingleStep() { currentNow = clock.GetNow(); EndPoint sender = transport.CreateEndPoint(); byte[] data = transport.Recv(256, ref sender); if (data != null) { byte gameCommand = data[0]; if (commandsTable.ContainsKey(gameCommand)) { commandsTable[gameCommand](data, sender); } } foreach (GameClient client in clientsTable.Values) { client.Process(); } foreach (Room room in Rooms) { room.UpdateRoom(); OnAsteroidCollision(room); } }
public static void Start() { if (transport == null) { throw new Exception("please specify a transport"); } Console.WriteLine("server started"); while (true) { currentClock = Stopwatch.GetTimestamp() / (float)Stopwatch.Frequency; EndPoint sender = transport.CreateEndPoint(); byte[] data = transport.Recv(256, ref sender); if (data != null) { byte gameCommand = data[0]; if (commandsTable.ContainsKey(gameCommand)) { commandsTable[gameCommand](data, sender); } } foreach (GameClient client in clientsTable.Values) { client.Process(); } foreach (GameObject gameObject in gameObjectsTable.Values) { gameObject.Tick(); } } }
public void CommandsManagement() { EndPoint sender = transport.CreateEndPoint(); byte[] data = transport.Receive(256, ref sender); if (data != null) { byte command = data[0]; if (commandsTable.ContainsKey(command)) { commandsTable[command](data, sender); } } }
public void SingleStep() { EndPoint sender = transport.CreateEndPoint(); byte[] data = transport.Recv(256, ref sender); if (data != null) { byte gameCommand = data[0]; if (commandsTable.ContainsKey(gameCommand)) { commandsTable[gameCommand](data, sender); } } foreach (GameClient client in clientsTable.Values) { client.Process(); } }