Exemple #1
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();
            }

        }
Exemple #2
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
        }