Esempio n. 1
0
    void AddOrder()

    {
        GameObject    order      = ObjectPooler.Instance.SpawnFromPool(Pool.NORMAL_BOX, transform.position, Quaternion.identity);
        BoxController currentBox = order.GetComponent <BoxController>();

        currentBox.OnObjectSpawn();
        int status    = Random.Range(0, 4);
        int type      = Random.Range(0, 3);
        int bubbleRNG = Random.Range(0, 2);

        if (status != 3)
        {
            currentBox.attributes[currentBox.fields[status]] = true;
        }
        if (bubbleRNG == 0)
        {
            currentBox.attributes[currentBox.fields[3]] = true;
        }
        switch (type)
        {
        case 1:
            currentBox.isHeavy = true;
            break;

        case 2:
            currentBox.isFragile = true;
            break;

        default:
            break;
        }
        Debug.Log("Here");
        BoxOrderController.instance.Add(currentBox);
    }
Esempio n. 2
0
    void GenerateOrder()
    {
        int        type = Random.Range(0, 3);
        GameObject currentBox;

        switch (type)
        {
        case 1:
            currentBox = ObjectPooler.Instance.SpawnFromPool(Pool.HEAVY_BOX, transform.position, Quaternion.identity);
            currentBox.GetComponent <BoxController>().isHeavy = true;
            break;

        case 2:
            currentBox = ObjectPooler.Instance.SpawnFromPool(Pool.FRAGILE_BOX, transform.position, Quaternion.identity);
            currentBox.GetComponent <BoxController>().isFragile = true;
            break;

        default:
            currentBox = ObjectPooler.Instance.SpawnFromPool(Pool.NORMAL_BOX, transform.position, Quaternion.identity);
            break;
        }
        BoxController order = currentBox.GetComponent <BoxController>();

        currentBox.SetActive(false);
        order.OnObjectSpawn();
        int redRNG    = Random.Range(0, 2);
        int blueRNG   = Random.Range(0, 2);
        int whiteRNG  = Random.Range(0, 2);
        int bubbleRNG = Random.Range(0, 2);

        if (blueRNG == 0)
        {
            order.attributes[order.fields[0]] = true;
        }
        if (redRNG == 0)
        {
            order.attributes[order.fields[1]] = true;
        }
        if (whiteRNG == 0)
        {
            order.attributes[order.fields[2]] = true;
        }
        if (bubbleRNG == 0)
        {
            order.attributes[order.fields[3]] = true;
        }
        Add(order);
        // Debug.Log("Order Created: " + order);
    }
Esempio n. 3
0
    // Update is called once per frame
    protected void Update()
    {
        if (Time.time > lastSpawnedBoxTime + spawnRate && boxCount < maximumBoxCount)
        {
            if (boxList[boxSpawnNumber] % 3 == 0)
            {
                box = ObjectPooler.Instance.SpawnFromPool(Pool.NORMAL_BOX, transform.position, Quaternion.identity);
            }
            else if (boxList[boxSpawnNumber] % 3 == 1)
            {
                box = ObjectPooler.Instance.SpawnFromPool(Pool.HEAVY_BOX, transform.position, Quaternion.identity);
            }
            else if (boxList[boxSpawnNumber] % 3 == 2)
            {
                box = ObjectPooler.Instance.SpawnFromPool(Pool.FRAGILE_BOX, transform.position, Quaternion.identity);
            }
            else
            {
                Debug.Log("IM VERY ANGRY SPAWNER");
            }

            boxComponent = box.GetComponent <BoxController>();
            boxComponent.OnObjectSpawn();
            boxComponent.onBoxDeath += BoxOnDeath;

            if (boxSpawnNumber == bombBox)
            {
                boxComponent.isSafe = false;
            }

            boxSpawnNumber++;
            if (boxSpawnNumber >= randomPacketSize)
            {
                generateNewList();
                boxSpawnNumber = 0;
            }

            boxCount++;

            lastSpawnedBoxTime = Time.time;
        }
    }