/// <summary> /// The displayBoss method creates the final Boss enemy and /// defines all its movements and shooting patherns. /// </summary> private void displayBoss() { Point bossPos = new Point(); bossPos.X = 300; bossPos.Y = 100; Animation bossAnimation; Image bossPic = new Image(); bossPic.Height = 120; bossPic.Width = 140; bossPic.Source = UtilityMethods.LoadImage("pics/boss/boss.png"); canvas.Children.Add(bossPic); Canvas.SetLeft(bossPic, 200); BitmapImage[] bossImages = { UtilityMethods.LoadImage("pics/boss/boss1.png"), UtilityMethods.LoadImage("pics/boss/boss2.png"),UtilityMethods.LoadImage("pics/boss/boss3.png"), }; bossAnimation = new Animation(bossPic, bossImages, true); this.boss = new Boss(bossPos, bossPic, canvas, bossAnimation); Animation.Initiate(bossAnimation, 500); enemies.Add(boss); boss.setTarget(player); this.boss.Fly(200); this.boss.Shoot(2); }
/// <summary> /// The Live method is called if the Boss is hitted but the /// counter is less than 33.It randomly moves the Boss on the screen /// giving an impression that the Boss is disapearing and reapearing /// in another location. /// </summary> public void live() { Animation bossAnimation; if (hitCounter < 34) { Random randX = new Random(); this.point.X = randX.Next(500); Random randY = new Random(); this.point.Y = randY.Next(300); this.image = new Image(); this.image.Height = 120; this.image.Width = 140; this.canvas.Children.Add(this.image); Canvas.SetTop(this.image, this.point.Y); Canvas.SetLeft(this.image, this.point.X); // this.setPointX(this.point.X); //this.setPointnY(this.point.Y); this.image.Source = UtilityMethods.LoadImage(SwitchImage()[0]); BitmapImage[] bossImages = { UtilityMethods.LoadImage(SwitchImage()[0]), UtilityMethods.LoadImage(SwitchImage()[1]),UtilityMethods.LoadImage(SwitchImage()[2]), }; bossAnimation = new Animation(image, bossImages, true); Animation.Initiate(bossAnimation, 200); } }
/// <summary> /// The Mainwindow Constructor will invoke the InitializeComponent method /// and load the Main window of the Game. /// </summary> public MainWindow() { this.Closed += MainWindow_Closed; this.Closing += MainWindow_Closing; InitializeComponent(); BitmapImage[] newGameSources = { UtilityMethods.LoadImage("pics/newGame_white.png") , UtilityMethods.LoadImage("pics/newGame_lightBlue.png") }; Animation newGameAnimation = new Animation(newGamePic, newGameSources, true); Animation.Initiate(newGameAnimation, 100); BitmapImage[] titleSources = { UtilityMethods.LoadImage("pics/GameTitle_Blue.png") , UtilityMethods.LoadImage("pics/GameTitle_lightBlue.png") }; Animation titleAnimation = new Animation(titlePic, titleSources, true); Animation.Initiate(titleAnimation, 150); BitmapImage[] loadGameSoures = { UtilityMethods.LoadImage("pics/loadGame_blue.png") , UtilityMethods.LoadImage("pics/loadGame_white.png") }; Animation loadGameAnim = new Animation(loadGamePic, loadGameSoures, true); Animation.Initiate(loadGameAnim, 150); }
/// <summary> /// The changeImage method changes the image of the commander once /// it is shot once as an indication to the user and initiates a new animation /// for that new image. /// </summary> public void changeImage() { this.animation.Stop(); BitmapImage[] commanderImages = { UtilityMethods.LoadImage("pics/commanderGreen0.png"), UtilityMethods.LoadImage("pics/commanderGreen1.png") }; this.animation = new Animation(this.image, commanderImages, true); Animation.Initiate(animation, 500); }
/// <summary> /// The overriden Die method initiates the animation of the explosion of /// the bug once shot already. The method also increases /// the points of the player if the bug is eliminated and stops the /// timer for moving and shooting of the bug. /// </summary> public override void Die() { this.target.addCoins(100); BitmapImage[] explosions = { UtilityMethods.LoadImage("pics/explosions/enemiesExp0.png"), UtilityMethods.LoadImage("pics/explosions/enemiesExp1.png"), UtilityMethods.LoadImage("pics/explosions/enemiesExp2.png"), UtilityMethods.LoadImage("pics/explosions/enemiesExp3.png") }; this.stopMove(); this.animation = new Animation(this.image, explosions, false, canvas); Animation.Initiate(this.animation, 40); }
/// <summary> /// The overriden Die method initiates the animation of the explosion of /// the SpaceShip enemy once shot already. The method also increases /// the points of the player if the spaceShip is eliminated and stops the /// timer for moving and shooting. /// </summary> public override void Die() { this.dead = true; this.target.addCoins(200); //this.isShot = true; BitmapImage[] explosions = { UtilityMethods.LoadImage("pics/explosions/enemiesExp0.png"), UtilityMethods.LoadImage("pics/explosions/enemiesExp1.png"), UtilityMethods.LoadImage("pics/explosions/enemiesExp2.png"), UtilityMethods.LoadImage("pics/explosions/enemiesExp3.png") }; this.stopMove(); this.StopShoot(); Animation explode = new Animation(this.image, explosions, false, canvas); Animation.Initiate(explode, 40); }
/// <summary> /// The overriden Die method initiates the animation of the explosion of /// the Player once shot already. The method also stops the explosion /// sound effect and dispose its resources invoking the Dispose method /// from the GameSound Class. /// </summary> public override void Die() { decrementLives(); BitmapImage[] explosions = { UtilityMethods.LoadImage("pics/explosions/explosion0.png"), UtilityMethods.LoadImage("pics/explosions/explosion1.png"), UtilityMethods.LoadImage("pics/explosions/explosion2.png"), UtilityMethods.LoadImage("pics/explosions/explosion3.png") }; Animation animation = new Animation(this.image, explosions, false, canvas); Animation.Initiate(animation, 100); explosionSoundEffect.playSound(); explosionSoundEffect.Dispose(); live(); }
/// <summary> /// The overriden Die method initiates the animation of the explosion of /// the Boss once the Boss is hit 33 times. If the commander is eliminated it stops the /// timer for moving and shooting of the Boss and the game finishes. /// </summary> public override void Die() { hitCounter++; BitmapImage[] explosions = { UtilityMethods.LoadImage("pics/bossExplosions/explosion1.png"), UtilityMethods.LoadImage("pics/bossExplosions/explosion2.png"), UtilityMethods.LoadImage("pics/bossExplosions/explosion3.png"), UtilityMethods.LoadImage("pics/bossExplosions/explosion4.png"), UtilityMethods.LoadImage("pics/bossExplosions/explosion5.png"), UtilityMethods.LoadImage("pics/bossExplosions/explosion6.png"), UtilityMethods.LoadImage("pics/bossExplosions/explosion7.png"), UtilityMethods.LoadImage("pics/bossExplosions/explosion8.png"), UtilityMethods.LoadImage("pics/bossExplosions/explosion9.png") }; if (hitCounter == 33) { this.stopMove(); this.animation = new Animation(this.image, explosions, false, canvas); Animation.Initiate(this.animation, 40); //this.canvas.Children.Remove(lv4Pic); sound.playSound(); Image missionAccomplished = new Image(); missionAccomplished.Height = 300; missionAccomplished.Width = 500; this.canvas.Children.Add(missionAccomplished); Canvas.SetTop(missionAccomplished, 150); Canvas.SetLeft(missionAccomplished, 170); BitmapImage[] missionAccomplishedSources = { UtilityMethods.LoadImage("pics/missAccomplised_blue.png") , UtilityMethods.LoadImage("pics/missAccomplised_white.png") }; Animation missionAccomplishedAnim = new Animation(missionAccomplished, missionAccomplishedSources, true); Animation.Initiate(missionAccomplishedAnim, 100); } else { canvas.Children.Remove(this.image); live(); } }
/// <summary> /// The overridden Fly method takes as input a double for the frequency /// to call the startFly method for the moving of the bugs on the screen /// and the method initiates the animation of the bugs's wings as well /// </summary> /// <param name="frequency">double value for the speed of the moving</param> public override void Fly(double frequency) { Animation.Initiate(this.animation, 200); startFly(frequency); }
/// <summary> /// The Initiate method involkes the Initiate method from the Animation class with a specific speed. /// </summary> /// <param name="animation">The animation Object provided</param> /// <param name="animationSpeed">The double value speed provided.</param> public static void Initiate(Animation animation, double animationSpeed) { animation.Initiate(animationSpeed); }