Exemplo n.º 1
0
        void Check_Game_Running()
        {
            Thread.CurrentThread.Name = "Memory_Thread_Check_Game_Running";
            bool was_running = true;

            while (true)
            {
                Thread.Sleep(1000);
                Process[] pname = Process.GetProcessesByName(Game_Name);
                if ((pname.Length != 0) != (was_running))
                {
                    was_running = !was_running;

                    if (was_running)
                    {
                        Notification_Message?.Invoke(this, new StringArg("Game was opened"));
                        GameOpened?.Invoke(this, new EventArgs());
                    }
                    else
                    {
                        Notification_Message?.Invoke(this, new StringArg("Game was closed"));
                        GameClosed?.Invoke(this, new EventArgs());
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void StatsSaveGame()
        {
            if (currentGame != null)
            {
                UpdateInfo(); //make sure we save the final score/tickets
                currentGame.UpdateScore(latestInfo);

                Logger.Log(LogLevel.Verbose, "Closing game {0} ({1}). Final score: {2}/{3}",
                           currentGame.DatabaseId.ToString(),
                           latestInfo.CurrentMap,
                           currentGame.Team1Score.ToString(),
                           currentGame.Team2Score.ToString());

                Core.Database.CloseGame(currentGame);
                GameClosed.Invoke(this, new GameClosedEventArgs(currentGame));
            }
        }
 public void GAME_CLOSED() => GameClosed?.Invoke(this, new EventArgs());
Exemplo n.º 4
0
 private void BoggleGame_FormClosing(object sender, FormClosingEventArgs e)
 {
     GameClosed?.Invoke();
 }
 private protected virtual void OnGameProcessExited(object sender, EventArgs e)
 {
     GameClosed?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 6
0
        public void Update(GameTime gameTime)
        {
            if (!GameStartTime.HasValue)
            {
                GameStartTime = gameTime.TotalGameTime;
            }

            if (!IsPaused)
            {
                TimeSpan totalGameTime = gameTime.TotalGameTime - GameStartTime.Value;
                _restGameTime = _allGameTime - totalGameTime;

                if (_allGameTime < (gameTime.TotalGameTime - GameStartTime))
                {
                    _restGameTime = new TimeSpan(0, 0, 0);

                    GameClosed.Invoke(_percent, new System.EventArgs());
                }
                else if (NextStepTime < (gameTime.TotalGameTime - GameStartTime))
                {
                    Random rand   = new Random();
                    long   offset = 0;

                    var offsetBound = General.GetOffsetBound(ScreenManager.BlockInLine);

                    if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_0 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_1)
                    {
                        offset = rand.Next(offsetBound[0].Item1, offsetBound[0].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_1 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_2)
                    {
                        offset = rand.Next(offsetBound[1].Item1, offsetBound[1].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_2 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_3)
                    {
                        offset = rand.Next(offsetBound[2].Item1, offsetBound[2].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_3 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_4)
                    {
                        offset = rand.Next(offsetBound[3].Item1, offsetBound[3].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_4 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_5)
                    {
                        offset = rand.Next(offsetBound[4].Item1, offsetBound[4].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_5 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_6)
                    {
                        offset = rand.Next(offsetBound[5].Item1, offsetBound[5].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_6 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_7)
                    {
                        offset = rand.Next(offsetBound[6].Item1, offsetBound[6].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_7 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_8)
                    {
                        offset = rand.Next(offsetBound[7].Item1, offsetBound[7].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_8 && totalGameTime.TotalSeconds <= General.TimePeriod.PERIOD_9)
                    {
                        offset = rand.Next(offsetBound[8].Item1, offsetBound[8].Item2) * 10000;
                    }
                    else if (totalGameTime.TotalSeconds > General.TimePeriod.PERIOD_9)
                    {
                        offset = rand.Next(offsetBound[9].Item1, offsetBound[9].Item2) * 10000;
                    }

                    UpdateEngine(gameTime, offset);
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Handles the message.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Handle(GameClosed message)
 {
     _listener.Stop();
 }