Ejemplo n.º 1
0
        public Boss(Panel ActionPanel, int lvl)
            :
            base(ActionPanel, "Boss0" + lvl + ".gif")
        {
            // set actor variables for the laser:
            this.lvl = lvl;

            speed = 2 * lvl;
            laser = 2 + (lvl * 3); // 4, 8, 11
            health = 10 + 30 * lvl; // 30, 70, 100, etc.
            coolDown = (10 - lvl) * 100; // 900, 800, 700, etc.

            posX = MyRnd.next(ActionPanel.Width - this.ObjWidth);
            posY = -this.ObjHeight - 300; // - 300 to delay a bit.
            vX = speed - (2 * MyRnd.next(speed));
            vY = speed;
            numLives = 0;
        } // end constructor
Ejemplo n.º 2
0
        } // end constructor
#endregion

#region public methods
        public override void update()
        {
            base.update();
            try
            {
                if (posY > ActionPanel.Height)
                {
                    deleteMe = true;
                }
                else
                {
                    // decide if we want to shoot at the player
                    if (MyRnd.next(1000) >= (998 - this.lvl)) // 0.2% - 0.5% based on lvl.
                    {
                        // shoot
                        Laser shot;
                        this.lvl += 1;
                        if (lvl > 3)
                        {
                            shot = new SeekingLaser(ActionPanel, this);
                        }
                        else
                        {
                            shot = new Laser(ActionPanel, this);
                        }
                        this.lvl -= 1;

                        shot.vY = 10 + this.lvl; // set speed
                        GameWindow.ThisGameWindow.actors[
                            GameWindow.GetFirstOpenIndex(GameWindow.ThisGameWindow.actors)] = shot;

                    }
                } // end not off screen
            }
            catch (ArgumentNullException ane)
            {
                ane.ToString();
            }
            catch (NullReferenceException ne)
            {
                ne.ToString();
            }

        }
Ejemplo n.º 3
0
        public Target(Panel ActionPanel, int lvl)
            :
            base(ActionPanel, "target0" + lvl + ".gif")
        {

            // set actor variables for the laser:
            this.lvl = lvl;

            speed = lvl + MyRnd.next(5);
            laser = lvl;
            health = 2 * lvl;
            coolDown = startCoolDown;

            posX = MyRnd.next(ActionPanel.Width - this.ObjWidth);
            posY = -this.ObjHeight;
            vX = speed - (2 * MyRnd.next(speed));
            vY = speed;
            numLives = 0;
        } // end constructor
Ejemplo n.º 4
0
        public Bonus(Panel ActionPanel, Actor sourceActor)
            :
            base(ActionPanel)
        {
            // set actor variables for the laser:
            source = sourceActor;

            this.speed = source.speed;

            // weight the bonuses - less ammo bonuses
            int rnd = MyRnd.next(100);
            if (rnd < 20) // 20% chance of bonus being  
            {
                m_category = BonusCategory.laserPowerBonus;
            }
            else if (rnd < 45) // 25% chance of bonus being 
            {
                m_category = BonusCategory.healthBonus;
            }
            else if (rnd < 75) // 30% chance of bonus being 
            {
                m_category = BonusCategory.speedBonus;
            }
            else  // 25% chance of bonus being 
            {
                m_category = BonusCategory.laserSpeedBonus;
            }

            SetImage("Bonus_" + (int)m_category + ".GIF");
          
            posX = source.posX;
            posY = source.posY;
            vX = source.vX / 2;
            vY = source.vY;

        } // end constructor
Ejemplo n.º 5
0
        } // end constructor
        #endregion

        #region public methods
        public override void update()
        {
            base.update();
            if (this.deleteMe)
            {
                GameWindow.ThisGameWindow.isBossPresent = false;
                return;
            }

                #region Shooting
                // first check if we can shoot yet
                if (lastShot.AddMilliseconds(coolDown).CompareTo(System.DateTime.Now) < 0)
                {
                    // if so, then randomly choose.
                    if (MyRnd.next(100) >= (90 - (this.lvl * 2))) // 10% - 15% based on lvl. (per frame)
                    {
                        // standard shot (x3)
                        int temp = this.lvl;
                        this.lvl = 5;
                        Laser shot = new Laser(ActionPanel, this);
                        Laser shot2 = new Laser(ActionPanel, this);
                        Laser shot3 = new Laser(ActionPanel, this);
                        SeekingLaser shot4 = new SeekingLaser(ActionPanel, this);
                        SeekingLaser shot5 = new SeekingLaser(ActionPanel, this);
                        SeekingLaser shot6 = new SeekingLaser(ActionPanel, this);

                        this.lvl = temp;

                        // level specific shooting capabilities
                        // small spread
                        shot.vY = 5 + this.lvl * 2; // set speed
                        shot2.vY = 5 + this.lvl * 2; // set speed
                        shot3.vY = 5 + this.lvl * 2; // set speed
                        shot4.vY = 5 + this.lvl * 2;
                        shot5.vY = 5 + this.lvl * 2;
                        shot6.vY = 5 + this.lvl * 2;

                        shot2.vX = -3; // set angle
                        shot3.vX = 3; // set angle
                        shot5.vX = -5; // set angle
                        shot6.vX = 5; // set angle

                        // if higher boss, shoot seeking laser instead
                        switch (temp)
                        {
                            case 1:
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot;
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot2;
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot3;
                                break;
                            case 2:
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot2;
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot4;
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot3;
                                break;
                            case 3:
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot5;
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot;
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot6;
                                break;
                            case 4:
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot5;
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot4;
                                GameWindow.ThisGameWindow.actors[
                                    GameWindow.GetFirstOpenIndex(
                                        GameWindow.ThisGameWindow.actors)] = shot6;
                                break;
                        }
                        
                        // we have fired, so set the lastShot timer
                        lastShot = DateTime.Now;
                    } // end shoot
                }// end if cooldown
                #endregion

                #region Movement
                // decide if we want to change location/speeds
                if (posY > (2 * img.Height))
                {
                    vY = 0;
                    // if boss is moving slowly vX
                    if (vX < 5 &&
                        vX > -5)
                    {
                        // then speed up
                        vX = 2 * (vX + 1);
                    }
                }
                #endregion
        }