Exemple #1
0
        public void GetLoseCell(List <ComputerLoseSet> ComputerLoseMap, GameCell Cell)
        {
            int lose1, lose2;

            int ix = Cell.x;
            int iy = Cell.y;

            if (Cell.WinMode == WinMode.None)
            {
                if (Cell.Horizontal == CellMode.Empty)
                {
                    Cell.Horizontal = CellMode.Computer;
                    lose1           = GetWinsCell(ix, iy);
                    lose2           = 0;
                    if (iy > 0)
                    {
                        if (fileldArray[ix, iy - 1].WinMode == WinMode.None)
                        {
                            lose2 = GetWinsCell(ix, iy - 1);
                        }
                    }
                    Cell.Horizontal = CellMode.Empty;

                    ComputerLoseMap.Add(new ComputerLoseSet(Cell, lose1 > lose2 ? lose1 : lose2, true));
                }

                if (Cell.Vertical == CellMode.Empty)
                {
                    Cell.Vertical = CellMode.Computer;
                    lose1         = GetWinsCell(ix, iy);
                    lose2         = 0;
                    if (ix > 0)
                    {
                        if (fileldArray[ix - 1, iy].WinMode == WinMode.None)
                        {
                            lose2 = GetWinsCell(ix - 1, iy);
                        }
                    }
                    Cell.Vertical = CellMode.Empty;
                    ComputerLoseMap.Add(new ComputerLoseSet(Cell, lose1 > lose2 ? lose1 : lose2, false));
                }
            }
        }
Exemple #2
0
 public ComputerLoseSet(GameCell cell, int lose, bool hv)
 {
     this.Cell = cell;
     this.HV   = hv;
     this.Lose = lose;
 }
Exemple #3
0
        public void SetStep(object sender, MouseEventArgs e)
        {
            CellMode StepModeHorizontal = CellMode.Empty;
            CellMode StepModeVertical   = CellMode.Empty;

            if (GameCursor.InGameField)
            {
                GameCursor.CursorPosition.SetPosition(e);

                GameCell Cell = fileldArray[GameCursor.CursorPosition.X, GameCursor.CursorPosition.Y];

                bool IsEnable = false;

                if (GameCursor.CursorLineMode == LineMode.Horizontal && Cell.Horizontal == CellMode.Empty)
                {
                    switch (PlayerMode)
                    {
                    case PlayerMode.Player1:
                        StepModeHorizontal = CellMode.Player1;
                        break;

                    case PlayerMode.Player2:
                        StepModeHorizontal = CellMode.Player2;
                        break;

                    case PlayerMode.Computer:
                        StepModeHorizontal = CellMode.Computer;
                        break;
                    }
                    StepModeVertical = Cell.Vertical;
                    IsEnable         = true;
                }

                if (GameCursor.CursorLineMode == LineMode.Vertical && Cell.Vertical == CellMode.Empty)
                {
                    StepModeHorizontal = Cell.Horizontal;
                    switch (PlayerMode)
                    {
                    case PlayerMode.Player1:
                        StepModeVertical = CellMode.Player1;
                        break;

                    case PlayerMode.Player2:
                        StepModeVertical = CellMode.Player2;
                        break;

                    case PlayerMode.Computer:
                        StepModeVertical = CellMode.Computer;
                        break;
                    }
                    IsEnable = true;
                }

                if (IsEnable)
                {
                    Cell.SetCell(StepModeHorizontal, StepModeVertical);

                    if (!Cell.CheckWinCells())
                    {
                        if (GameMode == GameMode.Player1Player2)
                        {
                            switch (PlayerMode)
                            {
                            case PlayerMode.Player1:
                                PlayerMode = PlayerMode.Player2;
                                break;

                            case PlayerMode.Player2:
                                PlayerMode = PlayerMode.Player1;
                                break;
                            }
                        }

                        if (GameMode == GameMode.Player1Computer)
                        {
                            PlayerMode = PlayerMode.Computer;
                            SetComputerStep();
                            PlayerMode = PlayerMode.Player1;

                            /*switch (PlayerMode)
                             * {
                             *  case PlayerMode.Player1:
                             *      PlayerMode = PlayerMode.Computer;
                             *      break;
                             *  case PlayerMode.Computer:
                             *      PlayerMode = PlayerMode.Player1;
                             *      break;
                             * }*/
                        }
                    }

                    SaveGame();
                }
            }
        }
Exemple #4
0
 public ComputerWinSet(GameCell cell, int win)
 {
     this.Cell = cell;
     this.Win  = win;
 }