Beispiel #1
0
    bool ForcedRoom(CellDoor door)
    {
        var room = new NewRoom();

        Debug.Log("tengo " + NewRoomGenerator.instancia.forcerooms.Count + " forced rooms");
        Debug.Log("El current es: " + NewRoomGenerator.instancia.currentCantRooms);

        GameObject trygo = NewRoomGenerator.instancia.forcerooms[NewRoomGenerator.instancia.currentCantRooms - 1];

        if (NewRoomGenerator.instancia.currentCantRooms == NewRoomGenerator.instancia.MaxRooms)
        {
            room = SpawnAndGet(NewRoomGenerator.instancia.lastRoom);
        }
        else
        {
            room = SpawnAndGet(trygo);
        }

        int index = 0;

        if (ComprobarLugarDeSpawn(door, room, ref index))
        {
            vecinos.Add(room);
            NewRoomGenerator.instancia.AddRangesFromRoom(room);
            SetOcuppiedDoor(door.index);
            room.doormanager.doors[index].Occuppied = true;
            room.gameObject.name = "Room_" + NewRoomGenerator.instancia.currentCantRooms.ToString("00");
            NewRoomGenerator.instancia.currentCantRooms++;
            NewRoomGenerator.instancia.listrooms.Add(room);
            room.CreateNewRoom(this);
            return(true);
        }
        else
        {
            Destroy(room.gameObject);
            return(false);
        }
    }
Beispiel #2
0
    bool RandomRoom(CellDoor door)
    {
        foreach (var s in NewRoomGenerator.instancia.samples)
        {
            if (NewRoomGenerator.instancia.currentCantRooms == s.IndexToAppear)
            {
                s.weight = 0;
            }
        }

        var stackrooms = NewRoomGenerator.instancia.GetStackOffRooms();

        // RECORRO LAS ROOMS

        while (stackrooms.Count > 0)
        {
            var  room   = new NewRoom();
            bool last   = false;
            var  sample = stackrooms.Pop();

            if (NewRoomGenerator.instancia.currentCantRooms == NewRoomGenerator.instancia.MaxRooms - 1)
            {
                room = SpawnAndGet(NewRoomGenerator.instancia.lastRoom);
                last = true;
            }
            else
            {
                room = SpawnAndGet(sample.model);
            }

            int index = 0;

            if (ComprobarLugarDeSpawn(door, room, ref index))
            {
                vecinos.Add(room);
                NewRoomGenerator.instancia.AddRangesFromRoom(room);

                SetOcuppiedDoor(door.index);
                room.doormanager.doors[index].Occuppied = true;

                room.gameObject.name = "Room_" + NewRoomGenerator.instancia.currentCantRooms.ToString("00");


                NewRoomGenerator.instancia.currentCantRooms++;

                NewRoomGenerator.instancia.listrooms.Add(room);

                if (!last)
                {
                    NewRoomGenerator.instancia.samples[sample.originalIndex].weight++;

                    if (sample.one_per_dungeon)
                    {
                        sample.weight = int.MaxValue;
                    }
                }


                room.CreateNewRoom(this);

                return(true);
            }
            else
            {
                Destroy(room.gameObject);
                continue;
            }
        }
        return(false);
    }