public void DoAnimation(InitiallyFullTube tb) { switch (Size(tb.pila)) { case 1: oldY = tb.basse.transform.position.y; tb.basse.transform.position = new Vector3(tb.basse.transform.position.x, tb.oldY + 0.5f, tb.basse.transform.position.z); break; case 2: oldY = tb.middleBase.transform.position.y; tb.middleBase.transform.position = new Vector3(tb.middleBase.transform.position.x, tb.oldY + 0.5f, tb.middleBase.transform.position.z); break; case 3: oldY = tb.middleTop.transform.position.y; tb.middleTop.transform.position = new Vector3(tb.middleTop.transform.position.x, tb.oldY + 0.5f, tb.middleTop.transform.position.z); break; case 4: oldY = tb.top.transform.position.y; tb.top.transform.position = new Vector3(tb.top.transform.position.x, tb.oldY + 0.5f, tb.top.transform.position.z); break; } }
private void FillStack(InitiallyFullTube t) { t.pila = new Stack <Color>(); t.pila.Push(t.transform.GetChild(0).GetComponent <SpriteRenderer>().color); t.pila.Push(t.transform.GetChild(1).GetComponent <SpriteRenderer>().color); t.pila.Push(t.transform.GetChild(2).GetComponent <SpriteRenderer>().color); t.pila.Push(t.transform.GetChild(3).GetComponent <SpriteRenderer>().color); }
public void PrintStackStatus(Stack <Color> s, InitiallyFullTube tb) { switch (Size(s)) { case 0: tb.basse.SetActive(false); tb.middleBase.SetActive(false); tb.middleTop.SetActive(false); tb.top.SetActive(false); break; case 1: tb.basse.SetActive(true); tb.basse.GetComponent <SpriteRenderer>().color = s.ToArray()[0]; tb.middleBase.SetActive(false); tb.middleTop.SetActive(false); tb.top.SetActive(false); //Debug.Log("case 1"); break; case 2: tb.basse.SetActive(true); tb.basse.GetComponent <SpriteRenderer>().color = s.ToArray()[1]; tb.middleBase.SetActive(true); tb.middleBase.GetComponent <SpriteRenderer>().color = s.ToArray()[0]; tb.middleTop.SetActive(false); tb.top.SetActive(false); // Debug.Log("case 2"); break; case 3: tb.basse.SetActive(true); tb.basse.GetComponent <SpriteRenderer>().color = s.ToArray()[2]; tb.middleBase.SetActive(true); tb.middleBase.GetComponent <SpriteRenderer>().color = s.ToArray()[1]; tb.middleTop.SetActive(true); tb.middleTop.GetComponent <SpriteRenderer>().color = s.ToArray()[0]; tb.top.SetActive(false); //Debug.Log("case 3"); break; case 4: tb.basse.SetActive(true); tb.basse.GetComponent <SpriteRenderer>().color = s.ToArray()[3]; tb.middleBase.SetActive(true); tb.middleBase.GetComponent <SpriteRenderer>().color = s.ToArray()[2]; tb.middleTop.SetActive(true); tb.middleTop.GetComponent <SpriteRenderer>().color = s.ToArray()[1]; tb.top.SetActive(true); tb.top.GetComponent <SpriteRenderer>().color = s.ToArray()[0]; //Debug.Log("case 4"); break; default: break; } }
public void SetTubes() { for (int i = 0; i < position.Length; i++) { InitiallyFullTube t = Instantiate(tube) as InitiallyFullTube; t.transform.SetParent(container.GetComponent <Transform>()); t.transform.position = new Vector3(position[i][0], position[i][1], container.transform.position.z); t.transform.localScale = new Vector3(container.transform.localScale.x + 77.18328f, container.transform.localScale.y + 77.18328f, container.transform.localScale.z + 77.18328f); Debug.Log("before if"); if (Screen.currentResolution.width != 1920 && Screen.currentResolution.height != 1080) { Debug.Log("in Screen"); t.transform.localScale = new Vector3(t.transform.localScale.x / 2, t.transform.localScale.x / 2, 1); t.transform.position = new Vector3(positionLR[i][0], positionLR[i][1], container.transform.position.z); } } tubes = FindObjectsOfType <InitiallyFullTube>(); int empty_tubes = tubes.Length - c.Length / 4; Debug.Log(c.Length); Debug.Log(tubes.Length); for (int i = 0; i < empty_tubes; i++) { tubes[i].initial_status = "empty"; tubes[i].transform.GetChild(0).gameObject.SetActive(false); tubes[i].transform.GetChild(1).gameObject.SetActive(false); tubes[i].transform.GetChild(2).gameObject.SetActive(false); tubes[i].transform.GetChild(3).gameObject.SetActive(false); tubes[i].pila = new Stack <Color>(); } int k = 0; for (int j = empty_tubes; j < tubes.Length; j++) { Debug.Log(tubes[j]); tubes[j].initial_status = "full"; tubes[j].transform.GetChild(3).GetComponent <SpriteRenderer>().color = c[k++]; tubes[j].transform.GetChild(2).GetComponent <SpriteRenderer>().color = c[k++]; tubes[j].transform.GetChild(1).GetComponent <SpriteRenderer>().color = c[k++]; tubes[j].transform.GetChild(0).GetComponent <SpriteRenderer>().color = c[k++]; FillStack(tubes[j]); } }