コード例 #1
0
ファイル: RoomGenerator.cs プロジェクト: Halloweens/RogueRpg
    private bool CanPlaceRoomAt(Vector2i position, Vector2i roomSize)
    {
        for (int j = 0; j < roomSize.y; j++)
        {
            for (int i = 0; i < roomSize.x; i++)
            {
                if (!grid.IsCoordValid(position.x + i, position.y + j) || grid.GetChunk(position.x + i, position.y + j) != null)
                {
                    return(false);
                }
            }
        }

        return(true);
    }
コード例 #2
0
ファイル: GeneratorChunk.cs プロジェクト: Halloweens/RogueRpg
    public GeneratorChunk GetNeighbor(GeneratorDirection dir)
    {
        Vector2i loc = location + GeneratorDirections.ToVector2i(dir);

        return(grid.GetChunk(loc.x, loc.y));
    }
コード例 #3
0
ファイル: WallGenerator.cs プロジェクト: Halloweens/RogueRpg
    public IEnumerator CreateRoomWalls()
    {
        foreach (GeneratorRoom room in grid.RoomList)
        {
            foreach (GeneratorChunk chunk in room.chunks)
            {
                Vector2i currPos = chunk.Location;

                Vector2i posUp      = grid.GetChunk(currPos.x, currPos.y).Location + GeneratorDirections.ToVector2i(GeneratorDirection.Up);
                Vector2i posDown    = grid.GetChunk(currPos.x, currPos.y).Location + GeneratorDirections.ToVector2i(GeneratorDirection.Down);
                Vector2i posOnRight = grid.GetChunk(currPos.x, currPos.y).Location + GeneratorDirections.ToVector2i(GeneratorDirection.Right);
                Vector2i posOnLeft  = grid.GetChunk(currPos.x, currPos.y).Location + GeneratorDirections.ToVector2i(GeneratorDirection.Left);

                CreateWall(posUp, currPos, "up");
                CreateWall(posDown, currPos, "down");
                CreateWall(posOnLeft, currPos, "left");
                CreateWall(posOnRight, currPos, "right");

                yield return(0);
            }
        }
    }