} // end checkWallCollisions public override void CheckObjectCollision(Actor[] objects) { // if laser traveling downward, then it is an enemy laser if (vY > 0) { // if laser hit player AND laser does not belong to player if(Actor.DoesCollide(this, objects[0]) && deleteMe == false && owner != objects[0]) { // damage player objects[0].damageMe(this.laser); // create small explosion... Explosion e = new Explosion(ActionPanel, this, Explosion.ExplosionCategory.laserHit); GameWindow.ThisGameWindow.actors[ GameWindow.GetFirstOpenIndex(GameWindow.ThisGameWindow.actors)] = e; // destroy self this.deleteMe = true; } // end if hit player } // end if going down (enemy laser) else { // it's the players laser for (int i = 1; i < objects.Length; i++) { if (objects[i] != null && objects[i] != this && objects[i].GetType() != typeof(Laser) && // lasers don't counter each other objects[i].GetType() != typeof(SeekingLaser) && // lasers don't counter each other objects[i].GetType() != typeof(Bonus) && // lasers can't kill a bonus objects[i].GetType() != typeof(Explosion) && // lasers go through explosions. objects[i].deleteMe == false) { // check collision, if so, respond. if (Actor.DoesCollide(this, objects[i])) { // player laser damaged target, destroy/hurt target objects[i].damageMe(this.laser); if (objects[i].deleteMe == true) { GameWindow.DropBonus(ActionPanel, objects[i]); objects[0].score += objects[i].laser; } else // if target not destroyed { // create small laser explosion... Explosion e = new Explosion(ActionPanel, this, Explosion.ExplosionCategory.laserHit); // set explosion to match movement of target. e.vX = objects[i].vX; e.vY = objects[i].vY; GameWindow.ThisGameWindow.actors[ GameWindow.GetFirstOpenIndex(GameWindow.ThisGameWindow.actors)] = e; } // destory self this.deleteMe = true; } // if collides. } // end if } // end for loop } // end if going up (player laser) } // end checkObjectCollision
} // 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 }