Beispiel #1
0
 public Hero(ContentManager content)
 {
     projectileList      = new List <IMoveableObject>();
     bulletTexture       = content.Load <Texture2D>("Bullet");
     texture             = content.Load <Texture2D>("IceWizard");
     Position            = new Vector2(70, 770);
     Velocity            = new Vector2(2, 0);
     heroAttackAnimation = new HeroAttackAnimation();
     heroRunAnimation    = new HeroRunAnimation();
     heroDieAnimation    = new HeroDieAnimation();
     heroJumpAnimation   = new HeroJumpAnimation();
     heroIdleAnimation   = new HeroIdleAnimation();
     heroHitAnimation    = new HeroHitAnimation();
     animation           = heroIdleAnimation;
 }
Beispiel #2
0
 /// <summary>
 /// Zorgt voor het juiste gedrag van de hero
 /// </summary>
 /// <param name="gameTime"></param>
 public void Update(GameTime gameTime)
 {
     if (projectileList != null)
     {
         UpdateProjectiles();
     }
     if (IsHit && totalLives != 0 && animation != heroHitAnimation)
     {
         totalLives--;
         IsHit     = false;
         animation = heroHitAnimation;
     }
     if (totalLives == 0)
     {
         if (animation != heroDieAnimation)
         {
             heroDieAnimation = new HeroDieAnimation();
             animation        = heroDieAnimation;
         }
         if (animation.CurrentFrame != animation.frames[animation.frames.Count - 1])
         {
             animation.Update(gameTime);
         }
         else
         {
             IsHit = false;
         }
     }
     else if (animation == heroHitAnimation)
     {
         if (animation.CurrentFrame != animation.frames[animation.frames.Count - 1])
         {
             animation.Update(gameTime);
         }
         else if (totalLives != 0)
         {
             animation        = heroIdleAnimation;
             heroHitAnimation = new HeroHitAnimation();
             Position         = new Vector2(70, 770);
             IsHit            = false;
         }
     }
     else
     {
         if (_Movement.Jump)
         {
             animation = heroJumpAnimation;
             if (Velocity.X >= 0 && !_Movement.Left)
             {
                 flipAnimation = false;
             }
             else
             {
                 flipAnimation = true;
             }
         }
         else if (_Movement.Left)
         {
             if (Velocity.Y == 0)
             {
                 animation = heroRunAnimation;
             }
             flipAnimation = true;
         }
         else if (_Movement.Right)
         {
             if (Velocity.Y == 0)
             {
                 animation = heroRunAnimation;
             }
             flipAnimation = false;
         }
         else if (_Movement.Shoot)
         {
             if (Velocity.Y == 0)
             {
                 animation = heroAttackAnimation;
                 Shoot();
             }
         }
         else
         {
             animation = heroIdleAnimation;
         }
         _Movement.Update(this);
         animation.Update(gameTime);
         TouchingGround = false;
         TouchingLeft   = false;
         TouchingRight  = false;
         TouchingTop    = false;
     }
 }