예제 #1
0
    [SerializeField] private float bias; //How far from the centre should the connection point spawn the next room?

    public IEnumerator GenerateRoom()
    {
        int        generatedProb  = Random.Range(0, spawnRooms.Length);
        GameObject roomToGenerate = spawnRooms[generatedProb];
        Quaternion rotation       = Quaternion.LookRotation(this.transform.forward);
        Vector3    position       = GenerateRelativeVector(rotation.eulerAngles.y, bias);
        GameObject generatedRoom  = Instantiate(roomToGenerate, position, rotation);

        yield return(null);

        TestConnection[] TestConnections  = generatedRoom.GetComponentsInChildren <TestConnection>();
        CheckCollision   validatorNewRoom = generatedRoom.GetComponentInChildren <CheckCollision>();
        TestConnection   chosenPoint      = TestConnections[0];

        validatorNewRoom.TurnOnCollider();
        yield return(new WaitForSeconds(0.05f));

        if (validatorNewRoom.GetIsCollided())
        {
            Destroy(generatedRoom);
            yield return(null);
        }
        else
        {
            TestMapGen.AddGeneratedRoom(generatedRoom);
            this.SetConnected();
            chosenPoint.SetConnected();
            TestMapGen.AddTestConnections(TestConnections);
        }
    }
예제 #2
0
 private void Awake()
 {
     current = this;
 }