protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); Texture2D grass = Content.Load<Texture2D>("grass"); Texture2D path = Content.Load<Texture2D>("path"); level.AddTexture(grass); level.AddTexture(path); enemyTexture[0] = Content.Load<Texture2D>("enemy"); enemyTexture[1]=Content.Load<Texture2D>("enemy2"); // enemyHealth [0]= ; //enemyHealth [1]= ; arial = Content.Load<SpriteFont>("Arial"); lucida = Content.Load<SpriteFont>("Lucida"); Texture2D towerTexture = Content.Load<Texture2D>("tower"); Texture2D bulletTexture = Content.Load<Texture2D>("bullet"); bulletSound = Content.Load<SoundEffect>("gunShot"); player = new Player(level, towerTexture, bulletTexture,Content); // waveManager = new WaveManager(player, level, 30, enemyTexture); waveManager = new WaveManager(player, level, 30, enemyTexture, enemyHealth); SpriteFont font = Content.Load<SpriteFont>("Arial"); Texture2D topBar = Content.Load<Texture2D>("toolbar"); toolbar = new Toolbar(topBar, font, new Vector2(0, level.Height * 32)); Texture2D arrowNormal = Content.Load<Texture2D>("GUI\\Arrow Tower\\arrow normal"); Texture2D arrowHover = Content.Load<Texture2D>("GUI\\Arrow Tower\\arrow hover"); Texture2D arrowPressed = Content.Load<Texture2D>("GUI\\Arrow Tower\\arrow pressed"); arrowButton = new Button(arrowNormal, arrowHover, arrowPressed, new Vector2(0, level.Height * 32)); arrowButton.Clicked += new EventHandler(arrowButton_Clicked); Texture2D pausetexture = Content.Load<Texture2D>("pause"); Texture2D playtexture = Content.Load<Texture2D>("play"); button1=new Button1(pausetexture, playtexture, new Vector2(35, level.Height * 32 + 3)); }
public void Update(GameTime gameTime, List<Enemy> enemies) { mouseState = Mouse.GetState(); cellX = (int)(mouseState.X / 32); cellY = (int)(mouseState.Y / 32); tileX = cellX * 32; tileY = cellY * 32; if (mouseState.LeftButton == ButtonState.Released && oldState.LeftButton == ButtonState.Pressed) { if (string.IsNullOrEmpty(newTowerType) == false) { AddTower(); } else { if (selectedTower != null) { if (!selectedTower.Bounds.Contains(mouseState.X, mouseState.Y)) { selectedTower.Selected = false; } } foreach (Tower tower in towers) { if (tower==selectedTower) { continue; } if (tower.Bounds.Contains(mouseState.X, mouseState.Y)) { selectedTower = tower; tower.Selected = true; buttonVisible = true; upgradeButton = new Button(upgradeTexture, new Vector2(32,level.Height*32 -32)); } } } } foreach (Tower tower in towers) { if (tower.Target == null) { tower.GetClosestEnemy(enemies); } tower.Update(gameTime); } oldState = mouseState; }