protected void OnGameDataReceived(GameDataEventArgs eventArgs) { var eventHandler = this.GameDataReceived; if (eventHandler == null) return; eventHandler.InvokeAll(this, eventArgs); }
protected void OnGameDataSent(GameDataEventArgs eventArgs) { var eventHandler = this.GameDataSent; if (eventHandler == null) return; this.GameDataSent.InvokeAll(this, eventArgs); }
private void WordPlayNewGameLoaded(object sender, GameDataEventArgs e) { _userInterface.ResetUI(); _userInterface.AddNewPuzzleFractions(_wordPlayGame.WordPlayGame.CurrentTask.Length); ResetUIToDefaultValues(e); }
private void WordPlayPostGame(object sender, GameDataEventArgs e) { _userInterface.ResetUI(); _userInterface.Time.Text = e.ElapsedTime.ToString(); _userInterface.Status.Visible = true; _userInterface.Status.Text = "Game Over\nPoengsum: " + e.Score; _userInterface.Score.Text = e.Score.ToString(); }
public GameConnection(IDiceConnection diceConnection) { this.DiceConnection = diceConnection; diceConnection.PacketReceived += (sender, e) => { var gameData = new GameData() { DataString = e.Packet.ToString()}; var eventArgs = new GameDataEventArgs(gameData); OnGameDataReceived(eventArgs); }; }
/// <summary> /// Ends the game. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> public void EndGame(object sender, GameDataEventArgs eventArgs) { _gameScene.QueueFree(); this.RemoveChild(_gameScene); _gameStartOverlay.ShowOverlay(); _gameStartOverlay.ShowWaitLabel(); //SendGameData(eventArgs.GameData); _gameStartOverlay.ShowGameOverLabel(); }
public async Task SendAsync(IGameCommand command) { var commandString = new DiceCommandString(command.Command); var packetSequenceId = await DiceConnection.GetNextSequenceIdAsync(); var commandStringWords = commandString.ToWords(); var packet = new DicePacket(new DicePacketSequence(packetSequenceId, PacketType.Request, PacketOrigin.Client), commandStringWords); await this.DiceConnection.SendAsync(packet); var eventArgs = new GameDataEventArgs(new GameData() { DataString = packet.ToString() }); this.OnGameDataSent(eventArgs); }
private void WordPlayAnswersCorrect(object sender, GameDataEventArgs e) { ResetUIToDefaultValues(e); _userInterface.Status.Visible = true; _userInterface.Status.Foreground = Color.Green; _userInterface.Status.Text = "Riktig! + " + e.ScoreIncrement + " poeng"; if (e.Combo > 1) { _userInterface.Status.Text += "\n" + e.Combo + " på rad!"; } }
private void WordPlayAnswersIncorrect(object sender, GameDataEventArgs e) { ResetUIToDefaultValues(e); _userInterface.Status.Visible = true; _userInterface.Status.Foreground = Color.Red; _userInterface.Status.Text = "Feil! Prøv igjen"; for (int i = 0; i < _userInterface.PuzzleFractions.Count; i++) { _userInterface.PuzzleFractions[i].Foreground = e.Result[i] ? Color.Green : Color.Red; } }
private void ResetUIToDefaultValues(GameDataEventArgs e) { _userInterface.Time.Text = e.ElapsedTime.ToString(); _userInterface.Task.Text = e.AnswerCounter.ToString(); _userInterface.Score.Text = e.Score.ToString(); _userInterface.Status.Text = string.Empty; _userInterface.Status.Visible = false; _userInterface.Status.Foreground = Color.White; if (!e.IsGameLoaded) { return; } for (int i = 0; i < _userInterface.PuzzleFractions.Count; i++) { _userInterface.PuzzleFractions[i].Text = e.WordFractions[i]; _userInterface.PuzzleFractions[i].Foreground = Color.White; _userInterface.PuzzleFractions[i].X = 25 + i * (int)(NativeSize.X / NumPlayers); _userInterface.PuzzleFractions[i].Y = (int)(-NativeSize.Y / 3); } }
public void CreateInstance_IGameDataInstance_GameDataIGameDataInstance() { var gameDataMock = new Mock<IGameData>().Object; var gameDataEventArgs = new GameDataEventArgs(gameDataMock); Assert.Equal(gameDataMock, gameDataEventArgs.GameData); }
private void WordPlayAnswersChangedPlaces(object sender, GameDataEventArgs e) { ResetUIToDefaultValues(e); }
private void WordPlayGameUpdate(object sender, GameDataEventArgs e) { _userInterface.Time.Text = e.ElapsedTime.ToString(); }
private void WordPlayPreGame(object sender, GameDataEventArgs e) { _userInterface.Status.Visible = true; _userInterface.Status.Text = "Start spillet med å løfte armene oppover"; }