Beispiel #1
0
        public void ChangePlate(GamePoint point)
        {
            GamePoint point1 = new GamePoint(point.X, point.Y);

            if (ProverkaLine(point))
            {
                Cell.ColorCell color = Place[point1.X, point1.Y].GetColor;
                GamePoint      res   = FindPoint(point);
                Score += (int)Math.Pow(Change(res, Place[point.X, point.Y].GetColor), 2);
                Random random = new Random();
                Place[point1.X, point1.Y].ChangeColotInt(random.Next(5));
            }
        }
Beispiel #2
0
 int Change(GamePoint point, Cell.ColorCell color)
 {
     if (point.X < 0 || point.X > 15 || point.Y < 0 || point.Y > 15)
     {
         return(0);
     }
     if (Place[point.X, point.Y].GetColor != color)
     {
         return(0);
     }
     Cell.ColorCell color1 = Place[point.X, point.Y].GetColor;
     Place[point.X, point.Y].GetColor = Cell.ColorCell.White;
     return(1 + Change(new GamePoint(point.X + 1, point.Y), color1) + Change(new GamePoint(point.X - 1, point.Y), color1) + Change(new GamePoint(point.X, point.Y + 1), color1) + Change(new GamePoint(point.X, point.Y - 1), color1));
 }
Beispiel #3
0
        GamePoint FindPoint(GamePoint point)
        {
            GamePoint res = new GamePoint();

            res.X = point.X;
            res.Y = point.Y;
            if (point.X == 0)
            {
                res.X++;
                while (Cell.ColorCell.White == Place[res.X + 1, res.Y].GetColor)
                {
                    res.X++;
                }
            }
            else
            if (point.X == 15)
            {
                res.X--;
                while (Cell.ColorCell.White == Place[res.X - 1, res.Y].GetColor)
                {
                    res.X--;
                }
            }
            else
            if (point.Y == 0)
            {
                res.Y++;
                while (Cell.ColorCell.White == Place[res.X, res.Y + 1].GetColor)
                {
                    res.Y++;
                }
            }
            else
            {
                res.Y--;
                while (Cell.ColorCell.White == Place[res.X, res.Y - 1].GetColor)
                {
                    res.Y--;
                }
            }

            /*if (Place[res.X + 1, res.Y].GetColor == Place[point.X, point.Y].GetColor || Place[res.X - 1, res.Y].GetColor == Place[point.X, point.Y].GetColor ||
             *  Place[res.X, res.Y + 1].GetColor == Place[point.X, point.Y].GetColor || Place[res.X, res.Y - 1].GetColor == Place[point.X, point.Y].GetColor)
             */Place[res.X, res.Y].GetColor = Place[point.X, point.Y].GetColor;
            return(res);
        }
Beispiel #4
0
 public static Point ConvertGamePointToPoint(GamePoint point)
 {
     return(new Point(point.X, point.Y));
 }
Beispiel #5
0
        bool ProverkaLine(GamePoint point)
        {
            bool Type = true;

            if ((point.X == 0 || point.X == 15) && (point.Y == 0 || point.Y == 15))
            {
                return(false);
            }
            if (!((point.X == 0 || point.X == 15) || (point.Y == 0 || point.Y == 15)))
            {
                return(false);
            }
            if (point.X == 0 || point.X == 15)
            {
                Type = true;
            }
            else
            {
                Type = false;
            }
            for (int i = 1; i < 16; i++)
            {
                if (i == 15)
                {
                    return(false);
                }
                if (!Type)
                {
                    if (point.Y == 0)
                    {
                        if (Place[point.X, point.Y].GetColor == Place[point.X, i].GetColor)
                        {
                            return(true);
                        }
                        if (Place[point.X, i].GetColor != Cell.ColorCell.White)
                        {
                            if (Place[point.X + 1, i - 1].GetColor == Place[point.X, point.Y].GetColor || Place[point.X - 1, i - 1].GetColor == Place[point.X, point.Y].GetColor)
                            {
                                return(true);
                            }
                            Place[point.X, i - 1].GetColor = Place[point.X, point.Y].GetColor;
                            return(false);
                        }
                    }
                    else
                    {
                        if (Place[point.X, point.Y].GetColor == Place[point.X, 15 - i].GetColor)
                        {
                            return(true);
                        }
                        if (Place[point.X, 15 - i].GetColor != Cell.ColorCell.White)
                        {
                            if (Place[point.X - 1, i - 1].GetColor == Place[point.X, point.Y].GetColor || Place[point.X + 1, i - 1].GetColor == Place[point.X, point.Y].GetColor)
                            {
                                return(true);
                            }
                            Place[point.X, 16 - i].GetColor = Place[point.X, point.Y].GetColor;
                            return(false);
                        }
                    }
                }
                else
                {
                    if (point.X == 0)
                    {
                        if (Place[i, point.Y].GetColor == Place[point.X, point.Y].GetColor)
                        {
                            return(true);
                        }
                        if (Place[i, point.Y].GetColor != Cell.ColorCell.White)
                        {
                            if (Place[i - 1, point.Y + 1].GetColor == Place[point.X, point.Y].GetColor || Place[i - 1, point.Y - 1].GetColor == Place[point.X, point.Y].GetColor)
                            {
                                return(true);
                            }
                            Place[i - 1, point.Y].GetColor = Place[point.X, point.Y].GetColor;
                            return(false);
                        }
                    }
                    else
                    {
                        if (Place[point.X, point.Y].GetColor == Place[15 - i, point.Y].GetColor)
                        {
                            return(true);
                        }
                        if (Place[15 - i, point.Y].GetColor != Cell.ColorCell.White)
                        {
                            if (Place[i - 1, point.Y + 1].GetColor == Place[point.X, point.Y].GetColor || Place[i - 1, point.Y - 1].GetColor == Place[point.X, point.Y].GetColor)
                            {
                                return(true);
                            }
                            Place[16 - i, point.Y].GetColor = Place[point.X, point.Y].GetColor;
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }