コード例 #1
0
ファイル: ChunkLocation.cs プロジェクト: Cyanch/Okroma
        public ChunkLocation(World2D world, int x, int y)
        {
            this.World = world;
            this.X     = x;
            this.Y     = y;

            this.AsPixel = new Point(x * World.Info.ChunkSize, y * World.Info.ChunkSize);
            this.AsTile  = new Point(x * World.Info.ChunkTileSpan, y * World.Info.ChunkTileSpan);
        }
コード例 #2
0
ファイル: TileLocation.cs プロジェクト: Cyanch/Okroma
        public TileLocation(int x, int y, int z, Chunk2D chunk, int chunkX, int chunkY)
        {
            this.X     = x;
            this.Y     = y;
            this.Z     = z;
            this.World = chunk.World;

            if (Chunk2D.IsValidChunkCoordinate(World, chunkX, chunkY))
            {
                this.AsLocalized = new Point(chunkX, chunkY);
            }
            else
            {
                var chunkPoint = World.ChunkPointFromTileLocation(x, y);
                chunk            = World.GetChunk(chunkPoint.X, chunkPoint.Y);
                this.AsLocalized = new Point(X - chunk.Location.AsTile.X, Y - chunk.Location.AsTile.Y);
            }
            this.Chunk = chunk;

            this.AsPixel = new Point(X * World.Info.TileSize, Y * World.Info.TileSize);
        }
コード例 #3
0
ファイル: Chunk2D.cs プロジェクト: Cyanch/Okroma
 public static bool IsValidChunkCoordinate(World2D world, int x, int y)
 {
     return(0 <= x && x < world.Info.ChunkTileSpan &&
            0 <= y && y < world.Info.ChunkTileSpan);
 }