public override void OnCollision(Entity e, SoundEngine soundEngine) { Type type = e.GetType(); if (type == typeof(Enemy)) { health--; bleeding = true; shaking = true; soundEngine.PlaySound("mario shrink"); } }
public override void Update(GameTime gameTime, InputManager input, Map map, Camera camera, EntityManager entityManager, SoundEngine soundEngine) { base.Update(gameTime, input, map, camera, entityManager, soundEngine); moveAnimation.IsActive = true; syncTilePosition = true; if (direction == 1) { moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 0); velocity.X = moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } else if (direction == 2) { moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 1); velocity.X = -moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (ActivateGravity) velocity.Y += gravity * (float)gameTime.ElapsedGameTime.TotalSeconds; else velocity.Y = 0; position += velocity; if (direction == 1 && position.X >= destPosition.X) { direction = 2; destPosition.X = origPosition.X - range; } else if (direction == 2 && position.X <= destPosition.X) { direction = 1; destPosition.X = origPosition.X + range; } ssAnimation.Update(gameTime, ref moveAnimation); moveAnimation.Position = position; if (gameTime.TotalGameTime - previousEnemySoundTime > enemySoundTime) { soundEngine.PlaySound("zombie moan", this.position); // Update the time left next enemy spawn previousEnemySoundTime = gameTime.TotalGameTime; var soundSeconds = random.Next(5, 8); // random should be a member of the class enemySoundTime = TimeSpan.FromSeconds(soundSeconds); } }