private void loadQuestion(int delayTime) { System.Threading.Thread.Sleep(delayTime); foreach (Guid key in _clientCallbacks.Keys) { _currentCall = _clientCallbacks[key]; _currentCall.OnQuestionLoad(_questionIndex, (Question_Key)_questions[_questionIndex]); } _currentQTimeRemains = _qTime; _qTimer.Enabled = true; }
private void qTimer_Tick(object sender, EventArgs e) { _currentQTimeRemains -= QUESTION_TIMER_INTERVAL; if (_currentQTimeRemains > 0) { if ((_currentQTimeRemains % QUESTION_TIMER_NOTIFY_INTERVAL) == 0) { foreach (Guid key in _clientCallbacks.Keys) { _currentCall = _clientCallbacks[key]; _currentCall.OnQuestionUpdate(_currentQTimeRemains); } } } else { _qTimer.Enabled = false; questionComplete(); } }
public void RegisterUser(string userName) { _currentCall = OperationContext.Current.GetCallbackChannel<iCallback>(); if (!_callback.ContainsKey(userName)) { _callback.Add(userName, _currentCall); _scoreboard.Add(userName, 0); _currentCall.OnUserRegister(userName); try { userList.Add(userName); UserList(); } catch(Exception ex) { throw ex; } Console.WriteLine("User " + userName + " has joined the game!"); } else { throw new Exception(USER_EXISTS); } }
public void questionComplete() { foreach (Guid key in _clientCallbacks.Keys) { _currentCall = _clientCallbacks[key]; _currentCall.OnQuestionEnd(); } checkAnswers(); _questionIndex += 1; if (_questionIndex < _questions.Count) { loadQuestion(2000); } else { GameEnd(); } }
public void GameStart() { loadFile(); _qTimer = new Timer(); _qTimer.Tick += new EventHandler(qTimer_Tick); _qTimer.Interval = QUESTION_TIMER_INTERVAL; foreach (Guid user in _clientCallbacks.Keys) { _currentCall = _clientCallbacks[user]; _currentCall.OnScoreUpdate(_scoreboard); _currentCall.OnGameStart(_questions.Count); } loadQuestion(); }
public void GameEnd() { System.Threading.Thread.Sleep(1500); foreach (Guid key in _clientCallbacks.Keys) { _currentCall = _clientCallbacks[key]; _currentCall.OnGameEnd(); } _qTimer.Dispose(); _questions.Clear(); _answers.Clear(); _scoreboard.Clear(); _clientCallbacks.Clear(); }
public void checkAnswers() { Question_Key qKey = (Question_Key)_questions[_questionIndex]; foreach (string userNameKey in _answers.Keys) { answerKey ans_key = (answerKey)_answers[userNameKey]; if (qKey.Correct == ans_key.a_Key) { _scoreboard[userNameKey] += 1; } } foreach (Guid key in _clientCallbacks.Keys) { _currentCall = _clientCallbacks[key]; _currentCall.OnScoreUpdate(_scoreboard); } }