/// <summary> /// when a message have been received from the opponent /// </summary> /// <param name="sender">is the messageTransmiter</param> /// <param name="statues">is the server message</param> private void OpponentPlay(object sender, StatuesEventArgs statues) { // Opponent made a move if (statues.Stat.Stat == Status.Play) { Direction direction = (Direction)Enum.Parse(typeof(Direction), statues.Stat.Message); OpponentMazeControl.PositionPlayer(direction); } // Opponent end the game else if (statues.Stat.Stat == Status.CloseGame) { MessageBox.Show("The other player end the game"); Dispatcher.Invoke(() => { CloseGame(); }); } // Opponent won the game else if (statues.Stat.Stat == Status.Finish) { MessageBox.Show("You lost!"); Dispatcher.Invoke(() => { CloseGame(); }); } }
/// <summary> /// method to do when message is received /// </summary> /// <param name="o">object triggered the event</param> /// <param name="e">parameters sent</param> public void OnOpponentMove(object o, StatuesEventArgs e) { registerForMessages?.Invoke(this, e); }
/// <summary> /// method to do when message is received /// </summary> /// <param name="o">object triggered the event</param> /// <param name="e">parameters sent</param> public void OnOpponentMove(object o, StatuesEventArgs statues) { MoveOpponent?.Invoke(o, statues); }