protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(base.Game.GraphicsDevice); // Populate your tiles list with your textures here //Tiles = new List<Texture2D>(); Texture2D tmp = base.Game.Content.Load<Texture2D>(@"CityMap\Cubes\cubo_terra"); //Tiles.Add(tmp); selectionTexture = base.Game.Content.Load<Texture2D>(@"CityMap\selection_maior"); //cuboSemLinha = this.content.Load<Texture2D>("cubosemlinha"); pequenaCasa = base.Game.Content.Load<Texture2D>(@"CityMap\pequena_casa"); //grandeCasa = base.Game.Content.Load<Texture2D>(@"Buildings\casa_grande"); grandeCasa = base.Game.Content.Load<Texture2D>(@"Buildings\quartel_2x2"); House3x3 = base.Game.Content.Load<Texture2D>(@"Buildings\casa3x3"); spriteFont = base.Game.Content.Load<SpriteFont>(@"SpriteFont"); //testeHouse = new TinyHouse(pequenaCasa); // Initialise block 2D array Blocks = new DrawableCityBlock[Width, Height]; // Used as a base width and height for varying sized tiles CityBlock.BaseWidth = tmp.Width; CityBlock.BaseHeight = tmp.Height / 2; Rectangle position = new Rectangle(0, 0, tmp.Width, tmp.Height); for (int x = 0; x < Width; x++) { position.X = (CityBlock.BaseWidth / 2) * x; position.Y = (CityBlock.BaseHeight / 2) * x; for (int y = 0; y < Height; y++) { Blocks[x, y] = new DrawableCityBlock(new CityBlock(position, new Point(x,y))); Blocks[x, y].Coordinates = x + "," + y; position.Y += (CityBlock.BaseHeight / 2); position.X += -(CityBlock.BaseWidth / 2); } } CalculateCityEdges(); base.LoadContent(); }
public DrawableCityBlock[] GetCityBlocksIfAvailable(Point clicked, Point area) { int size = area.X * area.Y; int count = 0; DrawableCityBlock[] tmpBlocks = new DrawableCityBlock[size]; //retorna null se a area for maior que 1 e se a estrutura for sair fora do mapa if ((area.X > 1) && ((clicked.X + area.X > Width) || (clicked.Y + area.Y > this.Height))) { return null; } else if (area.X == 1 && area.Y == 1) { tmpBlocks[size - 1] = Blocks[clicked.X, clicked.Y]; return tmpBlocks; } for (int x = clicked.X; x < clicked.X + area.X; x++) for (int y = clicked.Y; y < clicked.Y + area.Y; y++) if (Blocks[x, y].IsBuildable) { tmpBlocks[count++] = Blocks[x, y]; } return Utils.IsAllValuesNotNull(tmpBlocks) ? tmpBlocks : null; }