Beispiel #1
0
        private void SetComputerStep(GameCell Cell)
        {
            int[,] WinCells;
            WinCells = new int[x, y];
            if (Cell.WinMode == WinMode.None)
            {
                WaveCells(Cell.x, Cell.y, WinCells);
                GameCell Cell1, CellD, CellL;

                for (int iy = 0; iy <= y - 1; iy++)
                {
                    for (int ix = 0; ix <= x - 1; ix++)
                    {
                        if (WinCells[ix, iy] == 1)
                        {
                            Cell1 = fileldArray[ix, iy];
                            CellD = fileldArray[ix, iy + 1];
                            CellL = fileldArray[ix + 1, iy];
                            Cell1.SetCell(WinMode.Computer);
                            Cell1.SetCell((Cell1.Horizontal == CellMode.Empty ? CellMode.Computer : Cell1.Horizontal), (Cell1.Vertical == CellMode.Empty ? CellMode.Computer : Cell1.Vertical));
                            CellD.SetCell((CellD.Horizontal == CellMode.Empty ? CellMode.Computer : CellD.Horizontal), CellD.Vertical);
                            CellL.SetCell(CellL.Horizontal, (CellL.Vertical == CellMode.Empty ? CellMode.Computer : CellL.Vertical));
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public bool CheckWinCells()
        {
            GameField Game = ((App)(Application.Current)).Game;

            bool     f = false;
            GameCell Cell1, Cell2;

            WinMode Win = WinMode.None;

            Cell1 = Game.fileldArray[x + 1, y];
            Cell2 = Game.fileldArray[x, y + 1];

            switch (Game.PlayerMode)
            {
            case PlayerMode.Player1:
                Win = WinMode.Player1;
                break;

            case PlayerMode.Player2:
                Win = WinMode.Player2;
                break;

            case PlayerMode.Computer:
                Win = WinMode.Computer;
                break;
            }

            if (WinMode == WinMode.None && Horizontal != CellMode.Empty && Vertical != CellMode.Empty && Cell1.Vertical != CellMode.Empty && Cell2.Horizontal != CellMode.Empty)
            {
                SetCell(Win);
                f = true;
            }

            if (y > 0)
            {
                Cell1 = Game.fileldArray[x, y - 1];
                Cell2 = Game.fileldArray[x + 1, y - 1];

                if (Cell1.WinMode == WinMode.None && Horizontal != CellMode.Empty && Cell1.Horizontal != CellMode.Empty && Cell1.Vertical != CellMode.Empty && Cell2.Vertical != CellMode.Empty)
                {
                    Cell1.SetCell(Win);
                    f = true;
                }
            }

            if (x > 0)
            {
                Cell1 = Game.fileldArray[x - 1, y];
                Cell2 = Game.fileldArray[x - 1, y + 1];

                if (Cell1.WinMode == WinMode.None && Vertical != CellMode.Empty && Cell1.Horizontal != CellMode.Empty && Cell1.Vertical != CellMode.Empty && Cell2.Horizontal != CellMode.Empty)
                {
                    Cell1.SetCell(Win);
                    f = true;
                }
            }

            return(f);
        }