void BarPooling() { barList = new List <UIHpBar>(); for (int i = 0; i < 10; ++i) { GameObject temp = Instantiate(HpBarPrefab); UIHpBar tempBar = temp.GetComponent <UIHpBar>(); temp.transform.SetParent(HpBarCollecter); temp.SetActive(false); barList.Add(tempBar); } }
public void HpBarReceiver(Acter _actor) { if (barList.Count <= 0) { GameObject temp = Instantiate(HpBarPrefab); UIHpBar tempBar = temp.GetComponent <UIHpBar>(); temp.transform.SetParent(HpBarCollecter); temp.SetActive(true); tempBar.SetBattleCharacter(_actor); tempBar.AddEvent(); return; } else if (barList.Count > 0) { UIHpBar tempBar = barList[0]; tempBar.gameObject.SetActive(true); tempBar.SetBattleCharacter(_actor); barList.Remove(tempBar); tempBar.AddEvent(); return; } }
public void PushHpBar(UIHpBar hpBar) { hpBar.gameObject.SetActive(false); hpBar.RemoveEvent(); barList.Add(hpBar); }