private void CheckEvents() { if (playerEvent.changeState) { playerEvent.changeState = false; // reset the current animation currentAnimation.Reset(); } if (playerEvent.shootWeapon) { playerEvent.shootWeapon = false; if (player.Gun.Shooting) { // it was the gun gunRepresentation.AddBullet(); } else if (player.Sword.Shooting) { // it was the sword swordRepresentation.AddBullet(); } } }
protected override void updateWhenAlive(float dt) { // First, get the behavior if (enemy.Behavior.Compare(BatBehavior.Flying)) { currentAnimation = flyAnimation; } else if (enemy.Behavior.Compare(BatBehavior.Diving)) { currentAnimation = diveAnimation; } else if (enemy.Behavior.Compare(BatBehavior.Idle)) { currentAnimation = idleAnimation; } else { currentAnimation = idleAnimation; } // Check whether to use big eyes if (enemy.Vision.EnemySeesPlayer || enemy.Behavior.Compare(BatBehavior.Diving)) { currentEyesFrame = eyesBigFrame; } else { currentEyesFrame = eyesIdleFrame; } // Check if he's been hit if (enemy.Health.Hit) { currentAnimation = hitAnimation; currentEyesFrame = eyesSadFrame; } else { hitAnimation.Reset(); } // Check whether we should be facing left if (enemy.FacingRight) { spriteEffects = SpriteEffects.None; } else { spriteEffects = SpriteEffects.FlipHorizontally; } // Next, check the events CheckEvents(); // Only update the animation for the current state updateCurrentAnimation(dt); }
protected override void updateWhenAlive(float dt) { // First, get the behavior if (enemy.Behavior.Compare(WalkerBehavior.Walking)) { currentAnimation = walkAnimation; } else if (enemy.Behavior.Compare(WalkerBehavior.Running)) { currentAnimation = runAnimation; } else if (enemy.Behavior.Compare(WalkerBehavior.Idle)) { currentAnimation = idleAnimation; } else { currentAnimation = idleAnimation; } // Check which eyes to use if (enemy.Vision.EnemySeesPlayer || enemy.Behavior.Compare(WalkerBehavior.Running)) { currentEyesFrame = eyesBigFrame; } else if (enemy.Behavior.Compare(WalkerBehavior.Walking)) { currentEyesFrame = eyesForwardFrame; } else { currentEyesFrame = eyesIdleFrame; } // Check if he's falling if (enemy.IsFalling()) { currentAnimation = fallAnimation; currentEyesFrame = eyesDownFrame; } else { fallAnimation.Reset(); } // Check if he's been hit if (enemy.Health.Hit) { currentAnimation = hitAnimation; currentEyesFrame = eyesSadFrame; } else { hitAnimation.Reset(); } // Check whether we should be facing left if (enemy.FacingRight) { spriteEffects = SpriteEffects.None; } else { spriteEffects = SpriteEffects.FlipHorizontally; } // Next, check the events CheckEvents(); // Only update the animation for the current state updateCurrentAnimation(dt); }