Пример #1
0
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            int X = e.X;
            int Y = e.Y;

            if (Algorithm.Busy)
            {
                return;
            }
            if (X < Viewer.SquareSide || X > Viewer.Width - Viewer.SquareSide || Y < Viewer.SquareSide || Y > Viewer.Width - Viewer.SquareSide)
            {
                return;
            }
            X -= (int)Viewer.SquareSide;
            Y -= (int)Viewer.SquareSide;
            X  = (int)(X / Viewer.SquareSide);
            Y  = (int)(Y / Viewer.SquareSide);
            Algorithm.Init(X, Y);
            Viewer.WriteNum(Graphics, X, Y, 0);
            while (Algorithm.MoveToNextLevel(ref Graphics))
            {
                Thread.Sleep(1000);
            }
            Algorithm.Clear();
        }
Пример #2
0
        public static bool MoveToNextLevel(ref Graphics grafics)
        {
            List <Point> points = new List <Point>();

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (matrix[i, j] == Level)
                    {
                        points.AddRange(NextPointsFrom(i, j));
                    }
                }
            }
            if (points.Count == 0)
            {
                return(false);
            }
            Level++;
            foreach (var p in points)
            {
                matrix[p.X, p.Y] = Level;
                Viewer.WriteNum(grafics, p.X, p.Y, Level);
            }
            return(true);
        }