示例#1
0
        // START GAME
        public int Run()
        {
            _Game.Lobby();
            _Game.GameLoop();

            return(0);
        }
示例#2
0
        private static void gameCycle()
        {
            for (; ;)
            {
                if (RemoteServer.isFroozen)
                {
                    Console.WriteLine("freezed");
                    RemoteServer.frozen[4].WaitOne();
                }

                if (!RemoteServer.isPrimary)
                {
                    serverSet(RemoteServer.isPrimary);
                }

                Thread sendStates;
                Thread sendUpdates;
                //espera time round
                if (RemoteServer.roundQueue != null)
                {
                    game.GameLoop(RemoteServer.roundQueue);
                }

                int x = RemoteServer.round;
                RemoteServer.round++;

                lock (RemoteServer.roundQueue)
                    RemoteServer.roundQueue.Clear();

                GameState gs = game.GetState(x);
                sendUpdates = new Thread(() => sendUpdatesToServer(gs))
                {
                    Priority = ThreadPriority.Highest
                };
                sendUpdates.Start();
                sendStates = new Thread(() => sendGameStateToClients(game, x, gs))
                {
                    Priority = ThreadPriority.Highest
                };
                sendStates.Start();

                System.Threading.Thread.Sleep(MSEC_PER_ROUND + 10);
            }
        }