Esempio n. 1
0
    void Start()
    {
        center = transform.position;

        long numb = RNJesus.gerRandomPowO2();

        centerObject = Instantiate(obj, center, transform.rotation);
        centerObject.GetComponent <Image>().color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
        centerObject.transform.SetParent(transform);
        centerObject.transform.SetParent(panel);
        centerObject.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = numb + "";

        BitObject bitObject = centerObject.GetComponent <BitObject>();

        bitObject.objectType = "bit";
        bitObject.value      = numb;

        centerObject.GetComponent <RectTransform>().localScale = new Vector3(1f, 1f, 1f);
        centerObject.GetComponent <BitObject>().enabled        = false;

        for (int i = 0; i < 2; i++)
        {
            addItem(true, "bit");
        }

        updatePoints();
    }
Esempio n. 2
0
    private GameObject createBitObject(string explicitType = "random")
    {
        List <float> space = new List <float>();

        space.Add(0.8f);
        space.Add(0.2f);
        int  type = RNJesus.biasedRandom(space);
        long numb = RNJesus.gerRandomPowO2();

        GameObject bit = Instantiate(obj, new Vector3(0, 0, 0), transform.rotation);

        bit.GetComponent <Image>().color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
        bit.transform.SetParent(transform);
        bit.transform.SetParent(panel);
        bit.GetComponent <RectTransform>().localScale = new Vector3(1f, 1f, 1f);
        BitObject bitObject = bit.GetComponent <BitObject>();

        switch (explicitType)
        {
        case "random": {
            if (type == 0)
            {
                bit.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = numb + "";
                bitObject.objectType = "bit";
                bitObject.value      = numb;
            }
            else
            {
                bitObject.objectType = "combine";
                bit.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = "+";
            }
            break;
        };

        case "bit": {
            bit.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = numb + "";
            bitObject.objectType = "bit";
            bitObject.value      = numb;
            break;
        };

        case "combine": {
            bitObject.objectType = "combine";
            bit.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = "+";
            break;
        };

        default: {
            bitObject.objectType = "bit";
            bit.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = "+";
            bitObject.value = numb;
            break;
        };
        }

        return(bit);
    }