Example #1
0
    //Randomly selects and returns room template based on the shape of the room
    private GameObject SelectRoomTemplate(Room room)
    {
        GameObject[] choices = new GameObject[] { };

        if (room.IsBossRoom)
        {
            choices = boss;
        }
        else if (room.IsStartRoom)
        {
            choices = start;
        }
        else if (room.IsX())
        {
            choices = X;
        }
        else if (room.IsTVertical())
        {
            choices = verticalT;
        }
        else if (room.IsTHorizontal())
        {
            choices = horizontalT;
        }
        else if (room.IsL())
        {
            choices = L;
        }
        else if (room.IsIVertical())
        {
            choices = verticalI;
        }
        else if (room.IsIHorizontal())
        {
            choices = horizontalI;
        }
        else if (room.IsDEVertical())
        {
            choices = verticalDE;
        }
        else if (room.IsDEHorizontal())
        {
            choices = horizontalDE;
        }
        else
        {
            //This should never happen!
            Debug.LogFormat("This should not have happened.\n{0}", room.ToString());
            return(null);
        }

        //Random.InitState(room.Seed); //Initialize random generator with the room seed to select the same room type every time this room is visited
        //return choices[Random.Range(0, choices.Length)];

        qrand.InitState(room.Seed);
        return(choices[qrand.NextInt(choices.Length)]);
    }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        //Setup random generation with room seed
        //Random.InitState(this.room.Seed);
        qrand.InitState(this.room.Seed);


        //Instantiate outer structures: walls & doors
        CreateWalls();


        //Mirror the room layout when needed
        if (room.IsTVertical() && room.HasDoorUp)
        {
            //transform.GetChild(2).transform.localScale = new Vector3(1, -1, 1);
            mirror(false, true);
        }
        if (room.IsTHorizontal() && room.HasDoorRight)
        {
            //transform.GetChild(2).transform.localScale = new Vector3(-1, 1, 1);
            mirror(true, false);
        }
        if (room.IsL() && (room.HasDoorUp && room.HasDoorLeft))
        {
            //transform.GetChild(2).transform.localScale = new Vector3(-1, 1, 1);
            mirror(true, false);
        }
        if (room.IsL() && (room.HasDoorDown && room.HasDoorLeft))
        {
            //transform.GetChild(2).transform.localScale = new Vector3(-1, -1, 1);
            mirror(true, true);
        }
        if (room.IsL() && (room.HasDoorDown && room.HasDoorRight))
        {
            //transform.GetChild(2).transform.localScale = new Vector3(1, -1, 1);
            mirror(false, true);
        }
        if (room.IsDEHorizontal() && room.HasDoorRight)
        {
            //transform.GetChild(2).transform.localScale = new Vector3(-1, 1, 1);
            mirror(true, false);
        }
        if (room.IsDEVertical() && room.HasDoorDown)
        {
            //transform.GetChild(2).transform.localScale= new Vector3(1, -1, 1);
            mirror(false, true);
        }
    }