public void OnDrop(GameObject dragged) { if (showInside) { if (dragged.transform.parent != transform) { GameObject go = Instantiate(dragged); go.transform.SetParent(transform); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; go.name = go.name + dropN; dropN++; GemaItem gi = go.GetComponent <GemaItem> (); //gi.image.raycastTarget = true; gi.GetComponent <Image> ().raycastTarget = true; gi.text.enabled = false; go.GetComponent <Draggable> ().dropable = true; Events.DroppedUI(dragged); } else { dragged.transform.SetAsFirstSibling(); } } else { Events.DroppedUI(dragged); } }
void SetCombiLevel() { cLevelData = Data.Instance.combinatoriasData.GetLevel(); int[] vals = cLevelData.valores.Clone() as int[]; System.Array.Sort(vals); List <CombinatoriasData.Gema> gemas = new List <CombinatoriasData.Gema> (); foreach (CombinatoriasData.Gema g in Data.Instance.combinatoriasData.gemas) { gemas.Add(g); } Utils.Shuffle(gemas); for (int i = 0; i < vals.Length; i++) { GameObject slot = Instantiate(gemaSlot); slot.transform.SetParent(inventarioContent); slot.transform.localPosition = Vector3.zero; slot.transform.localScale = Vector3.one; slot.transform.SetAsLastSibling(); CombinatoriasData.Gema g = gemas.Find(x => x.size == i); GameObject gi = Instantiate(gemaItem); gi.transform.SetParent(slot.transform); gi.transform.localPosition = Vector3.zero; gi.transform.localScale = Vector3.one; //gi.transform.SetAsLastSibling();*/ GemaItem gis = gi.GetComponent <GemaItem> (); gis.image.sprite = g.sprite; gis.text.text = "" + vals [i]; gis.val = vals [i]; for (int j = 0; j < cLevelData.incluidos.Length; j++) { if (vals[i] == cLevelData.incluidos[j]) { GameObject go = Instantiate(gemaItem); go.transform.SetParent(centralContent); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; //go.name = go.name + dropN; //dropN++; GemaItem git = go.GetComponent <GemaItem> (); git.image.sprite = g.sprite; git.val = vals [i]; git.GetComponent <Image> ().raycastTarget = false; git.text.enabled = false; go.GetComponent <Draggable> ().dropable = false; sumaCentral += vals [i]; } } } consigna.SetActive(true); ConsignaCombinatoria cs = consigna.GetComponent <ConsignaCombinatoria> (); cs.texto.text = "Encerrá dentro de los anillos de poder "; if (cLevelData.combinaciones > 1) { cs.texto.text += cLevelData.combinaciones + " combinaciones que sumen"; } else { cs.texto.text += cLevelData.combinaciones + " combinación que sume"; } cs.valor.text = "" + cLevelData.resultado; }