Esempio n. 1
0
    void ActiveDoors(RoomNode room, GameObject level)
    {
        GameObject plane = level.transform.GetChild(0).gameObject;

        string[] directions = new string[4]
        {
            "N", "S", "E", "W",
        };
        int[] ids = new int[4]
        {
            room.room_id_north_, room.room_id_south_, room.room_id_east_, room.room_id_west_
        };

        for (int i = 0; i < 4; ++i)
        {
            bool dir_active = ids[i] == 0;
            plane.transform.Find(directions[i] + "Wall").gameObject.SetActive(dir_active);

            GameObject door = plane.transform.Find(directions[i] + "Door").gameObject;
            door.SetActive(!dir_active);

            int key_value = 0;
            if (room.direction_locked != null && room.direction_locked.TryGetValue((CardinalDirection)i, out key_value))
            {
                door.transform.GetChild(0).gameObject.GetComponent <DoorBehaviour>().RequiredKey =
                    (PickableObject.KeyNumber)key_value;
                //if(corridor_by_dir[i] != null)
                //    corridor_by_dir[i].transform.GetChild(0).Find("SDoor").GetChild(0).gameObject.GetComponent<DoorBehaviour>().RequiredKey =
                //        (PickableObject.KeyNumber)key_value;
            }
            //else
            //{
            //    if (corridor_by_dir[i] != null)
            //        corridor_by_dir[i].transform.GetChild(0).GetChild(0).GetChild(0).gameObject.GetComponent<DoorBehaviour>().RequiredKey =
            //            PickableObject.KeyNumber.kKeyNumberNone;
            //}


            if (door.transform.childCount > 0)
            {
                door.transform.GetChild(0).gameObject.SetActive(current_room_.id() == ids[i]);
            }
        }
    }
Esempio n. 2
0
 public void ConE(ref RoomNode room)
 {
     room_id_east_ = room.id(); room.room_id_west_ = id();
 }
Esempio n. 3
0
 public void ConS(ref RoomNode room)
 {
     room_id_south_ = room.id(); room.room_id_north_ = id();
 }
Esempio n. 4
0
    void LoadNextLevel()
    {
        load_next_level = false;

        List <int>     next_ids           = new List <int>();
        List <Vector3> relative_positions = new List <Vector3>();

        for (int i = 0; i < 4; ++i)
        {
            corridor_by_dir[i] = null;
        }

        GameObject corridor = null;

        if (current_room_.room_id_north_ != 0 && current_room_.room_id_north_ != previous_room_.id())
        {
            next_ids.Add(current_room_.room_id_north_);
            relative_positions.Add(new Vector3(0.0f, 0.0f, room_size));

            corridor = GetUnusedCorridor();
            if (corridor != null)
            {
                corridor.transform.position = current_level.transform.position + new Vector3(0.0f, 0.0f, 1.0f) * room_size;
                corridor.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
                corridor_by_dir[0]          = corridor;
            }
        }
        if (current_room_.room_id_south_ != 0 && current_room_.room_id_south_ != previous_room_.id())
        {
            next_ids.Add(current_room_.room_id_south_);
            relative_positions.Add(new Vector3(0.0f, 0.0f, -room_size));

            corridor = GetUnusedCorridor();
            if (corridor != null)
            {
                corridor.transform.position = current_level.transform.position + new Vector3(0.0f, 0.0f, -1.0f) * room_size;
                corridor.transform.rotation = Quaternion.Euler(0.0f, 180.0f, 0.0f);
                corridor_by_dir[1]          = corridor;
            }
        }
        if (current_room_.room_id_east_ != 0 && current_room_.room_id_east_ != previous_room_.id())
        {
            next_ids.Add(current_room_.room_id_east_);
            relative_positions.Add(new Vector3(room_size, 0.0f, 0.0f));

            corridor = GetUnusedCorridor();
            if (corridor != null)
            {
                corridor.transform.position = current_level.transform.position + new Vector3(1.0f, 0.0f, 0.0f) * room_size;
                corridor.transform.rotation = Quaternion.Euler(0.0f, 90.0f, 0.0f);
                corridor_by_dir[2]          = corridor;
            }
        }
        if (current_room_.room_id_west_ != 0 && current_room_.room_id_west_ != previous_room_.id())
        {
            next_ids.Add(current_room_.room_id_west_);
            relative_positions.Add(new Vector3(-room_size, 0.0f, 0.0f));

            corridor = GetUnusedCorridor();
            if (corridor != null)
            {
                corridor.transform.position = current_level.transform.position + new Vector3(-1.0f, 0.0f, 0.0f) * room_size;
                corridor.transform.rotation = Quaternion.Euler(0.0f, -90.0f, 0.0f);
                corridor_by_dir[3]          = corridor;
            }
        }



        int counter = 0;

        foreach (int id in next_ids)
        {
            RoomNode next_room_;

            next_room_ = FindRoom(id);
            if (next_room_.id() == 0)
            {
                continue;
            }
            prefab_next_level = next_room_.room_prefab_;

            GameObject new_level = InstantiateCustomLevel(prefab_next_level, relative_positions[counter]);
            ActiveDoors(next_room_, new_level);

            next_rooms_.Add(next_room_);
            next_levels.Add(new_level);

            counter++;
        }

        StartSpawn();
        should_open_doors = true;

        return;
    }