Пример #1
0
        private void RemoveCannon(int i)
        {
            Canon cannon = ClosestCannon(Enemies[i]);

            TheForm.GetControls().Remove(cannon);
            Cannons.Remove(cannon);
            TheForm.GetControls().Remove(Enemies[i]);
            Enemies.RemoveAt(i);

            SoundCollection.PlayerCannonCrush.Play();
            ShakeForm();
        }
Пример #2
0
        private Canon ClosestCannon(Enemy enemy)
        {
            int   min       = int.MaxValue;
            Canon minCannon = null;

            foreach (Canon cannon in Cannons)
            {
                if (Math.Abs(cannon.Left - enemy.Left) < min)
                {
                    min       = Math.Abs(cannon.Left - enemy.Left);
                    minCannon = cannon;
                }
            }
            return(minCannon);
        }
Пример #3
0
        private void DrawStrike(Enemy res)
        {
            Canon    cannon   = CannonToShot(res);
            Graphics graphics = TheForm.CreateGraphics();

            Point[]           points = { new Point(cannon.Left + cannon.Width / 2 - 8, cannon.Top), new Point(cannon.Left + cannon.Width / 2 + 8, cannon.Top), new Point(res.Left + res.Width / 2 + 5, res.Top + res.Height / 2),
                                         new Point(res.Left + res.Width / 2 - 5,                 res.Top + res.Height / 2) };
            PathGradientBrush brush = new PathGradientBrush(points);

            brush.CenterPoint    = new Point(cannon.Left + cannon.Width / 2, cannon.Top);
            brush.CenterColor    = Color.DarkBlue;
            brush.SurroundColors = new[] { Color.White, Color.Violet };
            FillMode fillMode = FillMode.Winding;

            graphics.FillPolygon(brush, points, fillMode);
            TimerStrike.Start();
        }