예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        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 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();
            }
        }
예제 #4
0
        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();
                }
            }
        }
예제 #5
0
        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();
            }
        }