Exemple #1
0
        /// <summary>
        /// Sets the tile at (x, y).
        /// </summary>
        /// <param name="x">X coordinate of the tile to set.</param>
        /// <param name="y">Y coordinate of the tile to set.</param>
        /// <param name="t">The tile to set (x, y) to.</param>
        /// <returns>If the tile was able to be changed.</returns>
        public bool SetTileAt(int x, int y, Tile t)
        {
            if (!this.IsInRange(x, y))
                return false;

            tileGrid[x, y] = t;
            return true;
        }
 public static void AddTextureForTile(Tile t)
 {
     TileTextures.Add(t.Name, Content.Load<Texture2D>(texturePath + t.GetFileName()));
 }
 public static Texture2D GetTileTexture(Tile t)
 {
     return GetTileTexture(t.Name);
 }
Exemple #4
0
        /// <summary>
        /// Used to set a square area to the same tile.
        /// </summary>
        /// <param name="x">Starting X coordinate.</param>
        /// <param name="y">Starting Y coordinate.</param>
        /// <param name="width">Width of area to be set.</param>
        /// <param name="height">Height of area to be set.</param>
        /// <param name="t">The tile to set the area to.</param>
        /// <returns>If the starting coordinates (x,y) were inside of the grid.</returns>
        public bool SetTileAtRange(int x, int y, int width, int height, Tile t)
        {
            for (int i = x; i <= width; i++)
                for (int j = y; j <= height; j++)
                    this.SetTileAt(i, j, t);

            if (this.IsInRange(x, y))
                return true;

            return false;
        }
Exemple #5
0
        /// <summary>
        /// Used to change a single tile.
        /// </summary>
        /// <param name="x">X coordinate of the tile to be changed.</param>
        /// <param name="y">Y coordinate of the tile to be changed.</param>
        /// <param name="t">The tile to change to.</param>
        /// <returns>If the tile was inside the grid and successfully changed.</returns>
        public bool SetTileAt(int x, int y, Tile t)
        {
            if (this.IsInRange(x, y))
            {
                Vector2 chunk = GetChunkForTileAt(x, y);
                Vector2 dist = GetDistanceFromChunkEdge(x, y);
                chunkGrid[(int)chunk.X, (int)chunk.Y].SetTileAt((int)dist.X, (int)dist.Y, t);
                return true;
            }

            return false;
        }
Exemple #6
0
 /// <summary>
 /// Constructor used to create a new map completely filled with one Tile.
 /// </summary>
 /// <param name="width">Width of the TileMap.</param>
 /// <param name="height">Height of the TileMap.</param>
 /// <param name="t">The tile to fill the map with.</param>
 public TileMap(int width, int height, Tile t)
 {
     this.ChunkWidth = width;
     this.ChunkHeight = height;
     this.Width = width * 20;
     this.Height = height * 20;
     chunkGrid = new Chunk[width, height];
     this.initalizeChunkGrid();
     (new FullMapGenerator(t)).Generate(this);
 }
 /// <summary>
 /// Sets the tile to generate with.
 /// </summary>
 public FullMapGenerator(Tile t)
 {
     this.TileToGenerate = t;
 }
 public static void AddTile(Tile t)
 {
     if (AddedTiles.Contains(t))
         throw new RMTEException(String.Format("You cannot add the same tile ({0}) twice to the TileDirectory.", t));
 }