public MainPage() { InitializeComponent(); NavigateNewBattleField.Subscribe(_ => { reversi.Board.Init(); BlackCounter.InIt(); WhiteCounter.InIt(); BoardUI.BoardPlayers = reversi.Board.Board; BoardUI.EnableColorPointList = reversi.Board.GetEnableColorPointList(Black); BoardUI.ReRendering(); CPUPieceCount.Value = reversi.Board.CountWhiteColor(); PlayerPieceCount.Value = reversi.Board.CountBlackColor(); }); NavigateHome.Subscribe(_ => this.Frame.Navigate(typeof(HomePage))); NavigateBattleResult.Subscribe(_ => this.Frame.Navigate(typeof(BattleResultPage), new ScoreData(reversi.Board.CountBlackColor(), reversi.Board.CountWhiteColor()))); if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") { } BoardUI.EnableColorPointList = reversi.Board.GetEnableColorPointList(Black); BoardUI.BoardPlayers = reversi.Board.Board; BoardUI.ReRendering(); CPUPieceCount.Value = reversi.Board.CountWhiteColor(); PlayerPieceCount.Value = reversi.Board.CountBlackColor(); IntelliService = new CPU(reversi.Board); }
private async Task GameEndProcess() { if (!WhiteCounter.IsContinue() || !BlackCounter.IsContinue() || (reversi.Board.CountNoneColor() == 0)) { await ShowDialog( $"ゲームが終了しました。\n プレイヤー:{reversi.Board.CountBlackColor()} CPU:{reversi.Board.CountWhiteColor()}"); var scoreData = new ScoreData(reversi.Board.CountBlackColor(), reversi.Board.CountWhiteColor()); await new ScoreClient().AddScore(scoreData); reversi.Board.Init(); BlackCounter.InIt(); WhiteCounter.InIt(); BoardUI.BoardPlayers = reversi.Board.Board; BoardUI.EnableColorPointList = reversi.Board.GetEnableColorPointList(Black); BoardUI.ReRendering(); NavigateBattleResult.Subscribe(); } }
private async void BoardUI_Tapped(object sender, TappedRoutedEventArgs e) { var x = -1; var y = -1; for (var i = 0; i < 8; i++) { var X = e.GetPosition((ReversiBoardUI)sender).X; var Y = e.GetPosition((ReversiBoardUI)sender).Y; if ((BoardUI.GetFramePosition(i) < X) && (X < BoardUI.GetFramePosition(1 + i))) { x = i; } if ((BoardUI.GetFramePosition(i) < Y) && (Y < BoardUI.GetFramePosition(1 + i))) { y = i; } } if ((x == -1) || (y == -1)) { return; } try { if ((reversi.Board.GetEnableColorPointList(Black).Count == 0) && (reversi.Board.CountBlackColor() != 0)) { Player.Skip(); await ShowDialog("プレイヤー:スキップします。"); BlackCounter.Skip(); } else { var point = new Tuple <int, int>(x, y); Debug.Write($"プレイヤー X:{x} Y: {y})\n "); SetColor(point); BoardUI.EnableColorPointList = reversi.Board.GetEnableColorPointList(Black); BoardUI.BeforeInputColor = new ColorData(new Tuple <int, int>(x, y), 0); } await GameEndProcess(); if ((reversi.Board.CountBlackColor() == 2) && (reversi.Board.CountWhiteColor() == 2)) { return; } if ((reversi.Board.GetEnableColorPointList(White).Count == 0) && (reversi.Board.CountWhiteColor() != 0)) { Player.Skip(); WhiteCounter.Skip(); RefreshInfomatinText(); await ShowDialog("CPU:スキップします"); } else { var Cpupoint = InputCPU(); SetColor(Cpupoint); } } catch (Exception exception) { Debug.Write(exception.ToString()); } await GameEndProcess(); }