public void GiveLekarstvo(int hue, UIInp sc) { //Debug.Log(needed); //Debug.Log(hue); if (needed == hue) { if (give) { foreach (var slot in combiner.ord) { if (slot.transform.childCount == 0 && sc.prParent != slot) { GameObject ob = Resources.Load <GameObject>("combs/Colb"); ob = GameObject.Instantiate(ob, slot.transform); ob.GetComponent <UIInp>().fill = 100; ob.GetComponent <UIInp>().SetFill(); ob.GetComponent <Image>().color = Color.HSVToRGB((float)(prize) / 10, 1, 1); ob.transform.position = transform.position; ob.transform.localScale = new Vector3(1, 1, 1); break; } } } transform.SetParent(gudRoom.transform); transform.localPosition = Vector2.zero; Receptionist.GetComponent <receptionist>().Test(); receptionist.reputation_score += 10; if (receptionist.reputation_score > 100) { receptionist.reputation_score = 100; } GameObject.Find("RobSounds").GetComponent <AudioSource>().clip = Resources.Load <AudioClip>("sounds/SFX_VITC_8"); GameObject.Find("RobSounds").GetComponent <AudioSource>().Play(); } else { Receptionist.GetComponent <receptionist>().didLose(); GameObject.Find("RobSounds").GetComponent <AudioSource>().clip = Resources.Load <AudioClip>("sounds/SFX_VITC_9"); GameObject.Find("RobSounds").GetComponent <AudioSource>().Play(); receptionist.reputation_score -= 10; if (receptionist.reputation_score < 20) { receptionist.reputation_score = 20; } lightFade = 0.5f; InvokeRepeating("fade", 0.03f, 0.04f); } Receptionist.GetComponent <receptionist>().displayScore(); }
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(); }
public void OnDrag(PointerEventData data) { if (Moving == null) { Moving = this; } if (Moving == this) { drag = true; transform.position = data.position; float hue; float t; Color.RGBToHSV(GetComponent <Image>().color, out hue, out t, out t); hue *= 10; int col = Mathf.RoundToInt(hue + 0.1f); GameObject.Find("LevelName").transform.GetComponent <Text>().text = GameObject.Find("Static").transform.GetComponent <Loader>().colbNames[col]; transform.SetParent(mov.transform); } }
public void OnEndDrag(PointerEventData data) { if (Moving == this) { drag = false; GameObject.Find("LevelName").transform.GetComponent <Text>().text = "Level " + GameObject.Find("Static").transform.GetComponent <Loader>().level; ContactFilter2D filter = new ContactFilter2D(); Collider2D[] res = new Collider2D[2]; int cols = GetComponent <BoxCollider2D>().OverlapCollider(filter, res); if (res[0]) { if (res[0].transform.GetComponent <Activat>()) { //Debug.Log(res[0].gameObject); if (res[0].transform.childCount != 0) { //Debug.Log(prParent.name); //Debug.Log(res[0].transform.GetChild(0).GetComponent<UIInp>().prParent); res[0].transform.GetChild(0).GetComponent <UIInp>().prParent = prParent; res[0].transform.GetChild(0).SetParent(prParent.transform); colber.GetComponent <AudioSource>().Play(); } else { colber2.GetComponent <AudioSource>().Play(); } prParent = res[0].gameObject; } else if (res[0].transform.GetComponent <Robo>()) { fill -= 25; SetFill(); res[0].transform.GetComponent <Robo>().GiveLekarstvo(Mathf.RoundToInt(GetHue() * 10), this); } } transform.SetParent(prParent.transform); Moving = null; } }
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(); } }