//------------------------------------------------------------------------------ // 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); }
//------------------------------------------------------------------------------ // Method: LoadContent // Author: nholmes // Summary: load everything needed for the main game //------------------------------------------------------------------------------ public override void LoadContent() { // load the background texture backgroundTexture = content.Load<Texture2D>(@"game\background\background"); foregroundTexture = content.Load<Texture2D>(@"game\background\foreground"); // create the shadow system and cause it to load shadowSystem = new ShadowSystem(); shadowSystem.LoadContent(content); // initialise the players - note that while the players are standard game objects we do NOT // add them to the game object managers list of managed objects but instead update them manually // this is to ensure that the player can be processed before any other objects etc playerOne = new Player(game, gameObjectManager, displayManager, new Vector2(128, 128), PlayerIndex.One, shadowSystem, 1); playerTwo = new Player(game, gameObjectManager, displayManager, new Vector2(256, 128), PlayerIndex.Two, shadowSystem, 2); // load the players content (this is normally handled by the game object manager - but see above) playerOne.LoadContent(content); playerTwo.LoadContent(content); // create a random number generator for the bugs Random random = new Random(); // create some bugs! for (int i = 0; i < 50; i++) { gameObjectManager.AddObject(new GreenBug(game, gameObjectManager, displayManager, new Vector2(-128 - (i * 64) - random.Next(16), 345 + random.Next(64)), shadowSystem, random)); } // once the load has finished, we must tell the timer system that we have // finished a very long frame, so it does not try to catch up timerSystem.ResetElapsedTime(); }
//------------------------------------------------------------------------------ // 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 :) }