//------------------------------------------------------------------------------ // Constructor: MainGame // Author: nholmes // Summary: Default constructor //------------------------------------------------------------------------------ public MainGame(Game game, PlayerIndex? controllingPlayer) : base(game, controllingPlayer) { // store reference to global ContentManager content = new ContentManager(game.Services, @"Content\"); // Create gameObjectManager gameObjectManager = new GameObject2DManager(game, content); // set the world position to 0,0 - this game doesnt scroll so this will never change :) worldPosition.X = 0; worldPosition.Y = 0; }
//------------------------------------------------------------------------------ // Constructor: Enemy // Author: Neil Holmes & Andrew Green // Summary: Constructor - prepares the player for use //------------------------------------------------------------------------------ public Enemy(Game game, GameObject2DManager gameObjectManager, DisplayManager displayManager, Vector2 position, ShadowSystem shadowSystem, Random random) : base(game, gameObjectManager, displayManager, position, properties) { // store a reference to the shadow system this.shadowSystem = shadowSystem; // create a random number generator this.random = random; // create the player's state manager stateManager = new GameObjectStateManager(game); // set direction to right Velocity = new Vector2(4, 0); }
//------------------------------------------------------------------------------ // Constructor: GreenBug // Author: Neil Holmes & Andrew Green // Summary: Constructor - prepares the player for use //------------------------------------------------------------------------------ public GreenBug(Game game, GameObject2DManager gameObjectManager, DisplayManager displayManager, Vector2 position, ShadowSystem shadowSystem, Random random) : base(game, gameObjectManager, displayManager, position, shadowSystem, random) { // nothing special to do here :) }
//------------------------------------------------------------------------------ // Constructor: GameObject2D // Author: Neil Holmes & Andrew Green // Summary: default constructor - initialises a 2D game object ready for use //------------------------------------------------------------------------------ public GameObject2D(Game game, GameObject2DManager gameObjectManager, DisplayManager displayManager, Vector2 position, GameObject2DProperties properties) { // Store reference to parent game system object this.game = game; // Store reference to owning gameObjectManager this.gameObjectManager = gameObjectManager; // store reference to the display manager this.displayManager = displayManager; // get the game input manager service inputManager = (InputManager)game.Services.GetService(typeof(InputManager)); // get the game input manager service timerSystem = (TimerSystem)game.Services.GetService(typeof(TimerSystem)); // set the type of this game object type = properties.type; // store whether the object should always be updated alwaysUpdate = properties.alwaysUpdate; // store the update range for this object updateRange = properties.updateRange; // store the position this.position = position; // set initial velocity to zero velocity = new Vector2(0, 0); // create the master list for the animation frames animationFrames = new List<List<Texture2D>>(); // set some default values for current animation frame and animation speed defaultAnimationSpeed = 10; animationSpeed = 0; // default to showing no animation at all currentAnimation = -1; // set the current animation frame index to zero currentAnimFrame = 0; // set the texture frame flip X and & to false by default textureFrameFlipX = false; textureFrameFlipY = false; // set the texture frame rotation to zero by defaul textureFrameRotation = 0; // store the display offset and size displayOffset = properties.displayOffset; displaySize = properties.displaySize; // set the rotation offset based on the display size rotationOffset = displaySize * 0.5f; // store the collision offset and size collisionOffset = properties.collisionOffset; collisionSize = properties.collisionSize; }