public void SetPlayerBoard(WrapPanel playerBoard) { this.PlayerBoard = playerBoard; Turn = new Turn(PlayerBoard); }
public async void AIBoard_Button_Click(object sender, RoutedEventArgs e) { Button aiButton = (sender as Button); WrapPanel aiPanel = (aiButton.Parent as WrapPanel); if (GameState == GameStates.Ongoing) { //player turn TurnCounter++; await Dispatcher.CurrentDispatcher.InvokeAsync(() => Turn.PlayerTurn( aiPanel.Children[ButtonRenderWindHit(aiPanel, aiButton)] as Button)); CheckIfPlayerWon(aiButton); //ai turn Button playerButton = await Dispatcher.CurrentDispatcher.InvokeAsync(() => Turn.AiAlghoritm()); await Dispatcher.CurrentDispatcher.InvokeAsync(() => Turn.PlayerTurn(playerButton)); CheckIfAiWon(playerButton); await Dispatcher.CurrentDispatcher.InvokeAsync(() => WeatherData.WeatherInfoUpdate()); } else { MessageBox.Show("The game is finished!"); } }