/// <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); // create 1x1 texture for line drawing _line = new Texture2D(GraphicsDevice, 1, 1); _line.SetData <Color>( new Color[] { Color.White });// fill the texture with white FileStream tempstream; Slide tmpSlide, keepSlide; SlideShow tmpSlideShow; SlideShowMachine tmpSlideShowMachine; int tmpIndex; tempstream = new FileStream("battlecity_tank.png", FileMode.Open); tmpIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); tmpSlide = new Slide(); tmpSlide.SetTextureIndex(tmpIndex); tmpSlide.SetOrigin(new Vector2(7.5f, 7.5f)); tmpSlide.SetBoundingArea(new BoundingArea(new Vector2(1, 1), new Vector2(13, 13), new Vector2(6.5f, 6.5f))); tmpSlideShow = new SlideShow(new List <Slide>()); tmpSlideShow.AddSlide(tmpSlide); tmpSlideShowMachine = new SlideShowMachine(new Dictionary <int, SlideShow>()); tmpSlideShowMachine.AddSlideShow(SlideShowMachine.SLIDESHOW_RIGHT, tmpSlideShow); _myPlayer.SetSlideShowMachine(tmpSlideShowMachine); tempstream = new FileStream("battlecity_tank2.png", FileMode.Open); tmpIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); tmpSlide = new Slide(); tmpSlide.SetTextureIndex(tmpIndex); tmpSlide.SetOrigin(new Vector2(7.5f, 7.5f)); var a = _alltextures.GetTextureFromIndex(tmpIndex).Bounds; tmpSlide.SetBoundingArea(new BoundingArea(new Vector2(1, 1), new Vector2(13, 13), new Vector2(6.5f, 6.5f))); tmpSlideShow = new SlideShow(new List <Slide>()); tmpSlideShow.AddSlide(tmpSlide); tmpSlideShowMachine = new SlideShowMachine(new Dictionary <int, SlideShow>()); tmpSlideShowMachine.AddSlideShow(SlideShowMachine.SLIDESHOW_RIGHT, tmpSlideShow); _theirPlayer.SetSlideShowMachine(tmpSlideShowMachine); tempstream = new FileStream("battlecity_shot.png", FileMode.Open); tmpIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); tmpSlide = new Slide(); tmpSlide.SetTextureIndex(tmpIndex); tmpSlide.SetOrigin(new Vector2(7.5f, 7.5f)); tmpSlide.SetBoundingArea(new BoundingArea(new Vector2(6, 6), new Vector2(4, 3), new Vector2(2, 1.5f))); tmpSlideShow = new SlideShow(new List <Slide>()); tmpSlideShow.AddSlide(tmpSlide); tmpSlideShowMachine = new SlideShowMachine(new Dictionary <int, SlideShow>()); tmpSlideShowMachine.AddSlideShow(SlideShowMachine.SLIDESHOW_RIGHT, tmpSlideShow); _projectileSpawner.SetSlideShowMachine(tmpSlideShowMachine); tempstream = new FileStream("battlecity_explosion1.png", FileMode.Open); tmpIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); tmpSlide = new Slide(); tmpSlide.SetTextureIndex(tmpIndex); tmpSlide.SetOrigin(new Vector2(7.5f, 7.5f)); tmpSlide.SetDisplayTime(0.2f); tmpSlideShow = new SlideShow(new List <Slide>()); tmpSlideShow.AddSlide(tmpSlide); keepSlide = tmpSlide; tempstream = new FileStream("battlecity_explosion2.png", FileMode.Open); tmpIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); tmpSlide = new Slide(); tmpSlide.SetTextureIndex(tmpIndex); tmpSlide.SetOrigin(new Vector2(7.5f, 7.5f)); tmpSlide.SetDisplayTime(0.2f); tmpSlideShow.AddSlide(tmpSlide); tmpSlideShow.AddSlide(keepSlide); tmpSlideShowMachine = new SlideShowMachine(new Dictionary <int, SlideShow>()); tmpSlideShowMachine.AddSlideShow(SlideShowMachine.SLIDESHOW_RIGHT, tmpSlideShow); _explosionSpawner.SetSlideShowMachine(tmpSlideShowMachine); tempstream = new FileStream("battlecity_tile_asphalt.png", FileMode.Open); int tileAsphaltIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); tempstream = new FileStream("battlecity_tile_brick.png", FileMode.Open); int tileBrickIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); tempstream = new FileStream("battlecity_tile_metal.png", FileMode.Open); int tileMetalIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); tempstream = new FileStream("battlecity_tile_tree.png", FileMode.Open); int tileTreeIndex = _alltextures.AddReturningIndex(Texture2D.FromStream(GraphicsDevice, tempstream)); tempstream.Close(); //TODO: En lista över Tiles som finns, //skapa sen kartan från kopior av dessa (eller samma Tile, jag vet inte om de ändras) Random rnd = new Random(); _mapUnder = new Map(MAP_WIDTH, MAP_HEIGHT, TILE_WIDTH, TILE_HEIGHT); _mapOver = new Map(MAP_WIDTH, MAP_HEIGHT, TILE_WIDTH, TILE_HEIGHT); Tile currentTile; for (int y = 0; y < MAP_HEIGHT; y++) { for (int x = 0; x < MAP_WIDTH; x++) { currentTile = new Tile(); currentTile.SetBoundingArea(new BoundingArea(new Vector2(x * TILE_WIDTH, y * TILE_HEIGHT), new Vector2(TILE_WIDTH, TILE_HEIGHT), new Vector2(0, 0))); int rndVal = rnd.Next(100); //sätt asfalt där spelarna spawnar if (x <= 4 && y <= 4) { rndVal = 0; } if (rndVal > 96) { currentTile.SetTextureIndex(tileMetalIndex); currentTile.SetIsBlocked(true); } else if (rndVal > 89) { currentTile.SetTextureIndex(tileBrickIndex); currentTile.SetTextureIndexDestroyed(tileAsphaltIndex); currentTile.SetIsBlocked(true); //if (rndVal > 95) // currentTile.SetLeftDownDestroyed(true); //if (rndVal > 94) // currentTile.SetLeftUpDestroyed(true); //if (rndVal > 93) // currentTile.SetRightDownDestroyed(true); //if (rndVal > 92) // currentTile.SetRightUpDestroyed(true); } else { currentTile.SetTextureIndex(tileAsphaltIndex); if (rndVal > 50) { Tile topTile = new Tile(); topTile.SetTextureIndex(tileTreeIndex); _mapOver.SetTileAtPosition(x, y, topTile); } } _mapUnder.SetTileAtPosition(x, y, currentTile); } //TODO: Kolla att det är ett tomt område (eller sätt asfalt där) _myPlayer.SetPos(new Vector2(16f, 20f)); _theirPlayer.SetPos(new Vector2(32f, 20f)); } }
public Texture2D GetTextureFromList(TextureList textureList) { return(textureList.GetTextureFromIndex(_textureIndex)); }
public Texture2D GetTextureDestroyedFromList(TextureList textureList) { return(textureList.GetTextureFromIndex(_textureIndexDestroyed)); }