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


C# Vector4.ZW方法代码示例

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


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

示例1: CarveRoom

        public static bool CarveRoom(Dungeon dungeon, Corridor corridor, Vector4 brushSizeVariation, Vector2 maxRoomSize, int maxBrushStrokes, out Room room)
        {
            Vector2 startingPosition = corridor ? corridor.Bounds.max : Vector2.zero;
            Vector2 corridorDirection = corridor ? corridor.Direction : Vector2.zero;
            Vector2 minBrushSize = brushSizeVariation.XY();
            Vector2 maxBrushSize = brushSizeVariation.ZW();

            Rect brush = new Rect(startingPosition, Vector2.zero);

            //move the room one up or to the left so it aligns properly to the corridor
            brush.x -= corridorDirection.y;
            brush.y -= corridorDirection.x;

            room = Room.CreateInstance(brush.position, Dungeon.Random);

            if (brush.x < 0 || brush.y < 0
                || !AdjustCoordinate(corridorDirection, minBrushSize, dungeon.Size, ref brush))
            {
                return false;
            }

            bool enoughSpaceForRoom = !dungeon.OverlapsCorridor(brush.position, minBrushSize);

            while (!corridorDirection.IsZero()
                    && !enoughSpaceForRoom //if the room is currently intersecting a corridor
                    && ((corridorDirection.y != 0 && brush.x >= 0 && brush.x + minBrushSize.x - 1 > room.Bounds.x)  //and it can be moved to the left (orUp)
                    || (corridorDirection.x != 0 && brush.y >= 0 && brush.y + minBrushSize.y - 1 > room.Bounds.y))) //while still being attached to the corridor
            {
                //move the room and check again
                brush.x -= corridorDirection.y;
                brush.y -= corridorDirection.x;
                enoughSpaceForRoom = !dungeon.OverlapsCorridor(brush.position, minBrushSize);//!dungeon.SearchInArea(pos, minSize, CellType.corridor);
            }

            if (!enoughSpaceForRoom) //if a room with the minimum size possible would still intersect a corridor, stop trying to make it
                return false;

            brush.x = Mathf.Clamp(brush.x, 0, dungeon.Width);
            brush.y = Mathf.Clamp(brush.y, 0, dungeon.Height);

            bool roomCarved = false;
            //mark cells at random locations within the room, until the maximum tries is reached
            for (int tries = 0; tries < maxBrushStrokes; tries++)
            {

                if (CreateBrush(
                    minBrushSize,
                    maxBrushSize,
                    startingPosition,
                    corridorDirection,
                    dungeon,
                    room,
                    ref brush))
                {
                    if (!brush.size.IsZero())
                    {
                        if (!dungeon.OverlapsCorridor(brush.position, brush.size))
                        {
                            if (AddCells(brush, dungeon, room) > 0)
                                roomCarved = true;
                        }
                    }
                }
                MoveBrush(dungeon, startingPosition, corridorDirection, room, minBrushSize, maxBrushSize, ref brush);
            }

            if (room.Position.x < 0 || room.Position.y < 0)
                throw new ArgumentOutOfRangeException("Room was carved outside of dungeon!\n" + room);

            return roomCarved;
        }
开发者ID:LuciusSixPercent,项目名称:Finsternis,代码行数:71,代码来源:RoomFactory.cs


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