/// <summary> /// Constructs the Enemy controller with the appropriate values /// </summary> /// <param name="nrToSpawn"></param> /// <param name="nrOfWaves"></param> /// <param name="level"></param> /// <param name="graphicsDevice"></param> /// <param name="player"></param> /// <param name="game1"></param> /// <param name="mapInUse"></param> public EnemyController(int nrToSpawn, int nrOfWaves, Level level, GraphicsDevice graphicsDevice, Player player, Game1 game1, int mapInUse) { this.nrOfWaves = nrOfWaves; this.nrToSpawn = nrToSpawn; isFirstWave = true; timerWaves = 0; timerEnemys = 0; this.level = level; this.player = player; this.graphicsDevice = graphicsDevice; this.game1 = game1; startFirstWave = 5; timerAfterFirstWave = 15; spawnNewEnemys = false; countWaves = 1; countEnemys = 0; enemyBounty = 1; enemySpeed = 2; enemyLife = 15; enemySpawnTime = 1f; timerEnemys = 1; enemy1 = ContentConverter.Convert(contentPath + "enemy1.png", graphicsDevice); enemy2 = ContentConverter.Convert(contentPath + "enemy2.png", graphicsDevice); enemy3 = ContentConverter.Convert(contentPath + "enemy3.png", graphicsDevice); enemy4 = ContentConverter.Convert(contentPath + "enemy4.png", graphicsDevice); enemyTexture = enemy1; spawnPosition = level.Waypoints.ElementAt <Vector2>(0); mapChangeIndicator = mapInUse; }
public UserInterface(GraphicsDevice graphicsDevice, Player player) { this.player = player; number0 = ContentConverter.Convert(rootPath + "number0.png", graphicsDevice); number1 = ContentConverter.Convert(rootPath + "number1.png", graphicsDevice); number2 = ContentConverter.Convert(rootPath + "number2.png", graphicsDevice); number3 = ContentConverter.Convert(rootPath + "number3.png", graphicsDevice); number4 = ContentConverter.Convert(rootPath + "number4.png", graphicsDevice); number5 = ContentConverter.Convert(rootPath + "number5.png", graphicsDevice); number6 = ContentConverter.Convert(rootPath + "number6.png", graphicsDevice); number7 = ContentConverter.Convert(rootPath + "number7.png", graphicsDevice); number8 = ContentConverter.Convert(rootPath + "number8.png", graphicsDevice); number9 = ContentConverter.Convert(rootPath + "number9.png", graphicsDevice); currencySymbol = ContentConverter.Convert(rootPath + "currencySymbol.png", graphicsDevice); heartSymbol = ContentConverter.Convert(rootPath + "heart.png", graphicsDevice); onesDisplay = tensDisplay = hundredsDisplay = thousandsDisplay = number0; onesDispayLives = tensDisplayLives = number0; posThousands = new Vector2(number0.Width, 0); posHundreds = new Vector2(number0.Width / 2, 0) + posThousands; posTens = new Vector2(number0.Width / 2, 0) + posHundreds; posOnes = new Vector2(number0.Width / 2, 0) + posTens; posCurrency = new Vector2(number0.Width / 2, 0) + posOnes; posHeart = new Vector2(1920 - number0.Width, 0); posOnesLives = posHeart - new Vector2(number0.Width, 0); posTensLives = posOnesLives - new Vector2(number0.Width / 2, 0); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); mainMenuBackground = ContentConverter.Convert("Content/Assets/Menu/Background.jpg", GraphicsDevice); mainMenuStartButton = ContentConverter.Convert("Content/Assets/Menu/PlayButton.png", GraphicsDevice); mainMenuQuitButton = ContentConverter.Convert("Content/Assets/Menu/QuitButton.png", GraphicsDevice); mainMenuButton = ContentConverter.Convert("Content/Assets/Menu/MainMenuButton.png", GraphicsDevice); endGameBackground = ContentConverter.Convert("Content/Assets/Menu/EndGameBackground.png", GraphicsDevice); mainMenu = new MainMenu(mainMenuBackground, mainMenuStartButton, mainMenuQuitButton); }
/// <summary> /// Constructs a Doubleshot Tower end sets all needed values /// </summary> /// <param name="texture"></param> /// <param name="positionX"></param> /// <param name="positionY"></param> /// <param name="player"></param> /// <param name="graphicsDevice"></param> public DoubleShotTower(Texture2D texture, float positionX, float positionY, Player player, GraphicsDevice graphicsDevice) { damage = 15; hasSplash = false; price = 10; range = 200; reloadTime = 1; position.X = positionX + texture.Width / 2; position.Y = positionY + texture.Height / 2; towerTexture = texture; rotationCenter = new Vector2(texture.Width / 2, texture.Height / 2); player.money -= (int)price; projectileTexture = ContentConverter.Convert("Content/Assets/TD/Projectiles/bullet.png", graphicsDevice); explosionTexture = ContentConverter.Convert("Content/Assets/TD/Projectiles/explosionNormal.png", graphicsDevice); this.player = player; projectileSpeed = 20; }
/// <summary> /// Constructs a RocketLauncher Tower end sets all needed values /// </summary> /// <param name="texture"></param> /// <param name="positionX"></param> /// <param name="positionY"></param> /// <param name="player"></param> /// <param name="graphicsDevice"></param> public RocketLauncherTower(Texture2D texture, float positionX, float positionY, Player player, GraphicsDevice graphicsDevice) { damage = 30; hasSplash = true; price = 20; range = 300; reloadTime = 3; position.X = positionX + texture.Width / 2; position.Y = positionY + texture.Height / 2; towerTexture = texture; rotationCenter = new Vector2(texture.Width / 2, texture.Height / 2); player.money -= (int)price; this.player = player; projectileTexture = ContentConverter.Convert("Content/Assets/TD/Projectiles/missile.png", graphicsDevice); explosionTexture = ContentConverter.Convert("Content/Assets/TD/Projectiles/explosionRocket.png", graphicsDevice); projectileSpeed = 8; }
/// <summary> /// Constructor that creates all the needed Sprites and Buttons /// </summary> /// <param name="game"></param> /// <param name="graphicsDevice"></param> public PauseMenu(Game1 game, GraphicsDevice graphicsDevice) { this.game = game; resumeButtonTexture = ContentConverter.Convert("Content/Assets/Menu/ContinueButton.png", graphicsDevice); quitButtonTexture = ContentConverter.Convert("Content/Assets/Menu/QuitButton.png", graphicsDevice); mainMenuButtonTexture = ContentConverter.Convert("Content/Assets/Menu/MainMenuButton.png", graphicsDevice); overlayTexture = ContentConverter.Convert("Content/Assets/Menu/PauseMenu.png", graphicsDevice); posOverlay = new Vector2(960 - overlayTexture.Width / 2, 540 - overlayTexture.Height / 2); overlayDimensions = new Rectangle(0, 0, overlayTexture.Width, overlayTexture.Height); posResumeButton = posOverlay + new Vector2(32, resumeButtonTexture.Height * 2); posMainMenuButton = posResumeButton + new Vector2(0, mainMenuButtonTexture.Height * 2); posQuitButton = posMainMenuButton + new Vector2(0, quitButtonTexture.Height * 2); resumeButton = new MenuButton("resumeButtonPause", resumeButtonTexture, (int)posResumeButton.X, (int)posResumeButton.Y); mainMenuButton = new MenuButton("mainMenuButtonPause", mainMenuButtonTexture, (int)posMainMenuButton.X, (int)posMainMenuButton.Y); quitButton = new MenuButton("quitButtonPause", quitButtonTexture, (int)posQuitButton.X, (int)posQuitButton.Y); }
/// <summary> /// Constructs a Slow Tower end sets all needed values /// </summary> /// <param name="texture"></param> /// <param name="positionX"></param> /// <param name="positionY"></param> /// <param name="player"></param> /// <param name="graphicsDevice"></param> public SlowTower(Texture2D texture, float positionX, float positionY, Player player, GraphicsDevice graphicsDevice) { damage = 5; hasSplash = true; price = 15; range = 300; reloadTime = 2; position.X = positionX + texture.Width / 2; position.Y = positionY + texture.Height / 2; towerTexture = texture; canSlow = true; speedModifier = 0.6f; modifierDuration = 2.0f; rotationCenter = new Vector2(texture.Width / 2, texture.Height / 2); player.money -= (int)price; projectileTexture = ContentConverter.Convert("Content/Assets/TD/Projectiles/slowProj.png", graphicsDevice); explosionTexture = ContentConverter.Convert("Content/Assets/TD/Projectiles/explosionSlow.png", graphicsDevice); projectileSpeed = 20; this.player = player; }
public UIButton(int buttonX, int buttonY, BuildButton buildButton, GraphicsDevice graphicsDevice, Player player, Level level) { this.buttonX = buttonX; this.buttonY = buttonY; this.buildButton = buildButton; this.player = player; this.level = level; this.graphicsDevice = graphicsDevice; centerPositionTower = new Vector2(buttonX, buttonY) + new Vector2(buildButton.Texture.Width / 2, buildButton.Texture.Height / 2); singleShotTexture = ContentConverter.Convert(singleShotPath, graphicsDevice); singleShotUITexture = ContentConverter.Convert(singleShotUIPath, graphicsDevice); doubleShotTexture = ContentConverter.Convert(doubleShotPath, graphicsDevice); doubleShotUITexture = ContentConverter.Convert(doubleShotUIPath, graphicsDevice); slowTexture = ContentConverter.Convert(slowPath, graphicsDevice); slowUITexture = ContentConverter.Convert(slowUIPath, graphicsDevice); rocketLauncherTexture = ContentConverter.Convert(rocketLauncherPath, graphicsDevice); rocketLauncherUITexture = ContentConverter.Convert(rocketLauncherUIPath, graphicsDevice); towerBuild = ContentConverter.Convert("Content/Assets/TD/UI/towerBuild.png", graphicsDevice); towerType = TowerTypes.Single; //texture = singleShotTexture; }
public Level(MapState mState, GraphicsDevice graphicsDevice, Game1 game1) { this.game1 = game1; this.graphicsDevice = graphicsDevice; // Create a list which contains the textures to load as map. tileTextures = new List <Texture2D>(); // Create lists which contain the towers, enemys and projectiles. towerList = new List <Towers>(); enemyList = new List <Enemys>(); projectileList = new List <Projectile>(); buildButtonList = new List <BuildButton>(); explosionList = new List <Explosion>(); player = new Player(graphicsDevice); ui = new UserInterface(graphicsDevice, player); inRangeCheck = new InRangeCheck(); isActive = true; buildButtonTexture = ContentConverter.Convert("Content/Assets/TD/UI/buildTower.png", graphicsDevice); #region Convert and load level textures // Level 1 background1 = ContentConverter.Convert(pathToLvl1Background, graphicsDevice); lvlWay1 = ContentConverter.Convert(pathToLvl1Way, graphicsDevice); lvlTile2 = ContentConverter.Convert(pathToLvlTile2, graphicsDevice); lvlTile3 = ContentConverter.Convert(pathToLvlTile3, graphicsDevice); lvlTile4 = ContentConverter.Convert(pathToLvlTile4, graphicsDevice); lvlTile5 = ContentConverter.Convert(pathToLvlTile5, graphicsDevice); lvlTile6 = ContentConverter.Convert(pathToLvlTile6, graphicsDevice); lvlTile7 = ContentConverter.Convert(pathToLvlTile7, graphicsDevice); lvlTile8 = ContentConverter.Convert(pathToLvlTile8, graphicsDevice); lvlTile9 = ContentConverter.Convert(pathToLvlTile9, graphicsDevice); // Level 2 background2 = ContentConverter.Convert(pathToLvl2Background, graphicsDevice); lvlWay2 = ContentConverter.Convert(pathToLvl2Way, graphicsDevice); lvlTile12 = ContentConverter.Convert(pathToLvlTile12, graphicsDevice); lvlTile13 = ContentConverter.Convert(pathToLvlTile13, graphicsDevice); lvlTile14 = ContentConverter.Convert(pathToLvlTile14, graphicsDevice); lvlTile15 = ContentConverter.Convert(pathToLvlTile15, graphicsDevice); lvlTile16 = ContentConverter.Convert(pathToLvlTile16, graphicsDevice); lvlTile17 = ContentConverter.Convert(pathToLvlTile17, graphicsDevice); lvlTile18 = ContentConverter.Convert(pathToLvlTile18, graphicsDevice); lvlTile19 = ContentConverter.Convert(pathToLvlTile19, graphicsDevice); // Level 3 background3 = ContentConverter.Convert(pathToLvl3Background, graphicsDevice); lvlWay3 = ContentConverter.Convert(pathToLvl3Way, graphicsDevice); lvlTile22 = ContentConverter.Convert(pathToLvlTile22, graphicsDevice); lvlTile23 = ContentConverter.Convert(pathToLvlTile23, graphicsDevice); lvlTile24 = ContentConverter.Convert(pathToLvlTile24, graphicsDevice); lvlTile25 = ContentConverter.Convert(pathToLvlTile25, graphicsDevice); lvlTile26 = ContentConverter.Convert(pathToLvlTile26, graphicsDevice); lvlTile27 = ContentConverter.Convert(pathToLvlTile27, graphicsDevice); lvlTile28 = ContentConverter.Convert(pathToLvlTile28, graphicsDevice); lvlTile29 = ContentConverter.Convert(pathToLvlTile29, graphicsDevice); // Oulines horOutline1 = ContentConverter.Convert(pathToHorOutline, graphicsDevice); verOutline1 = ContentConverter.Convert(pathToVerOutline, graphicsDevice); botRightCor = ContentConverter.Convert(pathToBottomRightCornerOutline, graphicsDevice); botLeftCor = ContentConverter.Convert(pathToBottomLeftCornerOutline, graphicsDevice); uppRightCor = ContentConverter.Convert(pathToUpperRightCornerOutline, graphicsDevice); uppLeftCor = ContentConverter.Convert(pathToUpperLeftCornerOutline, graphicsDevice); // Start-End start1 = ContentConverter.Convert(pathToStart, graphicsDevice); end1 = ContentConverter.Convert(pathToEnd, graphicsDevice); // UI Line uiLine = ContentConverter.Convert(pathToUiLine, graphicsDevice); #endregion #region Add loaded textures to textures list AddTexture(background1); AddTexture(lvlWay1); AddTexture(lvlTile2); AddTexture(lvlTile3); AddTexture(lvlTile4); AddTexture(lvlTile5); AddTexture(lvlTile6); AddTexture(lvlTile7); AddTexture(lvlTile8); AddTexture(lvlTile9); AddTexture(background2); AddTexture(lvlWay2); AddTexture(lvlTile12); AddTexture(lvlTile13); AddTexture(lvlTile14); AddTexture(lvlTile15); AddTexture(lvlTile16); AddTexture(lvlTile17); AddTexture(lvlTile18); AddTexture(lvlTile19); AddTexture(background3); AddTexture(lvlWay3); AddTexture(lvlTile22); AddTexture(lvlTile23); AddTexture(lvlTile24); AddTexture(lvlTile25); AddTexture(lvlTile26); AddTexture(lvlTile27); AddTexture(lvlTile28); AddTexture(lvlTile29); AddTexture(horOutline1); AddTexture(verOutline1); AddTexture(botRightCor); AddTexture(botLeftCor); AddTexture(uppRightCor); AddTexture(uppLeftCor); AddTexture(start1); AddTexture(end1); AddTexture(uiLine); #endregion #region Switch for changing the map. this.mState = mState; // Which map to use switch (mState) { case MapState.map1: mapToUse = map1; mapInUse = 1; buildButtonsToUse1(graphicsDevice); break; case MapState.map2: mapToUse = map2; mapInUse = 2; buildButtonsToUse2(graphicsDevice); break; case MapState.map3: mapToUse = map3; mapInUse = 3; buildButtonsToUse3(graphicsDevice); break; default: throw new Exception(String.Format("Unknown state: {0}", mState)); #endregion } #region EnemyWaypoints if (mState == MapState.map1) { // Waypoints waypoints.Enqueue(new Vector2(1, 4) * 64); waypoints.Enqueue(new Vector2(26, 4) * 64); waypoints.Enqueue(new Vector2(26, 13) * 64); waypoints.Enqueue(new Vector2(1, 13) * 64); } else if (mState == MapState.map2) { // Waypoints waypoints.Enqueue(new Vector2(1, 4) * 64); waypoints.Enqueue(new Vector2(7, 4) * 64); waypoints.Enqueue(new Vector2(7, 14) * 64); waypoints.Enqueue(new Vector2(22, 14) * 64); waypoints.Enqueue(new Vector2(22, 4) * 64); waypoints.Enqueue(new Vector2(28, 4) * 64); } else if (mState == MapState.map3) { // Waypoints waypoints.Enqueue(new Vector2(1, 4) * 64); waypoints.Enqueue(new Vector2(7, 4) * 64); waypoints.Enqueue(new Vector2(7, 14) * 64); waypoints.Enqueue(new Vector2(14, 14) * 64); waypoints.Enqueue(new Vector2(14, 4) * 64); waypoints.Enqueue(new Vector2(21, 4) * 64); waypoints.Enqueue(new Vector2(21, 14) * 64); waypoints.Enqueue(new Vector2(28, 14) * 64); } enemyController = new EnemyController(15, 10, this, graphicsDevice, player, game1, mapInUse); #endregion }