Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        _ground = GameObject.Find("Ground").GetComponent <Ground>();
        if (!_ground)
        {
            Debug.LogError("No Ground in Room");
        }
        _ceiling = GameObject.Find("Ceiling").GetComponent <Ceiling>();
        if (!_ceiling)
        {
            Debug.LogError("No Ceiling in Room");
        }
        _wall = GameObject.Find("Walls").GetComponent <Wall>();
        if (!_wall)
        {
            Debug.LogError("No Wall in Room");
        }
        _window = GameObject.Find("Windows").GetComponent <Window>();
        if (!_window)
        {
            Debug.LogError("No Window in Room");
        }
        _door = GameObject.Find("Doors").GetComponent <Door>();
        if (!_door)
        {
            Debug.LogError("No Door in Room");
        }
        _ground.AddGround();
        for (int wallIndex = 0; wallIndex < _outsideWallChance.Length; wallIndex++)
        {
            if (Random.Range(0, 1f) < _outsideWallChance[wallIndex])
            {
                _wall.SetOutsideWall(wallIndex, true);
            }
            else
            {
                _wall.SetOutsideWall(wallIndex, false);
            }
        }
        _wall.AddWalls();
        _ceiling.AddCeiling();;
        if (!CreateRoom())
        {
            Debug.LogError("Cannot initialise room");
            return;
        }

        PopulateRoom();
    }