Time for action – Shot classes
To implement the shots that the enemy and the player will fire at each other, perform the following steps:
1. Add a new class file called
PlayerShot.cs
to theMars Runner
project.2. Add the following
using
directives to thePlayerShot
class:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
3. Modify the declaration of the
PlayerShot
class to inherit from theGameEntity
class. The new declaration should read as follows:class PlayerShot : GameEntity
4. Add fields to the
PlayerShot
class as follows:#region Fields private Vector3 velocity = new Vector3(0, 30, 0); public bool IsActive; #endregion
5. Add a constructor to the
PlayerShot
class as follows:#region Constructor public PlayerShot( GraphicsDevice device, Model model, Vector3 position) : base(device, model, position) { scale = 0.25f; IsActive = true; } #endregion
6. Add the
ResetShot()
method to thePlayerShot
class as follows:#region Helper Methods public void...