コード例 #1
0
ファイル: Loader.cs プロジェクト: sakars/Robs-Lab
    public void Load()
    {
        //TextAsset txt = Resources.Load<TextAsset>("Level jsons/" + level.ToString());
        Sign.GetComponent <Text>().text = "Level " + level;
        Debug.Log(level.ToString());
        TextAsset mytxtData = (TextAsset)Resources.Load("LevelJsons/Lvl" + level.ToString());
        string    txt       = mytxtData.text;

        Debug.Log(txt);
        Layer1 Ldata = JsonUtility.FromJson <Layer1>(txt);

        Debug.Log(Ldata.colbHues.Length);
        foreach (var thing in Ldata.botPrizes)
        {
            Debug.Log(thing);
        }
        GameObject colb = Resources.Load <GameObject>("combs/Colb");

        GameObject[] order = GameObject.Find("CombineButton").transform.GetComponent <combiner>().order;
        for (int i = 0; i < Ldata.colbHues.Length; i++)
        {
            GameObject newC = GameObject.Instantiate(colb, order[Ldata.colbLoc[i]].transform);
            UIInp      sc   = newC.GetComponent <UIInp>();
            sc.SetHue(Ldata.colbHues[i] * 0.1f);
            sc.SetFill(Ldata.colbFills[i]);
            newC.transform.localPosition = new Vector3();
            newC.transform.localScale    = new Vector3(1, 1, 1);
        }
        GameObject bot = Resources.Load <GameObject>("combs/Robs");

        Debug.Log(bot);
        for (int i = Ldata.botHues.Length - 1; i >= 0; i--)
        {
            GameObject newB = GameObject.Instantiate(bot, GameObject.Find("Remaining_bots").transform);
            newB.transform.SetAsFirstSibling();
            newB.GetComponent <Robo>().info   = gameObject;
            newB.GetComponent <Robo>().needed = Ldata.botHues[i];
            if (Ldata.botPrizes[i] != 11)
            {
                newB.GetComponent <Robo>().give  = true;
                newB.GetComponent <Robo>().prize = Ldata.botPrizes[i];
            }
            newB.GetComponent <Robo>().Receptionist = GameObject.Find("roblocs");
            newB.GetComponent <Robo>().SetBot();
            newB.SetActive(true);
        }
        GameObject.Find("roblocs").GetComponent <receptionist>().Test();
    }
コード例 #2
0
    public void combine()
    {
        if (com_1.childCount != 0 && com_2.childCount != 0)
        {
            bool       don = false;
            GameObject fill;
            it_1 = com_1.GetChild(0).GetComponent <Image>().color;
            it_2 = com_2.GetChild(0).GetComponent <Image>().color;
            float hue1;
            float t;
            Color.RGBToHSV(it_1, out hue1, out t, out t);
            float hue2;
            Color.RGBToHSV(it_2, out hue2, out t, out t);
            //float distance = Mathf.Abs(hue1 - hue2);
            float mid;
            mid = (hue1 + hue2) / 2;

            /*if (distance > 0.5f)
             * {
             *  distance = 1 - distance;
             *  mid = (Mathf.Max(hue1, hue2) + distance / 2);
             * }
             * else
             * {
             *  mid = (Mathf.Max(hue1, hue2) - distance / 2);
             * }*/
            mid *= 10f;
            mid  = Mathf.Round(mid + 0.1f);
            mid /= 10f;
            mid %= 1;
            Debug.Log(mid);
            UIInp sc1 = com_1.GetChild(0).GetComponent <UIInp>();
            UIInp sc2 = com_2.GetChild(0).GetComponent <UIInp>();
            foreach (var slot in order)
            {
                if (slot.transform.childCount == 0)
                {
                    sc1.fill -= 25;
                    sc2.fill -= 25;
                    sc1.SetFill(sc1.fill);
                    sc2.SetFill(sc2.fill);
                    GameObject ob = Resources.Load <GameObject>("combs/Colb");
                    ob = GameObject.Instantiate(ob, slot.transform);
                    ob.GetComponent <UIInp>().fill = 50;
                    ob.GetComponent <UIInp>().SetFill();
                    ob.GetComponent <Image>().color = Color.HSVToRGB(mid, 1, 1);
                    ob.transform.position           = outage.transform.position;
                    ob.transform.localScale         = new Vector3(1, 1, 1);
                    don = true;
                    GetComponent <AudioSource>().clip   = Resources.Load <AudioClip>("sounds/SFX_VITC_4");
                    GetComponent <AudioSource>().volume = 0.35f;
                    GetComponent <AudioSource>().Play();
                    break;
                }
            }
            if (don == false)
            {
                GetComponent <AudioSource>().clip   = Resources.Load <AudioClip>("sounds/SFX_VITC_5");
                GetComponent <AudioSource>().volume = 0.4f;
                GetComponent <AudioSource>().Play();
            }
        }
        else
        {
            GetComponent <AudioSource>().clip   = Resources.Load <AudioClip>("sounds/SFX_VITC_5");
            GetComponent <AudioSource>().volume = 0.4f;
            GetComponent <AudioSource>().Play();
        }
    }