public void ForeachPiceOfBlockWhitShift(Action <Pice, Vector2Int> callback) { var dic = DicPool.Take(); _ForeachPickOfBlockWithShift(dic, new Vector2Int(0, 0), callback); DicPool.Put(dic); }
private void Update() { if (Input.anyKey) { if (Input.GetKeyDown(KeyCode.UpArrow)) { Bullet b = DicPool.GetBullet(); b.transform.Rotate(Vector3.forward * -90); b.dirt = Vector3.right * -5; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { Bullet b = DicPool.GetBullet(); b.transform.Rotate(Vector3.forward * 90); b.dirt = Vector3.right * -5; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { Bullet b = DicPool.GetBullet(); b.dirt = Vector3.right * -5; } else if (Input.GetKeyDown(KeyCode.RightArrow)) { Bullet b = DicPool.GetBullet(); b.transform.Rotate(Vector3.forward * 180); b.dirt = Vector3.right * -5; } } }
/// <summary> /// 遍历被这个 pice 连结到的 pice (包括自身) /// </summary> /// <param name="callback"></param> public void ForeachPiceOfBlock(Action <Pice> callback) { var dic = DicPool.Take(); _ForeachPickOfBlock(dic, callback); DicPool.Put(dic); }
private IEnumerator PlayCompleteTask() { var temp = DicPool.Take(); var rank = new List <List <Pice> >(); var r1 = new List <Pice>(); r1.Add(lastDragPice); rank.Add(r1); temp[lastDragPice] = true; var next = new List <Pice>(); var last = r1; here: foreach (var pice in last) { foreach (var linking in pice.linkingList) { var nextPice = linking.pice; if (temp.ContainsKey(nextPice) && temp[nextPice]) { continue; } next.Add(nextPice); temp[nextPice] = true; } } if (next.Count > 0) { rank.Add(next); last = next; next = new List <Pice>(); goto here; } DicPool.Put(temp); AudioManager.PlaySe("level-complete-wave"); foreach (var list in rank) { foreach (var pice in list) { pice.Flash(); } yield return(new WaitForSeconds(0.15f)); } yield return(new WaitForSeconds(0.15f)); AudioManager.PlaySe("level-complete"); Complete?.Invoke(); }
private void destroy() { reset(); DicPool.RecycleBullet(this); }
private void OnBecameInvisible() { gameObject.SetActive(false); DicPool.RecycleShape(this); }
private void OnTriggerEnter2D(Collider2D collision) { gameObject.SetActive(false); DicPool.RecycleShape(this); }
private void newShape() { Shape s = DicPool.GetShape(); s.move(); }