private void OpponentMoved(object sender, string direction) { Position position; if (IsValidMove(OpponentRow, OpponentColumn, direction, out position)) { OpponentRow = position.Row; OpponentColumn = position.Col; if (DidWin(OpponentRow, OpponentColumn)) { OnGameStatusChanged?.Invoke(this, OPPONENT_WON); _model.OnPlayerMoved -= PlayerMoved; _model.OnOpponentMoved -= OpponentMoved; } } }
public void PlayerMoved(object sender, string direction) { Position position; if (IsValidMove(PlayerRow, PlayerColumn, direction, out position)) { PlayerRow = position.Row; PlayerColumn = position.Col; _model.Move(direction); if (DidWin(PlayerRow, PlayerColumn)) { OnGameStatusChanged?.Invoke(this, PLAYER_WON); _model.OnPlayerMoved -= PlayerMoved; _model.OnOpponentMoved -= OpponentMoved; } } }
public void SinglePlayerMoved(object sender, string direction) { Position position; if (!IsValidMove(direction, out position)) { return; } PlayerColumn = position.Col; PlayerRow = position.Row; if (PlayerColumn == _maze.EndCol && PlayerRow == _maze.EndRow) { OnGameStatusChanged?.Invoke(this, USER_WON); OnPlayerMoved -= SinglePlayerMoved; } }
public void ToggleRoom() { FinishedVoting = !FinishedVoting; OnGameChanged?.Invoke(); OnGameStatusChanged?.Invoke(); }