Exemple #1
0
 public Debris()
 {
     InitializeComponent();
     LoadImages();
     LoadSounds();
     LoadScoreCard();
     lbl_overheat.Visible = false;
     shield_lbl.Text = health.ToString() + "%";
     player = new Sprite();
 }
Exemple #2
0
 private void xwing_btn_Click(object sender, EventArgs e)
 {
     player = new Sprite(50, 50, 40, 49, Sprite.TYPE_XWING, GetImage("XWing"), GetImage("XWingLeft"), 0, 0);
     hide_buttons_resume_game();
 }
Exemple #3
0
 private void vulture_droid_btn_Click(object sender, EventArgs e)
 {
     player = new Sprite(50, 50, 40, 49, Sprite.TYPE_VULTUREDROID, GetImage("VultureDroid"), GetImage("VultureDroidLeft"), 0, 0);
     hide_buttons_resume_game();
 }
Exemple #4
0
 private void tie_fighter_btn_Click(object sender, EventArgs e)
 {
     player = new Sprite(50, 50, 40, 49, Sprite.TYPE_TIEFIGHTER, GetImage("TieFighter"), GetImage("TieFighterLeft"), 0, 0);
     hide_buttons_resume_game();
 }
Exemple #5
0
 private void falcon_btn_Click(object sender, EventArgs e)
 {
     player = new Sprite(50, 50, 100, 100, Sprite.TYPE_FALCON, GetImage("Falcon"), GetImage("FalconLeft"), 0, 0);
     hide_buttons_resume_game();
 }
Exemple #6
0
 private void blaster_movement_Tick(object sender, EventArgs e)
 {
     //Move the player at the same time as the blasters
     if (waitingForSelection == false && player.followMouse(this, mouseX, mouseY) == -1)
     {
         if (player.Type == Sprite.TYPE_XWING)
         {
             player = new Sprite(50, 50, 40, 49, Sprite.TYPE_XWING, GetImage("XWing"), GetImage("XWingLeft"), 0, 0);
         }
         else if (player.Type == Sprite.TYPE_AWING)
         {
             player = new Sprite(50, 50, 40, 49, Sprite.TYPE_AWING, GetImage("AWing"), GetImage("AWingLeft"), 0, 0);
         }
         else if (player.Type == Sprite.TYPE_VULTUREDROID)
         {
             player = new Sprite(50, 50, 40, 49, Sprite.TYPE_VULTUREDROID, GetImage("VultureDroid"), GetImage("VultureDroidLeft"), 0, 0);
         }
         else if (player.Type == Sprite.TYPE_TIEFIGHTER)
         {
             player = new Sprite(50, 50, 40, 49, Sprite.TYPE_TIEFIGHTER, GetImage("TieFighter"), GetImage("TieFighterLeft"), 0, 0);
         }
         else if (player.Type == Sprite.TYPE_FALCON)
         {
             player = new Sprite(50, 50, 100, 100, Sprite.TYPE_FALCON, GetImage("Falcon"), GetImage("FalconLeft"), 0, 0);
         }
     }
     if (blasterTemp > 0)
     {
         blasterTemp--;
         blaster_temp.Text = blasterTemp.ToString() + "%";
         if (overheat == true && blasterTemp <= 50)
         {
             overheat = false;
             lbl_overheat.Visible = false;
         }
     }
     if (torpedoCool > 0)
     {
         torpedoCool--;
     }
     for (int i = 0; i < blasters.Count; i++)
     {
         if (blasters[i] != null)
         {
             if (blasters[i].AutoMove(this) == -1)
             {
                 blasters.RemoveAt(i);
                 double accuracy = Math.Round(((double)astroidsHit / (double)num_shots) * 100, 2);
                 accuracy_label.Text = accuracy.ToString();
             }
             for (int j = 0; j < astroids.Count; j++)
             {
                 try
                 {
                     if (i < blasters.Count && j < astroids.Count && blasters[i].DetectIntersection(astroids[j]) == 1)
                     {
                         blasters.RemoveAt(i);
                         if (!astroids[j].isBeingDestroyed())
                         {
                             astroids[j].Explode(GetImage("Explosion_1"), GetImage("ShatterAstroid2"));
                             PlaySound("Explosion1");
                             double accuracy = Math.Round(((double)astroidsHit / (double)num_shots) * 100, 2);
                             accuracy_label.Text = accuracy.ToString();
                         }
                         astroidsHit++;
                         debris_score.Text = astroidsHit.ToString();
                     }
                 }
                 catch (Exception ex)
                 {
                     Logger.Write(log_options, module, "WARNING: Exception detected: " + ex.Message);
                 }
             }
         }
     }
     Invalidate();
 }
Exemple #7
0
        /*********************************************************
        * CREATES A NEW SPRITE BLASTER OR WEAPON TYPE OBJECT
        *********************************************************/
        public Sprite fire(Form inputForm, Image inImage, int weapon)
        {
            Sprite output = null;

            //Fire for XWing type of ship
            if (Type == TYPE_XWING)
            {
                //XWing blasters
                if (weapon == 1)
                {
                    int startXPosition = X + 30;
                    int startYPosition = Y + 3;
                    byte move_direction = AUTO_RIGHT;
                    if (cur_turret == 0)
                    {
                        cur_turret++;
                    }
                    else
                    {
                        cur_turret = 0;
                        startYPosition = Y + 40;
                    }
                    if (direction == 2)
                    {
                        startXPosition = X + 15;
                        move_direction = AUTO_LEFT;
                    }
                    output = new Sprite(startXPosition, startYPosition, 15, 0, TYPE_BLASTER_RED, inImage, null, move_direction, 0);
                    output.XSpeed = 20;
                    output.YSpeed = 20;

                }
                //XWing torpedo
                else if (weapon == 2)
                {
                    if (direction == 1)
                    {
                        output = new Sprite(X + 30, Y + 20, 15, 0, TYPE_TORPEDO, inImage, null, AUTO_RIGHT, 0);
                    }
                    else if (direction == 2)
                    {
                        output = new Sprite(X + 15, Y + 20, 15, 0, TYPE_TORPEDO, inImage, null, AUTO_LEFT, 0);
                    }
                    output.XSpeed = 20;
                    output.YSpeed = 20;
                }
            }
            else if (Type == TYPE_AWING)
            {
                //AWing blasters
                if (weapon == 1)
                {
                    int startXPosition = X + 30;
                    int startYPosition = Y + 3;
                    byte move_direction = AUTO_RIGHT;
                    if (cur_turret == 0)
                    {
                        cur_turret++;
                    }
                    else
                    {
                        cur_turret = 0;
                        startYPosition = Y + 40;
                    }
                    if (direction == 2)
                    {
                        startXPosition = X + 15;
                        move_direction = AUTO_LEFT;
                    }
                    output = new Sprite(startXPosition, startYPosition, 15, 0, TYPE_BLASTER_RED, inImage, null, move_direction, 0);
                    output.XSpeed = 10;
                    output.YSpeed = 10;

                }
                //AWing torpedo
                else if (weapon == 2)
                {
                    if (direction == 1)
                    {
                        output = new Sprite(X + 30, Y + 20, 15, 0, TYPE_TORPEDO, inImage, null, AUTO_RIGHT, 0);
                    }
                    else if (direction == 2)
                    {
                        output = new Sprite(X + 15, Y + 20, 15, 0, TYPE_TORPEDO, inImage, null, AUTO_LEFT, 0);
                    }
                    output.XSpeed = 10;
                    output.YSpeed = 10;
                }
            }
            else if (Type == TYPE_TIEFIGHTER)
            {
                //AWing blasters
                if (weapon == 1)
                {
                    int startXPosition = X + 25;
                    int startYPosition = Y + 23;
                    byte move_direction = AUTO_RIGHT;
                    if (cur_turret == 0)
                    {
                        cur_turret++;
                    }
                    else
                    {
                        cur_turret = 0;
                        startYPosition = Y + 28;
                    }
                    if (direction == 2)
                    {
                        startXPosition = X + 15;
                        move_direction = AUTO_LEFT;
                    }
                    output = new Sprite(startXPosition, startYPosition, 15, 0, TYPE_BLASTER_RED, inImage, null, move_direction, 0);
                    output.XSpeed = 10;
                    output.YSpeed = 10;

                }
            }
            //Fire for Vulture droid type of ship
            else if (Type == TYPE_FALCON)
            {
                //XWing blasters
                if (weapon == 1)
                {
                    int startXPosition = X + 35;
                    int startYPosition = Y + 45;
                    byte move_direction = AUTO_RIGHT;
                    if (cur_turret == 0)
                    {
                        cur_turret++;
                    }
                    else if (cur_turret == 1)
                    {
                        cur_turret = 0;
                        startYPosition = Y + 50;
                    }
                    if (direction == 2)
                    {
                        startXPosition = X + 30;
                        move_direction = AUTO_LEFT;
                    }
                    output = new Sprite(startXPosition, startYPosition, 15, 0, TYPE_BLASTER_RED, inImage, null, move_direction, 0);
                    output.XSpeed = 20;
                    output.YSpeed = 20;

                }
                //XWing torpedo
                else if (weapon == 2)
                {
                    if (direction == 1)
                    {
                        output = new Sprite(X + 20, Y + 45, 15, 0, TYPE_TORPEDO, inImage, null, AUTO_RIGHT, 0);
                    }
                    else if (direction == 2)
                    {
                        output = new Sprite(X + 15, Y + 50, 15, 0, TYPE_TORPEDO, inImage, null, AUTO_LEFT, 0);
                    }
                    output.XSpeed = 10;
                    output.YSpeed = 10;
                }
            }
            //Fire for Vulture droid type of ship
            else if (Type == TYPE_VULTUREDROID)
            {
                //XWing blasters
                if (weapon == 1)
                {
                    int startXPosition = X + 30;
                    int startYPosition = Y + 3;
                    byte move_direction = AUTO_RIGHT;
                    if (cur_turret == 0)
                    {
                        cur_turret++;
                    }
                    else
                    {
                        cur_turret = 0;
                        startYPosition = Y + 40;
                    }
                    if (direction == 2)
                    {
                        startXPosition = X + 15;
                        move_direction = AUTO_LEFT;
                    }
                    output = new Sprite(startXPosition, startYPosition, 15, 0, TYPE_BLASTER_RED, inImage, null, move_direction, 0);
                    output.XSpeed = 20;
                    output.YSpeed = 20;

                }
                //XWing torpedo
                else if (weapon == 2)
                {
                    if (direction == 1)
                    {
                        output = new Sprite(X + 30, Y + 20, 15, 0, TYPE_TORPEDO, inImage, null, AUTO_RIGHT, 0);
                    }
                    else if (direction == 2)
                    {
                        output = new Sprite(X + 15, Y + 20, 15, 0, TYPE_TORPEDO, inImage, null, AUTO_LEFT, 0);
                    }
                    output.XSpeed = 10;
                    output.YSpeed = 10;
                }
            }
            else
            {
                Logger.Write(log_options, "SPRITE", "WARNING: No weapon assigned to object type: '" + Type + "'");
            }

            return output;
        }
Exemple #8
0
 public int DetectIntersection(Sprite inputObject)
 {
     if (X + Width > inputObject.X && X + Width < inputObject.X + inputObject.Width ||
         X > inputObject.X && X < inputObject.X + inputObject.Width ||
         X < inputObject.X && X + Width > inputObject.X + inputObject.Width ||
         X > inputObject.X && X + Width < inputObject.X + inputObject.Width)
     {
         if (Y + Height > inputObject.Y && Y + Height < inputObject.Y + inputObject.Height ||
         Y > inputObject.Y && Y < inputObject.Y + inputObject.Height ||
         Y < inputObject.Y && Y + Height > inputObject.Y + inputObject.Height ||
         Y > inputObject.Y && Y + Height < inputObject.Y + inputObject.Height)
         {
             return 1;
         }
     }
     return 0;
 }