Example #1
0
        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();
        }