protected override void Release() { HPBarItem hpBarItem = (HPBarItem)Target; if (hpBarItem == null) { return; } Object.Destroy(hpBarItem.gameObject); }
private void Update() { for (int i = m_ActiveHPBarItems.Count - 1; i >= 0; i--) { HPBarItem hpBarItem = m_ActiveHPBarItems[i]; if (hpBarItem.Refresh()) { continue; } HideHPBar(hpBarItem); } }
public void ShowHPBar(Entity entity, float fromHPRatio, float toHPRatio) { if (entity == null) { Log.Warning("Entity is invalid."); return; } HPBarItem hpBarItem = GetActiveHPBarItem(entity); if (hpBarItem == null) { hpBarItem = CreateHPBarItem(entity); m_ActiveHPBarItems.Add(hpBarItem); } hpBarItem.Init(entity, m_CachedCanvas, fromHPRatio, toHPRatio); }
private HPBarItem CreateHPBarItem(Entity entity) { HPBarItem hpBarItem = null; HPBarItemObject hpBarItemObject = m_HPBarItemObjectPool.Spawn(); if (hpBarItemObject != null) { hpBarItem = (HPBarItem)hpBarItemObject.Target; } else { hpBarItem = Instantiate(m_HPBarItemTemplate); Transform transform = hpBarItem.GetComponent <Transform>(); transform.SetParent(m_HPBarInstanceRoot); transform.localScale = Vector3.one; m_HPBarItemObjectPool.Register(new HPBarItemObject(hpBarItem), true); } return(hpBarItem); }
private void HideHPBar(HPBarItem hpBarItem) { hpBarItem.Reset(); m_ActiveHPBarItems.Remove(hpBarItem); m_HPBarItemObjectPool.Unspawn(hpBarItem); }