示例#1
0
    public static Vector2Int AddRoom(this Dictionary <Vector2Int, OpenDoors> grid, Vector2Int position, Room.PlayerExit direction)
    {
        if (!grid.ContainsKey(position))
        {
            OpenDoors doors = new OpenDoors();
            doors.OpenDoor(direction);
            grid.Add(position, doors);
        }
        else
        {
            var doors = grid[position];
            doors.OpenDoor(direction);
            grid[position] = doors;
        }

        var newPosition       = position + GetAddition(direction);
        var oppositeDirection = direction.GetOppositeExit();

        if (!grid.ContainsKey(newPosition))
        {
            OpenDoors newDoors = new OpenDoors(oppositeDirection);
            grid.Add(newPosition, newDoors);
        }
        else
        {
            var doors = grid[newPosition];
            doors.OpenDoor(oppositeDirection);
            grid[newPosition] = doors;
        }

        //Debug.Log("" + position + ": " + direction + ": " + newPosition);
        return(newPosition);
    }
示例#2
0
    public static List <Room.PlayerExit> GetMeaningfulExits(this Room.PlayerExit exit)
    {
        List <Room.PlayerExit> toReturn = new List <Room.PlayerExit>();
        var opposite = exit.GetOppositeExit();

        foreach (var temp in (Room.PlayerExit[])Enum.GetValues(typeof(Room.PlayerExit)))
        {
            if (temp != opposite)
            {
                toReturn.Add(temp);
            }
        }

        return(toReturn);
    }