Example #1
0
 /// <summary>
 /// Generate all the chunks in a radius around the given position.
 /// </summary>
 /// <param name="pPosition"></param>
 private void GenerateChunks(IVector2 pPosition)
 {
     for (int x = -generateRadius; x <= generateRadius; x++)
     {
         for (int y = -generateRadius; y <= generateRadius; y++)
         {
             if (!IsGenerated(pPosition.Clone().Add(new IVector2(x, y))))
             {
                 chunks.Add(new IVector2(x, y), new Chunk(tileWidth, tileHeight));
             }
         }
     }
 }
Example #2
0
 /// <summary>
 /// Get the chunk at the given position.
 /// </summary>
 /// <param name="pPosition"></param>
 /// <returns></returns>
 public Chunk GetChunkAt(IVector2 pPosition)
 {
     return(chunks[pPosition]);
 }
Example #3
0
 /// <summary>
 /// return true if the given chunk is generated.
 /// </summary>
 /// <param name="pPosition"></param>
 /// <returns></returns>
 public bool IsGenerated(IVector2 pPosition)
 {
     return(chunks.ContainsKey(pPosition));
 }
Example #4
0
 public Map(IVector2 pPosition, int pGenerateRadius = 2)
 {
     generateRadius = pGenerateRadius;
     GenerateChunks(pPosition ?? IVector2.zero);
 }
Example #5
0
 /// <summary>
 /// Move the player to the given chunk and position.
 /// </summary>
 /// <param name="pX"></param>
 /// <param name="pY"></param>
 /// <param name="pChunkX"></param>
 /// <param name="pChunkY"></param>
 public void MoveTo(int pX, int pY, IVector2 pTargetChunk)
 {
     tilePosition = new IVector2(pX, pY);
     mapPosition  = pTargetChunk;
 }
Example #6
0
 /// <summary>
 /// Move the player to the given tile.
 /// </summary>
 /// <param name="pX"></param>
 /// <param name="pY"></param>
 public void MoveTo(int pX, int pY)
 {
     tilePosition = new IVector2(pX, pY);
 }
Example #7
0
 /// <summary>
 /// Move the player to the given tile.
 /// </summary>
 /// <param name="pX"></param>
 /// <param name="pY"></param>
 public void MoveTo(IVector2 pTargetTile)
 {
     tilePosition = pTargetTile;
 }
Example #8
0
 /// <summary>
 /// Move the player to the given chunk and position.
 /// </summary>
 /// <param name="pX"></param>
 /// <param name="pY"></param>
 /// <param name="pChunkX"></param>
 /// <param name="pChunkY"></param>
 public void MoveTo(IVector2 pTargetTile, IVector2 pTargetChunk)
 {
     tilePosition = pTargetTile;
     mapPosition  = pTargetChunk;
 }
Example #9
0
 public IVector2 Subtract(IVector2 pVec)
 {
     _x -= pVec.x;
     _z -= pVec.z;
     return(this);
 }
Example #10
0
 public IVector2 Add(IVector2 pVec)
 {
     _x += pVec.x;
     _z += pVec.z;
     return(this);
 }
Example #11
0
 /// <summary>
 /// Get the tile at the given location.
 /// </summary>
 /// <param name="pPosition"></param>
 /// <returns></returns>
 public Tile GetTileAt(IVector2 pPosition)
 {
     return(tiles[pPosition]);
 }