Beispiel #1
0
        public void populateWithGrid(ContentManager content)
        {
            Texture2D texture = content.Load<Texture2D>("Env\\Dev\\devTileSheet");

            Vector2 tilePosition = new Vector2(0, 0);
            Rectangle source;

            for (int i = 0; i < Size.Y; i++)
            {
                tilePosition.X = 0;

                for (int j = 0; j < Size.X; j++)
                {
                    source = new Rectangle(0, 0, 32, 32);

                    Tile tempTile = new Tile(texture, source, true, true);
                    tempTile.setPosition(tilePosition);

                    tilePosition.X += 32;

                    TilesLayerGrid.Add(tempTile);
                }

                tilePosition.Y += 32;
            }
        }
Beispiel #2
0
        // Method that returns a Tile in a specific location on the tilesheet
        public Tile getTile(int x, int y)
        {
            Tile tile;

            if (!(x > (SheetWidth / TileSize) || y > (SheetHeight / TileSize)))
            {
                SourceRectangle = new Rectangle((x * TileSize), (y * TileSize), TileSize, TileSize);

                tile = new Tile(Texture, SourceRectangle, true, false);

                return tile;
            }
            else
                return null;
        }
Beispiel #3
0
        public void placeTile(Tile tile, Vector2 position, int layer)
        {
            Tile tempTile = tile;

            switch (layer)
            {
                case 1:
                    if (CurrentTileOne < (Size.X * Size.Y))
                    {
                        if (!positionCheck(position, TilesLayerOne))
                        {
                            TilesLayerOne.Add(tempTile);

                            CurrentTileOne++;
                        }
                    }
                    break;
                case 2:
                    if (CurrentTileTwo < (Size.X * Size.Y))
                    {
                        if (!positionCheck(position, TilesLayerTwo))
                        {
                            TilesLayerTwo.Add(tempTile);

                            CurrentTileTwo++;
                        }
                    }
                    break;
                case 3:
                    if (CurrentTileThree < (Size.X * Size.Y))
                    {
                        if (!positionCheck(position, TilesLayerThree))
                        {
                            TilesLayerThree.Add(tempTile);

                            CurrentTileThree++;
                        }
                    }
                    break;
            }
        }