Beispiel #1
0
        public void DrawD()
        {
            int x_initial = Tower3.Location.X + 8;
            int y_initial = Tower3.Location.Y;

            int x_final = Val.X;
            int y_final = Val.Y;

            double x_current = (double)x_initial;
            int    y_current = y_initial;

            int exR = 5;

            int time = y_final - y_initial;

            double add = ((double)x_final - (double)x_initial) / (double)time;

            Point[]    move     = new Point[2];
            Pen        myPen    = new Pen(Color.Pink, 1);
            SolidBrush pinkBomb = new SolidBrush(Color.Pink);

            Rectangle explosionRec = new Rectangle();

            Graphics g = Warzone.CreateGraphics();

            for (int i = 0; i < Math.Abs(y_initial - y_final); i++)
            {
                Thread.Sleep(10);
                x_current -= add;
                y_current -= 1;

                move[0] = new Point(x_initial, y_initial);
                move[1] = new Point(Convert.ToInt32(Math.Round(x_current)), y_current);

                g.DrawLines(myPen, move);
            }



            for (i = 0; i < 5; i++)
            {
                Thread.Sleep(100);
                exR              += 4;
                explosionRec.X    = move[1].X - 7 - i;
                explosionRec.Y    = move[1].Y - 7 - i;
                explosionRec.Size = new Size(exR, exR);
                g.FillPie(pinkBomb, explosionRec, 0, 360);
            }
            g.Clear(Warzone.BackColor);
        }
Beispiel #2
0
        public void DrawMissile()
        {
            int    x_initial = ranLoc.Next(0, Warzone.Width);                   //Will move a Line from top to bottom of panel
            int    y_initial = 0;
            double x_current = x_initial;
            int    y_current = y_initial;
            int    city      = ranLoc.Next(0, 3);
            int    time      = Tower1.Location.Y;

            double add = 0;

            Point[]    move        = new Point[2];
            Pen        myPen       = new Pen(Color.White, 1);
            Pen        outlineBase = new Pen(Color.Gold, 2);
            SolidBrush allWhite    = new SolidBrush(Color.LightGray);
            SolidBrush missileF    = new SolidBrush(Color.Blue);

            Graphics g = Warzone.CreateGraphics();



            Rectangle baseMid = new Rectangle(240, Warzone.Height - 5, 20, 10);

            g.DrawEllipse(outlineBase, baseMid);                                    //was supposed to represent the towers
            g.FillEllipse(allWhite, baseMid);

            Rectangle baseLeft = new Rectangle(120, Warzone.Height - 5, 20, 10);

            g.DrawEllipse(outlineBase, baseLeft);
            g.FillEllipse(allWhite, baseLeft);

            Rectangle baseRight = new Rectangle(360, Warzone.Height - 5, 20, 10);

            g.DrawEllipse(outlineBase, baseRight);
            g.FillEllipse(allWhite, baseRight);

            switch (city)
            {
            case 0:
                add = ((double)Tower1.Location.X + 8 - (double)x_initial) / time;                // rate = distance/time

                for (int i = 0; i < Warzone.Height; i++)
                {
                    Thread.Sleep(10);
                    x_current += add;
                    y_current += 1;

                    move[0] = new Point(x_initial, y_initial);
                    move[1] = new Point(Convert.ToInt32(Math.Round(x_current)), y_current);

                    g.DrawLines(myPen, move);
                }
                g.Clear(Warzone.BackColor);
                break;

            case 1:
                add = ((double)Tower2.Location.X + 8 - (double)x_initial) / time;


                for (int i = 0; i < Warzone.Height; i++)
                {
                    Thread.Sleep(10);
                    x_current += add;
                    y_current += 1;

                    move[0] = new Point(x_initial, y_initial);
                    move[1] = new Point(Convert.ToInt32((Math.Round(x_current))), y_current);

                    g.DrawLines(myPen, move);
                }
                g.Clear(Warzone.BackColor);
                break;

            case 2:
                add = ((double)Tower3.Location.X + 8 - (double)x_initial) / time;


                for (int i = 0; i < Warzone.Height; i++)
                {
                    Thread.Sleep(10);
                    x_current += add;
                    y_current += 1;

                    move[0] = new Point(x_initial, y_initial);
                    move[1] = new Point(Convert.ToInt32((Math.Round(x_current))), y_current);

                    g.DrawLines(myPen, move);
                }
                g.Clear(Warzone.BackColor);
                break;
            }
        }