public bool Compare(Procedural_Room it)
    {
        bool ret = false;

        if (it._x_pos == _x_pos && it._y_pos == _y_pos && it._tilewidth == _tilewidth && it._tileheight == _tileheight)
        {
            ret = true;
        }

        return(ret);
    }
    // Use this for initialization
    void Start()
    {
        //DrawMapWithTiles();
        realDepth = maxim_depth / 3;

        rooms   = new List <Procedural_Room>();
        myDoors = new List <GameObject>();

        Procedural_Room room_temp = new Procedural_Room(0, 0, tilesWidthRoom, tilesHeightRoom, count_rooms, ExitDirection.NONE_DIR, 0);

        rooms.Add(room_temp);
        //room_temp.DrawRoom();

        GenerateRoomLastChildFirst(room_temp, 0);

        foreach (Procedural_Room testRoom in rooms)
        {
            if (testRoom != null)
            {
                testRoom.SetColliders();
                testRoom.SetDoors();

                testRoom.InitializeRoomRunTimeValues();

                testRoom.DrawRoom();

                if (testRoom.GetLevelDepth() > 0 || _FirstShadowNot)
                {
                    if (!testRoom._wantBoss && !testRoom._wantMiniBoss)
                    {
                        Vector3    posShadow = testRoom.GetStarterRoom();
                        GameObject goShadow  = Instantiate(shadowRoom, testRoom.Room_Go.transform);
                        goShadow.transform.localPosition = posShadow + goShadow.transform.localPosition;
                    }
                    else
                    {
                        Vector3    posShadow = testRoom.GetStarterRoom();
                        GameObject goShadow  = Instantiate(shadowRoomBoss, testRoom.Room_Go.transform);
                        goShadow.transform.localPosition = posShadow + goShadow.transform.localPosition;
                    }
                }
                else
                {
                    _FirstShadowNot = true;
                }
            }
        }

        StartCoroutine(FloorTextShowingRoutine());
    }
    int FindInRooms(Procedural_Room myRoom)
    {
        int it = -1;

        for (int i = 0; i < rooms.Count; i++)
        {
            if (rooms[i].Compare(myRoom))
            {
                it = i;
                break;
            }
        }

        return(it);
    }
    public Procedural_Room GetRoomByPoint(Vector3 point)
    {
        Procedural_Room roomRet = null;
        bool            ret     = false;

        foreach (Procedural_Room room_temp in rooms)
        {
            if (room_temp != null)
            {
                ret = room_temp.IsInsideRoom(point);
                if (ret)
                {
                    roomRet = room_temp;
                    break;
                }
            }
        }
        return(roomRet);
    }
    void GenerateRoomLastChildFirst(Procedural_Room room, int level)
    {
        Procedural_Room    creation_room;
        ExitDirectionPoint creation_point = new ExitDirectionPoint();

        count_rooms++;

        if (level + 1 == realDepth && !_AddBoss && _counterBoss == 0)
        {
            _AddBoss = true;
        }
        else if (level == realDepth * 0.5 && !_AddMiniBoss && _counterMiniBoss == 0)
        {
            _AddMiniBoss = true;
        }


        if (level == realDepth)
        {
            Vector3    posUpgrade = room.GetMiddlePositionRoom();
            GameObject go         = Instantiate(UpgradeObject);
            go.transform.position = posUpgrade;

            int it = FindInRooms(room);
            if (rooms[it].usableExits.Count > 0)
            {
                rooms[it].usableExits[0].isUsed = true;
            }
            return;
        }

        for (int i = 0; i < room.usableExits.Count; i++)
        {
            creation_point = room.usableExits[i];

            bool wantToCreate = creation_point.needRoomCreation;
            if (!wantToCreate)
            {
                int it = FindInRooms(room);
                rooms[it].usableExits[i].isUsed = true;
            }

            if (creation_point.needRoomCreation && !PointIsInsideAnyRoom(creation_point.nextRoomPos))
            {
                int it = FindInRooms(room);
                rooms[it].usableExits[i].isUsed = true;

                if (_AddBoss)
                {
                    _counterBoss++;
                }
                else if (_AddMiniBoss)
                {
                    _counterMiniBoss++;
                }

                creation_room = new Procedural_Room(creation_point.nextRoomPos.x, creation_point.nextRoomPos.y, tilesWidthRoom, tilesHeightRoom, count_rooms, OppositeDirection(creation_point.dir), level, _AddBoss, _AddMiniBoss);

                _AddBoss     = false;
                _AddMiniBoss = false;

                if (creation_room.wantToDraw)
                {
                    rooms.Add(creation_room);
                    GenerateRoomLastChildFirst(creation_room, level + 1);
                }
            }
        }
    }