示例#1
0
        private void StartGameProcessMonitoring()
        {
            var dispatcher = Dispatcher.CurrentDispatcher;

            ThreadPool.QueueUserWorkItem(_ =>
            {
                while (gameProcessMonitoring.Wait(1000) == false)
                {
                    bool localIsRunGameLocked = dispatcher.Invoke(() => IsRunGameLocked);

                    var processes = Process.GetProcessesByName(Constants.ProcessName);

                    if (processes.Length > 0 && IsRunGameLocked == false)
                    {
                        dispatcher.Invoke(() =>
                        {
                            IsRunGameLocked = true;
                            Status          = "Dark Souls 3 is running...";
                            GameStarted?.Invoke(this, EventArgs.Empty);
                        });
                    }
                    else if (processes.Length == 0 && IsRunGameLocked)
                    {
                        dispatcher.Invoke(() =>
                        {
                            IsRunGameLocked = false;
                            Status          = "Dark Souls 3 has stopped...";
                            GameStopped?.Invoke(this, EventArgs.Empty);
                        });
                    }
                }

                gameProcessMonitoring.Reset();
            });
        }
示例#2
0
        public async Task StopGameAsync()
        {
            if (CoreRunner != null)
            {
                await CoreRunner.UnloadGameAsync();
            }

            CleanupAndGoBack();
            GameStopped?.Invoke(this);
        }
示例#3
0
        public async Task Connect()
        {
            _hubConnection = new HubConnectionBuilder().WithUrl(_hubUri).Build();
            _hubConnection.On(GameEvents.GameSessionStarted, () => GameSessionStarted?.Invoke());
            _hubConnection.On <bool>(nameof(IsSessionOpen), (isOpen) => IsSessionOpen?.Invoke(isOpen));
            _hubConnection.On(GameEvents.PlayerCreated, () => PlayerCreated?.Invoke());
            _hubConnection.On <ICollection <string> >(nameof(IncomingPlayers), (players) => IncomingPlayers?.Invoke(players));
            _hubConnection.On(GameEvents.GameStarted, () => GameStarted?.Invoke());
            _hubConnection.On <int>(GameEvents.TimeElapsed, countDownSeconds => TimeElapsed?.Invoke(countDownSeconds));
            _hubConnection.On(GameEvents.GameStopped, () => GameStopped?.Invoke());
            _hubConnection.On <int>(GameEvents.RightAnswer, newScore => SentRightAnswer?.Invoke(newScore));
            _hubConnection.On <int>(GameEvents.WrongAnswer, newScore => SentWrongAnswer?.Invoke(newScore));
            _hubConnection.On(GameEvents.RoundEnded, () => RoundEnded?.Invoke());
            _hubConnection.On <string>(GameEvents.Question, question => QuestionSent?.Invoke(question));
            _hubConnection.On <AnswerAndPlayers>(GameEvents.AnswerAndPlayers, answerAndPlayers => GotAnswerAndPlayers?.Invoke(answerAndPlayers));
            _hubConnection.On(GameEvents.NextRoundStarted, () => NextRoundStarted?.Invoke());

            await _hubConnection.StartAsync();
        }
示例#4
0
 private void OnGameStopped(GameStopped seerEvent) => GameStopped?.Invoke(seerEvent);
示例#5
0
 public void GameStop()
 {
     _generator.Stop();
     GameStopped?.Invoke();
 }