示例#1
0
    //finds the closest rooms from groupA and groupB
    private Room[] findClosestRoom(RoomGroup groupA, RoomGroup groupB)
    {
        Room[] returnRoom      = new Room[2];
        float  closestDistance = float.MaxValue;

        for (int i = 1; i < groupA.getCount(); i++)
        {
            for (int j = 0; j < groupB.getCount(); j++)
            {
                float euclideanDistance = EuclideanDist(groupA.GetRoom(i), groupB.GetRoom(j));
                if (euclideanDistance < closestDistance)
                {
                    returnRoom [0]  = groupA.GetRoom(i);
                    returnRoom [1]  = groupB.GetRoom(j);
                    closestDistance = euclideanDistance;
                }
            }
        }
        return(returnRoom);
    }
示例#2
0
    //joins two groups together with a coridoor
    private void JoinGroups(RoomGroup groupA, RoomGroup groupB)
    {
        Room[] closestRooms    = new Room[2];
        float  closestDistance = float.MaxValue;

        for (int i = 1; i < groupA.getCount(); i++)
        {
            for (int j = 0; j < groupB.getCount(); j++)
            {
                float euclideanDistance = EuclideanDist(groupA.GetRoom(i), groupB.GetRoom(j));
                if (euclideanDistance < closestDistance)
                {
                    closestRooms [0] = groupA.GetRoom(i);
                    closestRooms [1] = groupB.GetRoom(j);
                    closestDistance  = euclideanDistance;
                }
            }
        }
        if (!SpawnCoridoor(closestRooms[0], closestRooms[1], true, true))
        {
            spawnFailed = true;
        }
    }