Пример #1
0
 private void CheckCaptureDLDiagonal(int x, int y)
 {
     try {
         Stone[,] stones = gameScreen.Stones;
         StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;
         if (x - 1 < 0 || y + 1 > stones.GetLength(0) - 1)
         {
             return;
         }
         if (stones[y + 1, x - 1].CurrentState == currentState || stones[y + 1, x - 1].CurrentState == StoneState.Open)
         {
             return;
         }
         if (x - 2 < 0 || y + 2 > stones.GetLength(0) - 1)
         {
             return;
         }
         if (stones[y + 2, x - 2].CurrentState == currentState || stones[y + 2, x - 2].CurrentState == StoneState.Open)
         {
             return;
         }
         if (x - 3 < 0 || y + 3 > stones.GetLength(0) - 1)
         {
             return;
         }
         if (stones[y + 3, x - 3].CurrentState != currentState)
         {
             return;
         }
         CurrentPlayer.Captures++;
         stones[y + 1, x - 1].CurrentState = StoneState.Open;
         stones[y + 2, x - 2].CurrentState = StoneState.Open;
     } catch { }
 }
Пример #2
0
        public Desk(Game.Game g) : base(sizeX, sizeY, true)
        {
            this.fields = new Stone[sizeX + 1, sizeY + 1];
            this.game   = g;
            this.Pdesk  = ((Game.Game)game).desk;

            // inicialization of labels
            this.fields[0, 0]           = new Stone();
            this.fields[0, 0].Sensitive = false;
            for (uint i = 1; i < fields.GetLength(0); i++)
            {
                this.fields[i, 0] = new Stone();
                this.Attach(fields[i, 0], i, i + 1, 0, 1);
                this.fields[i, 0].Sensitive = false;
                this.fields[i, 0].Show();
                this.fields[i, 0].setChar(i.ToString());

                this.fields[0, i] = new Stone();
                this.Attach(fields[0, i], 0, 1, i, i + 1);
                this.fields[0, i].Sensitive = false;
                this.fields[0, i].Show();
                this.fields[0, i].setChar(i.ToString());
            }

            for (uint j = 1; j < fields.GetLength(1); j++)
            {
                for (uint i = 1; i < fields.GetLength(0); i++)
                {
                    fields[i, j] = new Stone();
                    this.Attach(fields[i, j], i, i + 1, j, j + 1);
                }
            }

            this.Restart();
        }
Пример #3
0
 private void CheckCaptureURDiagonal(int x, int y)
 {
     try {
         Stone[,] stones = gameScreen.Stones;
         StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;
         if (x + 1 > stones.GetLength(1) - 1 || y - 1 < 0)
         {
             return;
         }
         if (stones[y - 1, x + 1].CurrentState == currentState || stones[y - 1, x + 1].CurrentState == StoneState.Open)
         {
             return;
         }
         if (x + 2 > stones.GetLength(1) - 1 || y - 1 < 0)
         {
             return;
         }
         if (stones[y - 2, x + 2].CurrentState == currentState || stones[y - 2, x + 2].CurrentState == StoneState.Open)
         {
             return;
         }
         if (x + 3 > stones.GetLength(1) - 1 || y - 1 < 0)
         {
             return;
         }
         if (stones[y - 3, x + 3].CurrentState != currentState)
         {
             return;
         }
         CurrentPlayer.Captures++;
         stones[y - 1, x + 1].CurrentState = StoneState.Open;
         stones[y - 2, x + 2].CurrentState = StoneState.Open;
     } catch { }
 }
Пример #4
0
 private static IEnumerable <Stone> YieldDiagDown(Stone[,] stones, int i, int j)
 {
     for (var k = 0; i + k < stones.GetLength(0) && j + k < stones.GetLength(1); k++)
     {
         yield return(stones[i + k, j + k]);
     }
 }
Пример #5
0
 //initializes turn panels with empty stones
 public void InitializePanel(Stone[,] panel)
 {
     for (int i = 0; i < panel.GetLength(0); i++)
     {
         for (int j = 0; j < panel.GetLength(1); j++)
         {
             panel[i, j] = new Stone(i, j);
         }
     }
 }
Пример #6
0
        public static void MirrorVertical(this Stone[,] input)
        {
            var height = input.GetLength(0);

            for (var i = 0; i < height / 2; i++)
            {
                for (var j = 0; j < input.GetLength(1); j++)
                {
                    Swap(ref input[i, j], ref input[height - 1 - i, j]);
                }
            }
        }
Пример #7
0
        public static void MirrorHorizontal(this Stone[,] input)
        {
            var width = input.GetLength(1);

            for (var j = 0; j < width / 2; j++)
            {
                for (var i = 0; i < input.GetLength(0); i++)
                {
                    Swap(ref input[i, j], ref input[i, width - 1 - j]);
                }
            }
        }
Пример #8
0
        public static Stone[,] Copy(this Stone[,] s)
        {
            var copy = new Stone[s.GetLength(0), s.GetLength(1)];

            for (var i = 0; i < s.GetLength(0); i++)
            {
                for (var j = 0; j < s.GetLength(1); j++)
                {
                    copy[i, j] = s[i, j];
                }
            }
            return(copy);
        }
Пример #9
0
 public Board()
 {
     Spaces = new Stone[8, 8];
     for (int i = 0; i < Spaces.GetLength(0); i++)
     {
         for (int j = 0; j < Spaces.GetLength(1); j++)
         {
             Spaces[i, j]   = new Stone();
             Spaces[i, j].x = i;
             Spaces[i, j].y = j;
         }
     }
 }
Пример #10
0
        private void MonsterPang_Paint(object sender, PaintEventArgs e)
        {
            int x = 8;
            int y = 2;

            for (int row = 0; row < boardGUI.GetLength(0); row++)
            {
                x = 8;
                for (int col = 0; col < boardGUI.GetLength(1); col++)
                {
                    boardGUI[row, col] = stage.board.stones[row, col];
                    switch (boardGUI[row, col].type)
                    {
                    case 1:
                        stBitmap = Properties.Resources.stone1;
                        e.Graphics.DrawImage(stBitmap, x, y, stBitmap.Width, stBitmap.Height);
                        break;

                    case 2:
                        stBitmap = Properties.Resources.stone2;
                        e.Graphics.DrawImage(stBitmap, x, y, stBitmap.Width, stBitmap.Height);
                        break;

                    case 3:
                        stBitmap = Properties.Resources.stone3;
                        e.Graphics.DrawImage(stBitmap, x, y, stBitmap.Width, stBitmap.Height);
                        break;

                    case 4:
                        stBitmap = Properties.Resources.stone4;
                        e.Graphics.DrawImage(stBitmap, x, y, stBitmap.Width, stBitmap.Height);
                        break;

                    case 5:
                        stBitmap = Properties.Resources.stone5;
                        e.Graphics.DrawImage(stBitmap, x, y, stBitmap.Width, stBitmap.Height);
                        break;

                    case 6:
                        stBitmap = Properties.Resources.stone6;
                        e.Graphics.DrawImage(stBitmap, x, y, stBitmap.Width, stBitmap.Height);
                        break;

                    default:
                        break;
                    }
                    x = x + 50;
                }
                y = y + 52;
            }
        }
Пример #11
0
 public bool IsMovable()
 {
     for (int row = 0; row < stones.GetLength(0); row++)
     {
         for (int col = 0; col < stones.GetLength(1); col++)
         {
             if (Switchable(row, col, row, col + 1) || Switchable(row, col, row + 1, col))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #12
0
        public static bool LessThan(this Stone[,] a, Stone[,] b)
        {
            bool?aHasWhiteFirst = null;

            for (var i = 0; i < a.GetLength(0); i++)
            {
                for (var j = 0; j < b.GetLength(1); j++)
                {
                    if (a[i, j] == Stone.Black && b[i, j] != Stone.Black)
                    {
                        return(true);
                    }
                    if (b[i, j] == Stone.Black && a[i, j] != Stone.Black)
                    {
                        return(false);
                    }
                    if (!aHasWhiteFirst.HasValue && a[i, j] != b[i, j])
                    {
                        // NOTE Neither A nor B is black
                        //      And one has to be white and the other none
                        if (a[i, j] == Stone.White)
                        {
                            aHasWhiteFirst = true;
                        }
                        else
                        {
                            aHasWhiteFirst = false;
                        }
                    }
                }
            }
            return(aHasWhiteFirst == true);
        }
Пример #13
0
 private static IEnumerable <Stone> YieldCol(Stone[,] stones, int col)
 {
     for (var i = 0; i < stones.GetLength(0); i++)
     {
         yield return(stones[i, col]);
     }
 }
Пример #14
0
 private static IEnumerable <Stone> YieldRow(Stone[,] stones, int row)
 {
     for (var j = 0; j < stones.GetLength(1); j++)
     {
         yield return(stones[row, j]);
     }
 }
Пример #15
0
        private bool CheckDiagDLtoURTria(StoneState currentState, Stone[,] stones, int x, int y)
        {
            bool tria      = false;
            int  maxYBound = stones.GetLength(0) - 1;
            int  maxXBound = stones.GetLength(1) - 1;

            if (x + 1 <= maxXBound && y - 1 >= 0 && stones[y - 1, x + 1].CurrentState == StoneState.Open)
            {
                if (x - 1 >= 0 && y + 1 <= maxYBound && stones[y + 1, x - 1].CurrentState == currentState)
                {
                    if (x - 2 >= 0 && y + 2 <= maxYBound && stones[y + 2, x - 2].CurrentState == currentState)
                    {
                        if (x - 3 >= 0 && y + 3 <= maxYBound && stones[y + 3, x - 3].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            else if (x - 1 >= 0 && y + 1 <= maxYBound && stones[y + 1, x - 1].CurrentState == StoneState.Open)
            {
                if (x + 1 <= maxXBound && y - 1 >= 0 && stones[y - 1, x + 1].CurrentState == currentState)
                {
                    if (x + 2 <= maxXBound && y - 2 >= 0 && stones[y - 2, x + 2].CurrentState == currentState)
                    {
                        if (x + 3 <= maxXBound && y - 3 >= 0 && stones[y - 3, x + 3].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            else if (x + 1 <= maxXBound && y - 1 >= 0 && stones[y - 1, x + 1].CurrentState == currentState)
            {
                if (x - 1 >= 0 && y + 1 <= maxYBound && stones[y + 1, x - 1].CurrentState == currentState)
                {
                    if (x - 2 >= 0 && y + 2 <= maxYBound && stones[y + 2, x - 2].CurrentState == StoneState.Open)
                    {
                        if (x + 2 <= maxXBound && y - 2 >= 0 && stones[y - 2, x + 2].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            return(tria);
        }
Пример #16
0
        internal static IEnumerable <Stone> SearchStonesInCombo(Stone[,] field)
        {
            var(w, h) = field;

            for (int x = 0; x < w; ++x)
            {
                for (int y = 0; y < h; ++y)
                {
                    if (field[x, y] == null)
                    {
                        continue;
                    }

                    var c = field[x, y].color;

                    if (x < field.GetLength(0) - 2)
                    {
                        var s1       = field[x + 1, y];
                        var s2       = field[x + 2, y];
                        var hasCombo = s1 != null && s2 != null;
                        hasCombo = hasCombo && c == s1.color && c == s2.color;
                        if (hasCombo)
                        {
                            foreach (var s in GetAllWithColor(field, c, new int2(x, y), new int2(1, 0)))
                            {
                                yield return(s);
                            }
                        }
                    }

                    if (y < field.GetLength(1) - 2)
                    {
                        var s1       = field[x, y + 1];
                        var s2       = field[x, y + 2];
                        var hasCombo = s1 != null && s2 != null;
                        hasCombo = hasCombo && c == s1.color && c == s2.color;
                        if (hasCombo)
                        {
                            foreach (var s in GetAllWithColor(field, c, new int2(x, y), new int2(0, 1)))
                            {
                                yield return(s);
                            }
                        }
                    }
                }
            }
        }
Пример #17
0
        private bool CheckVerticalTessera(int x, int y)
        {
            StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;

            Stone[,] stones = gameScreen.Stones;
            bool tessera   = false;
            int  maxYValue = stones.GetLength(0) - 1;
            int  maxXValue = stones.GetLength(1) - 1;
            bool startedT  = false;
            int  count     = 0;

            for (var i = 0; i < maxYValue; i++)
            {
                if (stones[i, x].CurrentState == currentState)
                {
                    if (!startedT && i - 1 >= 0 && stones[i - 1, x].CurrentState == StoneState.Open)
                    {
                        startedT = true;
                    }
                    if (startedT)
                    {
                        count++;
                    }
                }
                else if (stones[i, x].CurrentState == StoneState.Open)
                {
                    if (count == 4 && i - 1 >= 0 && stones[i - 1, x].CurrentState == currentState)
                    {
                        tessera = true;
                    }
                    else
                    {
                        startedT = false;
                        count    = 0;
                    }
                }
                else
                {
                    startedT = false;
                    count    = 0;
                }
            }
            return(tessera);
        }
Пример #18
0
        private int CheckRowDiagonalRL(int x, int y)
        {
            int        count        = 0;
            StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;

            Stone[,] stones = gameScreen.Stones;
            for (int i = 0; i < 5; i++)
            {
                if (x - i < 0 || y - i < 0)
                {
                    break;
                }
                else
                {
                    if (stones[y - i, x - i].CurrentState == currentState)
                    {
                        count++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            for (int i = 1; i < 5; i++)
            {
                if (x + i > stones.GetLength(1) - 1 || y + i > stones.GetLength(0) - 1)
                {
                    break;
                }
                else
                {
                    if (stones[y + i, x + i].CurrentState == currentState)
                    {
                        count++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(count);
        }
Пример #19
0
 public static void Transpose(this Stone[,] input)
 {
     for (var i = 1; i < input.GetLength(0); i++)
     {
         for (var j = 0; j < i; j++)
         {
             Swap(ref input[i, j], ref input[j, i]);
         }
     }
 }
Пример #20
0
        static void MoveRocksDown()
        {
            Stone[,] temp = new Stone[25, 80];

            for (int i = 0; i < array.GetLength(0); i++)
            {
                for (int j = 0; j < array.GetLength(1); j++)
                {
                    if (i != 24)
                    {
                        temp[i + 1, j] = array[i, j];
                    }
                }
            }

            array = temp;

            Console.MoveBufferArea(0, 0, y, 24, 0, 1); //Move rocks down a line
            Console.MoveBufferArea(y + 3, 0, 80 - (y + 3), 24, y + 3, 1);
            Console.MoveBufferArea(y, 0, 3, 23, y, 1);
        }
Пример #21
0
        private bool CheckDLtoURTessera(int x, int y)
        {
            StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;

            Stone[,] stones = gameScreen.Stones;
            bool tessera         = true;
            int  maxYValue       = stones.GetLength(0) - 1;
            int  maxXValue       = stones.GetLength(1) - 1;
            int  disFromCurPoint = 0;

            while (CheckBounds(x - disFromCurPoint, y + disFromCurPoint) && stones[y + disFromCurPoint, x - disFromCurPoint].CurrentState == currentState)
            {
                disFromCurPoint++;
            }

            disFromCurPoint--;
            int startX = x - disFromCurPoint;
            int startY = y + disFromCurPoint;

            for (int i = 0; i < 4; i++)
            {
                if (CheckBounds(startX + i, startY - i) && stones[startY - i, startX + i].CurrentState != currentState)
                {
                    tessera = false;
                    break;
                }
            }

            if (!CheckBounds(startX - 1, startY + 1) ||
                (CheckBounds(startX - 1, startY + 1) && stones[startY + 1, startX - 1].CurrentState != StoneState.Open))
            {
                if (!CheckBounds(startX + 4, startY - 4) ||
                    (CheckBounds(startX + 4, startY - 4) && stones[startY - 4, startX + 4].CurrentState != StoneState.Open))
                {
                    tessera = false;
                }
            }
            return(tessera);
        }
Пример #22
0
 private void CheckCaptureDown(int x, int y)
 {
     try {
         Stone[,] stones = gameScreen.Stones;
         if (y > stones.GetLength(0) - 4)
         {
             return;
         }
         StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;
         if (y + 1 > stones.GetLength(0) - 1)
         {
             return;
         }
         if (stones[y + 1, x].CurrentState == currentState || stones[y + 1, x].CurrentState == StoneState.Open)
         {
             return;
         }
         if (y + 2 > stones.GetLength(0) - 1)
         {
             return;
         }
         if (stones[y + 2, x].CurrentState == currentState || stones[y + 2, x].CurrentState == StoneState.Open)
         {
             return;
         }
         if (y + 3 > stones.GetLength(0) - 1)
         {
             return;
         }
         if (stones[y + 3, x].CurrentState != currentState)
         {
             return;
         }
         CurrentPlayer.Captures++;
         stones[y + 1, x].CurrentState = StoneState.Open;
         stones[y + 2, x].CurrentState = StoneState.Open;
     } catch { }
 }
Пример #23
0
 private void CheckCaptureRight(int x, int y)
 {
     try {
         Stone[,] stones = gameScreen.Stones;
         if (x > stones.GetLength(1) - 4)
         {
             return;
         }
         StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;
         if (x + 1 > stones.GetLength(1) - 1)
         {
             return;
         }
         if (stones[y, x + 1].CurrentState == currentState || stones[y, x + 1].CurrentState == StoneState.Open)
         {
             return;
         }
         if (x + 2 > stones.GetLength(1) - 1)
         {
             return;
         }
         if (stones[y, x + 2].CurrentState == currentState || stones[y, x + 2].CurrentState == StoneState.Open)
         {
             return;
         }
         if (x + 3 > stones.GetLength(1) - 1)
         {
             return;
         }
         if (stones[y, x + 3].CurrentState != currentState)
         {
             return;
         }
         CurrentPlayer.Captures++;
         stones[y, x + 1].CurrentState = StoneState.Open;
         stones[y, x + 2].CurrentState = StoneState.Open;
     } catch { }
 }
Пример #24
0
 public static bool AreEqual(this Stone[,] a, Stone[,] b)
 {
     for (var i = 0; i < a.GetLength(0); i++)
     {
         for (var j = 0; j < b.GetLength(1); j++)
         {
             if (a[i, j] != b[i, j])
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #25
0
        /// <summary>
        /// Init blank desk with all bonuses
        /// </summary>
        public void Restart()
        {
            /* initialization of Buttons (letters) */
            for (uint j = 1; j < fields.GetLength(1); j++)
            {
                for (uint i = 1; i < fields.GetLength(0); i++)
                {
                    fields[i, j].setChar("");
                    fields[i, j].Name        = "B " + i + " " + j;              // name is +1 oposite the logic desk
                    fields[i, j].TooltipText = "[" + i + "," + j + "]";
                    fields[i, j].ModifyBg(StateType.Normal, this.Style.Backgrounds[(int)StateType.Prelight]);
                    fields[i, j].Hide();
                    fields[i, j].Show();
                    fields[i, j].Clicked += PushButton;
                }
            }

            /* initialization of charBonus */
            for (int j = 0; j < fields.GetLength(1) - 1; j++)
            {
                for (int i = 0; i < fields.GetLength(0) - 1; i++)
                {
                    if (Pdesk.CharBonus[i, j] == 1)
                    {
                        continue;
                    }
                    else
                    {
                        SetBonus(new System.Drawing.Point(i, j), Pdesk.CharBonus[i, j], false);
                    }
                }
            }

            /* initialization of wordBonus */
            for (int j = 0; j < fields.GetLength(1) - 1; j++)
            {
                for (int i = 0; i < fields.GetLength(0) - 1; i++)
                {
                    if (Pdesk.WordBonus[i, j] == 1)
                    {
                        continue;
                    }
                    else
                    {
                        SetBonus(new System.Drawing.Point(i, j), Pdesk.WordBonus[i, j], true);
                    }
                }
            }
        }
Пример #26
0
 public static bool CheckTie(Stone[,] stones, int winningLen)
 {
     for (var row = 0; row < stones.GetLength(0); row++)
     {
         if (TieCheck(YieldRow(stones, row), winningLen) != TypeCheckResult.NeitherWillWin)
         {
             return(false);
         }
     }
     for (var col = 0; col < stones.GetLength(1); col++)
     {
         if (TieCheck(YieldCol(stones, col), winningLen) != TypeCheckResult.NeitherWillWin)
         {
             return(false);
         }
     }
     if (TieCheck(YieldDiagDown(stones, 0, 0), winningLen) != TypeCheckResult.NeitherWillWin ||
         TieCheck(YieldDiagUp(stones, stones.GetLength(0) - 1, 0), winningLen) != TypeCheckResult.NeitherWillWin)
     {
         return(false);
     }
     for (var k = 1; k <= stones.GetLength(1) - winningLen; k++)
     {
         if (TieCheck(YieldDiagDown(stones, 0, k), winningLen) != TypeCheckResult.NeitherWillWin ||
             TieCheck(YieldDiagUp(stones, stones.GetLength(0) - 1, k), winningLen) != TypeCheckResult.NeitherWillWin)
         {
             return(false);
         }
     }
     for (var k = 1; k <= stones.GetLength(0) - winningLen; k++)
     {
         if (TieCheck(YieldDiagDown(stones, k, 0), winningLen) != TypeCheckResult.NeitherWillWin ||
             TieCheck(YieldDiagUp(stones, stones.GetLength(0) - 1 - k, 0), winningLen) != TypeCheckResult.NeitherWillWin)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #27
0
 private bool IsOutside(int x, int y)
 {
     return(x < 0 || y < 0 || x >= board.Length || y >= board.GetLength(1));
 }
Пример #28
0
        private bool CheckDiagonalTria(int x, int y)
        {
            StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;

            Stone[,] stones = gameScreen.Stones;
            bool tria = false;

            if (x - 1 >= 0 && y - 1 >= 0 && stones[y - 1, x - 1].CurrentState == StoneState.Open)
            {
                if (x + 1 <= stones.GetLength(1) - 1 && y - 1 <= stones.GetLength(0) - 1 &&
                    stones[y + 1, x + 1].CurrentState == StoneState.Open)
                {
                    tria = CheckDiagDLtoURTria(currentState, stones, x, y);
                }
                else if (x + 1 <= stones.GetLength(1) - 1 && y + 1 <= stones.GetLength(0) - 1 &&
                         stones[y + 1, x + 1].CurrentState == currentState)
                {
                    if (x + 2 <= stones.GetLength(1) - 1 && y + 2 <= stones.GetLength(0) - 1 &&
                        stones[y + 2, x + 2].CurrentState == currentState)
                    {
                        if (x + 3 <= stones.GetLength(1) - 1 && y + 3 <= stones.GetLength(0) - 1 &&
                            stones[y + 3, x + 3].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            else if (x + 1 <= stones.GetLength(1) - 1 && y + 1 <= stones.GetLength(0) - 1 &&
                     stones[y + 1, x + 1].CurrentState == StoneState.Open)
            {
                if (x - 1 >= 0 && y - 1 >= 0 && stones[y - 1, x - 1].CurrentState == currentState)
                {
                    if (x - 2 >= 0 && y - 2 >= 0 && stones[y - 2, x - 2].CurrentState == currentState)
                    {
                        if (x - 3 >= 0 && y - 3 >= 0 && stones[y - 3, x - 3].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            else if (x + 1 <= stones.GetLength(1) - 1 && y + 1 <= stones.GetLength(0) - 1 &&
                     stones[y + 1, x + 1].CurrentState == currentState)
            {
                if (x - 1 >= 0 && y - 1 >= 0 && stones[y - 1, x - 1].CurrentState == currentState)
                {
                    if (x - 2 >= 0 && y - 2 >= 0 && stones[y - 2, x - 2].CurrentState == StoneState.Open)
                    {
                        if (x + 2 <= stones.GetLength(1) - 1 && y + 2 <= stones.GetLength(0) - 1 &&
                            stones[y + 2, x + 2].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            return(tria);
        }
Пример #29
0
        private bool CheckVerticalTria(int x, int y)
        {
            Stone[,] stones = gameScreen.Stones;
            StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;
            bool       tria         = false;

            if (y == 0 || x == stones.GetLength(0) - 1)
            {
                tria = false;
            }
            if (y - 1 >= 0 && stones[y - 1, x].CurrentState == currentState)
            {
                if (y - 2 >= 0 && stones[y - 2, x].CurrentState == StoneState.Open)
                {
                    if (y + 1 <= stones.GetLength(0) - 1 && stones[y + 1, x].CurrentState == currentState)
                    {
                        if (y + 2 <= stones.GetLength(0) - 1 && stones[y + 2, x].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
                else if (y - 2 >= 0 && stones[y - 2, x].CurrentState == currentState)
                {
                    if (y - 3 >= 0 && stones[y - 3, x].CurrentState == StoneState.Open)
                    {
                        if (y + 1 <= stones.GetLength(1) - 1 && stones[y + 1, x].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            else if (y - 1 >= 0 && stones[y - 1, x].CurrentState == StoneState.Open)
            {
                if (y + 1 <= stones.GetLength(0) - 1 && stones[y + 1, x].CurrentState == currentState)
                {
                    if (y + 2 <= stones.GetLength(0) - 1 && stones[y + 2, x].CurrentState == currentState)
                    {
                        if (y + 3 <= stones.GetLength(0) - 1 && stones[y + 3, x].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            else if (y + 1 <= stones.GetLength(0) - 1 && stones[y + 1, x].CurrentState == StoneState.Open)
            {
                if (y - 1 >= 0 && stones[y - 1, x].CurrentState == currentState)
                {
                    if (y - 2 >= 0 && stones[y - 2, x].CurrentState == currentState)
                    {
                        if (y - 3 >= 0 && stones[y - 3, x].CurrentState == currentState)
                        {
                            if (y - 4 >= 0 && stones[y - 4, x].CurrentState == StoneState.Open)
                            {
                                tria = true;
                            }
                        }
                    }
                }
            }
            return(tria);
        }
Пример #30
0
        private bool CheckHorizontalTria(int x, int y)
        {
            StoneState currentState = CurrentPlayer == Player1 ? StoneState.Black : StoneState.White;

            Stone[,] stones = gameScreen.Stones;
            bool tria = false;

            if (x == 0 || x == stones.GetLength(1) - 1)
            {
                tria = false;
            }
            if (x - 1 >= 0 && stones[y, x - 1].CurrentState == currentState)
            {
                if (x - 2 >= 0 && stones[y, x - 2].CurrentState == StoneState.Open)
                {
                    if (x + 1 <= stones.GetLength(1) - 1 && stones[y, x + 1].CurrentState == currentState)
                    {
                        if (x + 2 <= stones.GetLength(1) - 1 && stones[y, x + 2].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
                else if (x - 2 >= 0 && stones[y, x - 2].CurrentState == currentState)
                {
                    if (x - 3 >= 0 && stones[y, x - 3].CurrentState == StoneState.Open)
                    {
                        if (x + 1 <= stones.GetLength(1) - 1 && stones[y, x + 1].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            else if (x - 1 >= 0 && stones[y, x - 1].CurrentState == StoneState.Open)
            {
                if (x + 1 <= stones.GetLength(1) - 1 && stones[y, x + 1].CurrentState == currentState)
                {
                    if (x + 2 <= stones.GetLength(1) - 1 && stones[y, x + 2].CurrentState == currentState)
                    {
                        if (x + 3 <= stones.GetLength(1) - 1 && stones[y, x + 3].CurrentState == StoneState.Open)
                        {
                            tria = true;
                        }
                    }
                }
            }
            else if (x + 1 <= stones.GetLength(1) - 1 && stones[y, x + 1].CurrentState == StoneState.Open)
            {
                if (x - 1 >= 0 && stones[y, x - 1].CurrentState == currentState)
                {
                    if (x - 2 >= 0 && stones[y, x - 2].CurrentState == currentState)
                    {
                        if (x - 3 >= 0 && stones[y, x - 3].CurrentState == currentState)
                        {
                            if (x - 4 >= 0 && stones[y, x - 4].CurrentState == StoneState.Open)
                            {
                                tria = true;
                            }
                        }
                    }
                }
            }
            return(tria);
        }