public void placeTurret(int rows, int cols, TurretType type) { switch (type) { case TurretType.Turret: if (bank.Purchase(100)) { structures[rows, cols] = new BasicTurret(new Vector2( (int)((screenWidth / 2) - (4.5 - cols) * sideLength), (int)((screenHeight / 2) - (4.5 - rows) * sideLength)), turretTexture, bulletTexture, groundTexture, healthBar, sideLength, rows, cols, this, bank); } break; case TurretType.Wall: if (bank.Purchase(50)) { structures[rows, cols] = new Wall(new Vector2( (int)((screenWidth / 2) - (4.5 - cols) * sideLength), (int)((screenHeight / 2) - (4.5 - rows) * sideLength)), wallTexture, groundTexture, healthBar, bank, this, sideLength, rows, cols); } break; } }
private void Load(string filePath) { Stream inStream = File.OpenRead(filePath); BinaryReader input = new BinaryReader(inStream); int height = input.ReadInt32(); int width = input.ReadInt32(); //set enemy health to input.ReadInt32() //set enemy damage to input.ReadInt32() //set turret health to input.ReadInt32() //set enemy damage to input.ReadInt32() //set main structure health to input.ReadInt32() structures = new Structure[height, width]; sideLength = (int)((screenHeight / height) * 0.8); for (int r = 0; r < height; r++) { for (int c = 0; c < width; c++) { switch (input.ReadInt32()) { case 0: structures[r, c] = new EmptyTile(new Vector2( (int)((screenWidth / 2) - (4.5 - c) * sideLength), (int)((screenHeight / 2) - (4.5 - r) * sideLength)), groundTexture, bank, this, r, c, sideLength, true); break; case 1: structures[r, c] = new BasicTurret(new Vector2( (int)((screenWidth / 2) - (4.5 - c) * sideLength), (int)((screenHeight / 2) - (4.5 - r) * sideLength)), turretTexture, bulletTexture, groundTexture, healthBar, sideLength, r, c, this, bank); break; case 2: if (mainStructure == null) { mainStructure = new MainStructure(new Vector2( (int)((screenWidth / 2) - (4 - c) * sideLength), (int)((screenHeight / 2) - (4 - r) * sideLength)), mainStructureTexture, groundTexture, healthBar, sideLength * 2); structures[r, c] = mainStructure; } break; case 3: structures[r, c] = new Wall(new Vector2( (int)((screenWidth / 2) - (4.5 - c) * sideLength), (int)((screenHeight / 2) - (4.5 - r) * sideLength)), wallTexture, groundTexture, healthBar, bank, this, sideLength, r, c); break; } } } }