/// <summary>
 /// overridden draw method allows for the drawing of the thruster fire
 /// </summary>
 /// <param name="Initialg"></param>
 public override void DrawObj(Graphics Initialg)
 {
     base.DrawObj(Initialg);
     if (!IsDying)
     {
         if (ShieldLevel > 0 || Accelerating)
         {
             Initialg.TranslateTransform((int)Position.X, (int)Position.Y);
             Initialg.RotateTransform((float)Rotation); //degrees
             if (ShieldLevel > 0)
             {
                 Initialg.DrawImage(shieldImg, new Point(-(int)(shieldImg.Width / 2 + 8), -(int)(shieldImg.Height / 2 + 9)));
             }
             if (Accelerating)
             {
                 Initialg.DrawEllipse(new Pen(Color.PaleTurquoise, 3), -6, 15, 12, 5);
                 Initialg.FillEllipse(new SolidBrush(Color.Violet), -3, 15, 6, 20);
                 Accelerating = false;
             }
             Initialg.ResetTransform();
         }
     }
     else
     {
         IsActive = Boom.ExplosionDraw(Initialg, new Rectangle((int)(this.Position.X - (this.Dimensions.X + Settings.explodeSizeAdd) / 2), (int)(this.Position.Y - (this.Dimensions.Y + Settings.explodeSizeAdd) / 2), (int)(this.Dimensions.X + Settings.explodeSizeAdd), (int)(this.Dimensions.Y + Settings.explodeSizeAdd)));
         if (HasBoomed == false)
         {
             GameSounds.effect(GameMedia.getDir["explosion1SND"]);
             HasBoomed = true;
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Draws the vehicle on the given grahpics
        /// </summary>
        /// <param name="Initialg">Graphics vehicle is drawn on</param>
        public override void DrawObj(Graphics Initialg)
        {
            if (!IsDying)
            {
                base.DrawObj(Initialg);

                //center world on vehicle then rotate
                Initialg.TranslateTransform((int)Position.X, (int)Position.Y);
                Initialg.RotateTransform((float)Rotation); //degrees

                if (Accelerating)
                {
                    Initialg.DrawEllipse(new Pen(Color.AliceBlue, 3), -6, 15, 12, 5);
                    Initialg.FillEllipse(new SolidBrush(Color.DeepSkyBlue), -3, 15, 6, 20);
                    Accelerating = false;
                }

                Initialg.ResetTransform();
            }
            else
            {
                IsActive = boom.ExplosionDraw(Initialg, new Rectangle((int)(this.Position.X - (this.Dimensions.X + Settings.explodeSizeAdd) / 2), (int)(this.Position.Y - (this.Dimensions.Y + Settings.explodeSizeAdd) / 2), (int)(this.Dimensions.X + Settings.explodeSizeAdd), (int)(this.Dimensions.Y + Settings.explodeSizeAdd)));
                if (hasBoomed == false)
                {
                    GameSounds.effect(GameMedia.getDir["explosion1SND"]);
                    hasBoomed = true;
                }
            }
        }
Пример #3
0
 /// <summary>
 /// this function shoots
 /// </summary>
 public void Shoot()
 {
     if (bulletCoolDown <= 0)
     {
         try { GameSounds.effect(GameMedia.getDir["laser0SND"]); }
         catch { }
         bullets.Add(new NormalBullet(Position.X - Settings.bulletWidth / 2, Position.Y - Settings.bulletHeight / 2, Velocity.X, Velocity.Y, Rotation, "laser0PIC"));
         bulletCoolDown = Settings.shipBulletCooldown;
     }
 }
Пример #4
0
 /// <summary>
 /// warps the player's ship to a random location on the screen.
 /// </summary>
 public void Warp()
 {
     if (warpCoolDown <= 0)
     {
         GameSounds.effect(GameMedia.getDir["warpSND"]);
         Position.X   = (Utilities.screenBounds.Width * Utilities.getRand10() / 10);
         Position.Y   = (Utilities.screenBounds.Height * Utilities.getRand10() / 10);
         warpCoolDown = Settings.shipWarpCooldown;
     }
 }
 /// <summary>
 /// what happens when the Seeker fires
 /// </summary>
 public override void fire()
 {
     if (BulletCoolDown == 0)
     {
         Bullets.Add(new SeekingBullet(Position.X - Settings.bulletWidth / 2, Position.Y - Settings.bulletHeight / 2, Velocity.X, Velocity.Y, Rotation, "laser3PIC", target));
         BulletCoolDown = 150;
         base.fire();
         try { GameSounds.effect(GameMedia.getDir["laser2SND"]); }
         catch { }
     }
 }
 /// <summary>
 /// overloaded draw allows the meteors to explode upon death
 /// </summary>
 /// <param name="Initialg"></param>
 public override void DrawObj(Graphics Initialg)
 {
     base.DrawObj(Initialg);
     if (IsDying)
     {
         deathFlag++;
         IsActive = boom.ExplosionDraw(Initialg, new Rectangle((int)(this.Position.X - (this.Dimensions.X + Settings.explodeSizeAdd) / 2), (int)(this.Position.Y - (this.Dimensions.Y + Settings.explodeSizeAdd) / 2), (int)(this.Dimensions.X + Settings.explodeSizeAdd), (int)(this.Dimensions.Y + Settings.explodeSizeAdd)));
     }
     if (deathFlag == 1)
     {
         try { GameSounds.effect(GameMedia.getDir["explosion0SND"]); }
         catch { }
     }
 }
 /// <summary>
 /// this is what happens when the Hunter's underlying logic decides to fire weapons
 /// </summary>
 public override void fire()
 {
     if (BulletCoolDown == 0)
     {
         GunLeft.setVector(Position);
         GunLeft.addVector(8, RadRotation);
         GunRight.setVector(Position);
         GunRight.addVector(-8, RadRotation);
         Bullets.Add(new NormalBullet(GunLeft.X - Settings.bulletWidth / 2, GunLeft.Y - Settings.bulletHeight / 2, Velocity.X, Velocity.Y, Rotation, "laser2PIC"));
         Bullets.Add(new NormalBullet(GunRight.X - Settings.bulletWidth / 2, GunRight.Y - Settings.bulletHeight / 2, Velocity.X, Velocity.Y, Rotation, "laser2PIC"));
         BulletCoolDown = 120;
         base.fire();
         try { GameSounds.effect(GameMedia.getDir["laser2SND"]); }
         catch { }
     }
 }
Пример #8
0
 /// <summary>
 /// overridded behavior routine allows the Caller to change to a 'coward' when it's shields go down.
 /// </summary>
 /// <param name="player">the player's ship</param>
 protected override void alienLogic(PlayerShip player)
 {
     base.alienLogic(player);
     abilityCoolDown--;
     if (abilityCoolDown == 195)
     {
         GameSounds.effect(GameMedia.getDir["callSigSND"]);
     }
     if (abilityCoolDown <= 0)
     {
         if (ShieldLevel < 1)
         {
             ShieldLevel++;
             IsCoward = false;
             try { GameSounds.effect(GameMedia.getDir["shieldsUpSND"]); }
             catch { }
         }
         callAllies();
         abilityCoolDown = 3000;
     }
 }
 /// <summary>
 /// Handles the collision between a player's bullet and an alien ship
 /// </summary>
 /// <param name="alien">the alien</param>
 /// <param name="bullet">the bullet</param>
 private void bulletHitAlien(AlienBase alien, Weapon bullet)
 {
     bullet.IsDying = true;
     UsedBullets.Add(bullet);
     alien.ShieldLevel -= 1;
     if (alien.ShieldLevel < 0)
     {
         alien.IsDying = true;
         DestroyedAliens.Add(alien);
         MainGame.score             += alien.PointValue;
         MainGame.extraLivesCounter += alien.PointValue;
         if (MainGame.extraLivesCounter > Settings.scoreToNextLife)
         {
             MainGame.lives++;
             MainGame.extraLivesCounter = 0;
             MainGame.extraLifeAdded    = true;
         }
     }
     else
     {
         try { GameSounds.effect(GameMedia.getDir["shieldsDownSND"]); }
         catch { }
     }
 }
        /// <summary>
        /// checks if the level has been won or lost, writes game state to a string stored in MainGame, which
        /// string is accessed by the graphics engine.
        /// </summary>
        private void gameStateEngine()
        {
            int currentTime  = 0;
            int previousTime = Environment.TickCount;
            int deltaTime    = 0;

            while (true)
            {
                currentTime = Environment.TickCount;
                while (!MainGame.isRunning)
                {
                    ;
                }
                deltaTime = currentTime - previousTime;
                if (deltaTime < Settings.gameStateInverseFPS)
                {
                    Thread.Sleep(Settings.gameStateInverseFPS - deltaTime);
                }
                previousTime = currentTime;

                if (MainGame.isRunning)
                {
                    if (Game.isLevelWon())
                    {
                        MainGame.stateDescription = "LevelWon";
                        MainGame.isRunning        = false;
                        GameSounds.credits();
                    }
                    else if (Game.isLevelLost())
                    {
                        GameSounds.loser();
                        if (MainGame.lives <= 0)
                        {
                            MainGame.stateDescription = "GameLost";
                            MainGame.isRunning        = false;
                            return;
                        }
                        else
                        {
                            MainGame.stateDescription = "LevelLost";
                            MainGame.isRunning        = false;
                        }
                    }
                    else if (MainGame.extraLifeAdded)
                    {
                        GameSounds.effect(GameMedia.getDir["extraLifeSND"]);
                        MainGame.stateDescription = "extraLife";
                        MainGame.isRunning        = false;
                    }
                    try
                    {
                        lbl_score.Text = MainGame.score.ToString();
                        lbl_level.Text = MainGame.level.ToString();
                    }
                    catch { }
                }
                else if (MainGame.needsToExit)
                {
                    return;
                }
            }
        }