Exemplo n.º 1
0
        public static void Start()
        {
            if (!IsActive)
            {
                IsActive = true;

                companionCube = Resources.CompanionCube;

                if (cubesForm != null) cubesForm.Close();
                cubesForm = new CompanionCubesForm();
                cubesForm.MouseClick += CubesForm_MouseClick;
                cubesForm.Show();

                area = new Rectangle(0, 0, cubesForm.Width, cubesForm.Height);

                Cubes = new List<CompanionCube>(CubeCount);

                for (int i = 0; i < CubeCount; i++)
                {
                    CompanionCube cube = new CompanionCube(MathHelpers.Random(50, 100), MathHelpers.Random(250, 500));
                    cube.Location = new Point(MathHelpers.Random(area.X, area.X + area.Width - cube.Size.Width),
                        MathHelpers.Random(area.Y - cube.Size.Height - 500, area.Y - cube.Size.Height));
                    Cubes.Add(cube);
                }

                previousElapsed = TimeSpan.Zero;
                startTime = Stopwatch.StartNew();

                timer = new Timer();
                timer.Interval = 20;
                timer.Tick += Timer_Tick;
                timer.Start();
            }
        }
Exemplo n.º 2
0
        public static void Start()
        {
            if (!IsActive)
            {
                IsActive = true;

                companionCube = Resources.CompanionCube;

                if (cubesForm != null)
                {
                    cubesForm.Close();
                }
                cubesForm             = new CompanionCubesForm();
                cubesForm.MouseClick += CubesForm_MouseClick;
                cubesForm.Show();

                area = new Rectangle(0, 0, cubesForm.Width, cubesForm.Height);

                Cubes = new List <CompanionCube>(CubeCount);

                for (int i = 0; i < CubeCount; i++)
                {
                    CompanionCube cube = new CompanionCube(MathHelpers.Random(50, 100), MathHelpers.Random(250, 500));
                    cube.Location = new Point(MathHelpers.Random(area.X, area.X + area.Width - cube.Size.Width),
                                              MathHelpers.Random(area.Y - cube.Size.Height - 500, area.Y - cube.Size.Height));
                    Cubes.Add(cube);
                }

                previousElapsed = TimeSpan.Zero;
                startTime       = Stopwatch.StartNew();

                timer          = new Timer();
                timer.Interval = 20;
                timer.Tick    += Timer_Tick;
                timer.Start();
            }
        }