#region File Description //----------------------------------------------------------------------------- // RocketPowerUp.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; #endregion namespace NetRumble { /// /// A power-up that gives a player a rocket-launching weapon. /// public class RocketPowerUp : PowerUp { #region Static Graphics Data /// /// Texture for the rocket power-up. /// private static Texture2D texture; #endregion #region Initialization Methods /// /// Constructs a new rocket-launcher power-up. /// public RocketPowerUp() : base() { } #endregion #region Drawing Methods /// /// Draw the rocket power-up. /// /// The amount of elapsed time, in seconds. /// The SpriteBatch object used to draw. public override void Draw(float elapsedTime, SpriteBatch spriteBatch) { // ignore the parameter color if we have an owner base.Draw(elapsedTime, spriteBatch, texture, null, Color.White); } #endregion #region Interaction Methods /// /// Defines the interaction between this power-up and a target GameplayObject /// when they touch. /// /// The GameplayObject that is touching this one. /// True if the objects meaningfully interacted. public override bool Touch(GameplayObject target) { // if we hit a ship, give it the weapon Ship ship = target as Ship; if (ship != null) { ship.Weapon = new RocketWeapon(ship); } return base.Touch(target); } #endregion #region Static Graphics Methods /// /// Load all of the static graphics content for this class. /// /// The content manager to load with. public static void LoadContent(ContentManager contentManager) { // safety-check the parameters if (contentManager == null) { throw new ArgumentNullException("contentManager"); } // load the texture texture = contentManager.Load("Textures/powerupRocket"); } /// /// Unload all of the static graphics content for this class. /// public static void UnloadContent() { texture = null; } #endregion } }