Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        qrand = FindObjectOfType <QRand>();

        roomHeight = room.GetComponent <RoomGeneration>().GetSize().y;
        roomWidth  = room.GetComponent <RoomGeneration>().GetSize().x;

        //Characters are instantieated
        character1 = Instantiate(character1Prefab, new Vector3(0, 0, 0), Quaternion.identity);
        character2 = Instantiate(character2Prefab, new Vector3(0, 0, 0), Quaternion.identity);

        //Character map location is set
        //locationX = Random.Range(0,levelWidth);
        //locationY = Random.Range(0,levelHeight);
        locationX = qrand.NextInt(levelWidth);
        locationY = qrand.NextInt(levelHeight);
        Debug.LogFormat("Spawned in room [x={0},y={1}]", locationX, locationY);

        //Connections of the rooms will be generated. Rooms are saved to roomStructure variable
        roomStructure = new Room[levelHeight][];
        GenerateLevelLayout();

        //First room will be instantiated
        InstantiateRoom(locationX, locationY, true);
    }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        qrandDone = false;
        waitDone  = false;
        Debug.Log("Scene loading begun.");
        StartCoroutine(TimedDelay(7f));
        QRand qrand = FindObjectOfType <QRand>();

        if (qrand)
        {
            Debug.Log("Starting loadQRand() coroutine.");
            StartCoroutine(LoadQRand());
        }
    }
Esempio n. 3
0
    [SerializeField] float[] flipProbabilities; //x, y, both, otherwise no flip

    // Start is called before the first frame update
    void Start()
    {
        RoomGeneration roomGenerator = transform.root.GetComponent <RoomGeneration>();
        Room           room          = roomGenerator.room;
        QRand          qrand         = FindObjectOfType <QRand>();
        // qrand.InitState(room.Seed); //Change the seed based on the location
        float random = qrand.NextFloat();

        //Random.InitState(room.Seed); //TODO something addition to make new combinations
        //float random = Random.value;

        //Debug.Log(random);
        float cumulativeProbability = 0f;

        for (int i = 0; i < probabilities.Length; i++)
        {
            cumulativeProbability += probabilities[i];
            if (cumulativeProbability >= random)
            {
                GameObject roomPart = Instantiate(roomParts[i], transform.position, Quaternion.identity, transform.parent);
                //roomPart.transform.parent = roomGenerator.transform.Find("Layout").transform;
                roomPart.transform.parent = gameObject.transform;
                break;
            }
        }

        random = qrand.NextFloat();
        cumulativeProbability = 0f;
        bool x = false;
        bool y = false;

        for (int i = 0; i < flipProbabilities.Length; i++)
        {
            cumulativeProbability += flipProbabilities[i];
            if (cumulativeProbability >= random)
            {
                if (i == 0 || i == 2)
                {
                    x = true;
                }
                if (i == 1 || i == 2)
                {
                    y = true;
                }
                Debug.Log("Probs: " + i);
            }
        }

        Debug.Log(x + ", " + y);

        int j = 0;

        if (transform.childCount > 0)
        {
            foreach (Transform child in transform.GetChild(0))
            {
                if (x)
                {
                    child.localPosition = new Vector3(-child.localPosition.x, child.localPosition.y, child.localPosition.z);
                }
                if (y)
                {
                    child.localPosition = new Vector3(child.localPosition.x, -child.localPosition.y, child.localPosition.z);
                }
                child.parent = roomGenerator.transform.Find("Layout").transform;
                Debug.Log("Childs: " + j);
                j += 1;
            }
        }


        //This game object is not neede anymore
        Destroy(gameObject);
    }
Esempio n. 4
0
 void Awake()
 {
     qrand = FindObjectOfType <QRand>();
 }