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


C# Door.decrement方法代码示例

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


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

示例1: placeMultiDoorRoom

    /*
     * Method for placing random rooms
     * Randomly picks entrance and primary exit
     * If !willCollide(), is placed
     * If any unused doors remain, stores them in unusedDoors queue
     * @param origin: vector3 position that tracks where an object is spawned.
     * @param room: room to be placed
     * */
    private void placeMultiDoorRoom(Prefab room, Door door)
    {
        door.decrement(); //door has been consumed now
        int numDoors = room.numDoors(); //number of doors IN THIS ROOM ONLY
        int doorsToQueue = numDoors - 1; //number of open doors
        int entInt = (int)Random.Range(0, numDoors - 1); //pick an entrance from room
        Quaternion[] exits = new Quaternion[doorsToQueue];
        int[] distribute = split(door.getNum(), doorsToQueue);

        Vector3 center = door.getPos() + (CELL_SIZE * door.getFace()); //move spawn point from door to center of next room
        Transform placedRoom = Instantiate(room.getTransform(), center, Quaternion.identity) as Transform; //spawn the room in normal orientation
        currentRoomsPlaced += 1;
        Vector3 entrance = room.getDoor(entInt) * placedRoom.forward; //get vector pointing at the door we want to connect with the connecting door
        placedRoom.forward = Quaternion.FromToRotation(entrance, -door.getFace()) * placedRoom.forward; //rotate transform so that proper door is lined up.
        placedRoom.transform.localScale = new Vector3(scale, 1, scale);
        placeLight(center);

        //Debug.Log("Center for this room will be " + center);
        if (placedRoom.up != Vector3.up) //ensures everything is upright (some bug somewhere is flipping random rooms upsidedown)
        {
            placedRoom.up = Quaternion.FromToRotation(placedRoom.up, Vector3.up) * placedRoom.up;
        }

        //Debug.Log("There are " + (doorsToQueue) + " doors to add");
        for (int i = 1; i < numDoors; i++)
        {
            exits[mod(i, doorsToQueue)] = room.getDoor(mod(entInt + i, numDoors));
        }
        for (int i = 0; i < doorsToQueue; i++)
        {
            int doorSplit = distribute[0]; //this door's share of the rooms
            Vector3 facing = exits[i] * placedRoom.forward; //gets a door that is NOT the entrance
            Vector3 position = center + (facing * CELL_SIZE);
            unusedDoors.Enqueue(new Door(position, facing, doorSplit));
           // Debug.Log("Added door at position " + position + " that is facing " + facing + " to queue");

        }
    }
开发者ID:mattgor123,项目名称:CS355-Robo-Clean-5000,代码行数:46,代码来源:Dungeon.cs


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