当前位置: 首页>>代码示例>>C#>>正文


C# Room.InitCenterSize方法代码示例

本文整理汇总了C#中Room.InitCenterSize方法的典型用法代码示例。如果您正苦于以下问题:C# Room.InitCenterSize方法的具体用法?C# Room.InitCenterSize怎么用?C# Room.InitCenterSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Room的用法示例。


在下文中一共展示了Room.InitCenterSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IncrementGeneration

    protected void IncrementGeneration(DungeonEnvironmentGenerationData data, Dictionary<Vector2i, Vector2i> wallDirMapping = null)
    {
        Vector2i[] keys = wallDirMapping.Keys.ToArray();

        // make a corridor
        Vector2i corridorStart = keys[Random.Range(0, keys.Length - 1)];
        Vector2i dir = wallDirMapping[corridorStart];
        Vector2i corridorEnd = corridorStart + dir * Random.Range(0, data.mMaxCorridorLength);
        Room corridor = new Room();
        corridor.InitMinMax(corridorStart, corridorEnd);

        //Debug.DrawLine(GetTilePosition(corridorStart.mX, corridorStart.mY) + Vector3.up, GetTilePosition(corridorEnd.mX, corridorEnd.mY) + Vector3.up, Color.red, 10.0f);

        if (CanPlaceRoom(corridor))
        {
            PlaceRoom(corridor, true);
            GetWalls(corridor, wallDirMapping);

            // make a room to the end of it
            int roomWidth = Random.Range(data.mMinRoomDimensions.mX, data.mMaxRoomDimensions.mX);
            int halfRoomWidth = roomWidth / 2;
            int roomHeight = Random.Range(data.mMinRoomDimensions.mY, data.mMaxRoomDimensions.mY);
            int halfRoomHeight = roomHeight / 2;
            Room room = new Room();
            room.InitCenterSize(corridorEnd.mX, corridorEnd.mY, roomWidth, roomHeight);
            if (dir.mY != 0) // vertical
            {
                room.ShiftBy(dir * (halfRoomHeight + 1));
                room.ShiftBy(new Vector2i(Random.Range(-halfRoomWidth, halfRoomWidth), 0));
            }
            else // horizontal
            {
                room.ShiftBy(dir * (halfRoomWidth + 1));
                room.ShiftBy(new Vector2i(0, Random.Range(-halfRoomHeight, halfRoomHeight)));
            }

            if (CanPlaceRoom(room))
            {
                PlaceRoom(room);
                GetWalls(room, wallDirMapping);
            }

            wallDirMapping.Remove(corridorStart);
            if (dir.mY != 0) // vertical
            {
                wallDirMapping.Remove(corridorStart + Vector2i.kLeft);
                wallDirMapping.Remove(corridorStart + Vector2i.kRight);
            }
            else
            {
                wallDirMapping.Remove(corridorStart + Vector2i.kUp);
                wallDirMapping.Remove(corridorStart + Vector2i.kDown);
            }
        }
    }
开发者ID:stregawolf,项目名称:VDayJam2016,代码行数:55,代码来源:Dungeon.cs

示例2: GenerateRooms

    public void GenerateRooms(DungeonEnvironmentGenerationData data)
    {
        mRooms.Clear();
        
        if(data.mUseSeed)
        {
            mSeed = data.mSeed;
        }
        else
        {
            mSeed = Random.seed;
        }
        Random.seed = mSeed;
        openWalls.Clear();

        if (data.mRandomizeInitialRoomPosition)
        {
            int halfInitialRoomWidth = data.mInitialRoomSize.mX/2;
            int halfInitialRoomHeight = data.mInitialRoomSize.mY/2;
            mInitialRoomPosition.mX = Random.Range(halfInitialRoomWidth+1, data.mTotalDimensions.mX - halfInitialRoomWidth-1);
            mInitialRoomPosition.mY = Random.Range(halfInitialRoomHeight+1, data.mTotalDimensions.mY - halfInitialRoomHeight-1);
        }
        else
        {
            mInitialRoomPosition = data.mInitialRoomPosition;
        }
        Room initialRoom = new Room();
        initialRoom.InitCenterSize(mInitialRoomPosition.mX, mInitialRoomPosition.mY, data.mInitialRoomSize.mX, data.mInitialRoomSize.mY);

        PlaceRoom(initialRoom);
        GetWalls(initialRoom, openWalls);

        int attempts = 0;
        while (attempts < mMaxGenerationAttempts && openWalls.Count > 0)
        {
            IncrementGeneration(data, openWalls);
            ++attempts;
        }
    }
开发者ID:stregawolf,项目名称:VDayJam2016,代码行数:39,代码来源:Dungeon.cs


注:本文中的Room.InitCenterSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。