void SetGrillaLevel() { gLevelData = Data.Instance.grillaData.GetLevel(); consigna.SetActive(true); ConsignaCombinatoria cs = consigna.GetComponent <ConsignaCombinatoria> (); cs.texto.text = gLevelData.consigna; //cs.valor.text = ""+cLevelData.resultado; foreach (Transform child in gridContent) { Destroy(child.gameObject); } RectTransform rt = gemaGrid.GetComponent <RectTransform> (); gridContent.sizeDelta = new Vector2(gLevelData.size[0] * rt.sizeDelta.x, gLevelData.size[1] * rt.sizeDelta.y); respuesta.gameObject.SetActive(false); int fromX, fromY, toX, toY; fromX = fromY = toX = toY = -1; if ((int)gLevelData.levelType > 1) { fromX = UnityEngine.Random.Range(0, gLevelData.size[0] - gLevelData.filled[0]); fromY = UnityEngine.Random.Range(0, gLevelData.size[1] - gLevelData.filled[1]); toX = fromX + gLevelData.filled[0]; toY = fromY + gLevelData.filled[1]; if ((int)gLevelData.levelType == 2) { respuesta.gameObject.SetActive(true); } } grid = new int[gLevelData.size[0], gLevelData.size[1]]; for (int i = 0; i < gLevelData.size[0] * gLevelData.size[1]; i++) { GameObject go = Instantiate(gemaGrid); go.transform.SetParent(gridContent); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; go.transform.SetAsLastSibling(); GemaGrid gg = go.GetComponent <GemaGrid> (); gg.id = new Vector2(i % gLevelData.size[0], Mathf.Floor(i / gLevelData.size[1])); if ((int)gLevelData.levelType == 2) { gg.SetInteractable(false); if (gg.id.x >= fromX && gg.id.x < toX && gg.id.y >= fromY && gg.id.y < toY) { gg.SetActive(true); } } else if ((int)gLevelData.levelType == 3) { if (gg.id.x >= fromX && gg.id.x < toX && gg.id.y >= fromY && gg.id.y < toY) { grid [(int)gg.id.x, (int)gg.id.y] = 1; gg.SetInteractable(false); gg.SetActive(true); } } } totalTime = gLevelData.time * 3; }
void Start() { ggrid = GetComponent <GemaGrid>(); }