-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to get children and parent tiles.
- Loading branch information
Showing
3 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections; | ||
|
||
namespace TilesMath; | ||
|
||
public struct TileChildren : IEnumerable<Tile> | ||
{ | ||
private readonly int _x; | ||
private readonly int _y; | ||
private readonly int _z; | ||
|
||
internal TileChildren(Tile tile) | ||
{ | ||
_x = tile.X * 2; | ||
_y = tile.Y * 2; | ||
_z = tile.Zoom + 1; | ||
} | ||
|
||
|
||
public IEnumerator<Tile> GetEnumerator() | ||
{ | ||
yield return Tile.Create(_x, _y, _z); | ||
yield return Tile.Create(_x + 1, _y, _z); | ||
yield return Tile.Create(_x + 1, _y + 1, _z); | ||
yield return Tile.Create(_x, _y + 1, _z); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return GetEnumerator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters