/// <summary> /// Constructor method that passes the turret model and the position to the /// parent BasicModel class. Also takes in a bullet model that this turret /// will fire. /// </summary> /// <param name="m"></param> /// <param name="position"></param> /// <param name="bullet"></param> public Turret(Model m, Vector3 position, Model bullet, WorldModelManager worldModelManager, float range, float maxHealth, float maxDamage, Texture2D healthBarTexture, SpriteBatch spriteBatch, Tile builtOnTile) : base(m, position, maxHealth, maxDamage, healthBarTexture, spriteBatch, builtOnTile) { this.bullet = bullet; lastFired = 0; this.range = range; FaceEnemy(null); //Debug.WriteLine("Turret created at X: " + position.X + " Y: " + position.Y + " Z: " + position.Z); Initiate(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { spriteBatch = new SpriteBatch(GraphicsDevice); camera = new Camera(this, new Vector3(0, 1000, 1000), Vector3.Zero, Vector3.Up); Components.Add(camera); grid = new Grid(Vector3.Zero, WORLD_BOUNDS_WIDTH, WORLD_BOUNDS_HEIGHT, this); Debug.WriteLine(grid.ToString()); worldModelManager = new WorldModelManager(this, graphics, grid); Components.Add(worldModelManager); player = new Player(this); prevMouseState = Mouse.GetState(); enemiesKilled = 0; currentWave = new Wave(1, 500); timeMinutes = 0; timeMilliseconds = 0; towerHealthDanger = false; turretDestroyedSound = Content.Load <SoundEffect>(@"Sound\explosion"); cannonFire = Content.Load <SoundEffect>(@"Sound\cannonFire"); enemyDeath = Content.Load <SoundEffect>(@"Sound\enemyDeath"); siren = Content.Load <SoundEffect>(@"Sound\siren"); towerScream = Content.Load <SoundEffect>(@"Sound\towerScream"); backgroundMusic = Content.Load <Song>(@"Sound\backgroundMusic"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(backgroundMusic); sirenInstance = siren.CreateInstance(); base.Initialize(); }