示例#1
0
文件: Game.cs 项目: Postremus/UniTTT
 public void Run()
 {
     do
     {
         if (!_gameMode.HasStoped)
         {
             _gameMode.LogikLoop();
         }
         if (_gameMode is Logik.Game.NetworkGame)
         {
             ((Logik.Game.NetworkGame)_gameMode).OnWinMessageEvent(_gameMode.Player1.Symbol, UniTTT.Logik.FieldHelper.GetGameState(_gameMode.Field, _gameMode.Player));
             if (_gameMode.Player1.Symbol == 'X')
             {
                 if (NewGameQuestion())
                 {
                     _gameMode.OnNewGameEvent();
                 }
             }
             else
             {
                 Console.WriteLine("Warte auf neues Spiel..");
                 while (!_gameMode.HasStarted)
                 {
                 }
                 ;
             }
         }
         else
         {
             if (NewGameQuestion())
             {
                 _gameMode.NewGame();
             }
             else
             {
                 break;
             }
         }
     } while (true);
 }
示例#2
0
        private void Loop()
        {
            Stopwatch st = new Stopwatch();

            st.Start();
            TimeSpan elapsed = TimeSpan.Zero;

            while (true)
            {
                if (elapsed.Seconds != st.Elapsed.Seconds && st.Elapsed.Seconds % _config.PlayVelocity / 2 == 0)
                {
                    game.Logik();
                    if (game.HasEnd())
                    {
                        game.NewGame();
                    }
                }
                else if (st.Elapsed.Milliseconds % 41 == 0)
                {
                    pictureBox1.Invoke(new MethodInvoker(UpdateImageLocation));
                }
                elapsed = st.Elapsed;
            }
        }