public bool InsertElementAfterFront() { if (!CheckIfInsertActionAvailable()) { return(false); } for (int i = 0; i < elements.Count; i++) { if (i == 0) { continue; } Rigidbody2D r2d = elements[i].rigidbody2D; r2d.AddForce(Vector2.up * insertPushUpForce); } BoxCollider2D col = st_element.GetComponent <BoxCollider2D>(); Vector3 spawnPosition = elements[0].transform.position; spawnPosition.y += col.size.y; STElement element = CreateElement(spawn_point.transform.position); elements.Insert(1, element); return(true); }
// A vast majority of our insert methods 'act funny' if the rigid bodies // aren't sleeping near the bottom private bool CheckIfInsertActionAvailable() { for (int i = 0; i < bottomCheck && i < elements.Count; i++) { STElement element = elements[i]; if (!element.rigidbody2D.IsSleeping()) { return(false); } } return(true); }
public void PopBottom() { if (elements.Count == 0) { return; } STElement element = elements[0]; Destroy(element.gameObject); elements.RemoveAt(0); UpdateEventScreen(); }
private bool CheckIfBottomIsSleeping() { if (elements.Count == 0) { return(true); } STElement element = elements[0]; if (!element.rigidbody2D.IsSleeping()) { return(false); } return(true); }
public bool SpawnElement() { if (!CheckIfSpawnActionAvailable()) { return(false); } STElement element = CreateElement(spawn_point.transform.position); if (!element) { return(false); } elements.Add(element); return(true); }
// Always get the STElementInfo from the front of the list private STElement CreateElement(Vector3 position) { if (infos.Count <= 0) { return(null); } STElementInfo info = infos[0]; infos.RemoveAt(0); GameObject element = Instantiate(st_element, position, Quaternion.identity) as GameObject; STElement st = element.GetComponent <STElement>(); st.ConfigureElement(info); return(st); }
public STElement() { _value = 0; _next = null; _index = 0; }
public STElement(int index) { _value = 0; _next = null; _index = index; }