using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace BouncyCatIsBouncy { class Heater : IDynamicObject { Animation m_animation; SpriteBatch m_batch; Vector2 m_position; bool m_isVisible; public Heater(SpriteBatch batch, PhysicsBody body) { m_batch = batch; body.OnCollision += (unused) => OnCollision(); m_position = body.Position; } private void OnCollision() { m_animation.Animating = true; m_isVisible = true; } public void Update(float dt) { m_animation.Update(dt); } public void Draw() { if (m_isVisible) m_animation.Draw(); } public void LoadContent(ContentManager manager) { var sheet = manager.Load(@"Spritesheets/heater"); m_animation = new Animation(m_batch, sheet, 256, 256); m_animation.Animating = true; m_animation.Center = m_position; m_animation.Speed = 250.0f; m_animation.Rotation = -.3f; } } }