protected override void Release(bool isShutdown) { ExpBarItem expBarItem = (ExpBarItem)Target; if (expBarItem == null) { return; } Object.Destroy(expBarItem.gameObject); }
private void Update() { for (int i = m_ActiveExpBarItems.Count - 1; i >= 0; i--) { ExpBarItem expBarItem = m_ActiveExpBarItems[i]; if (expBarItem.Refresh()) { continue; } HideExpBar(expBarItem); } }
public void ShowExpBar(Entity entity, float fromHPRatio, float toHPRatio) { if (entity == null) { Log.Warning("Entity is invalid."); return; } ExpBarItem expBarItem = GetActiveExpBarItem(entity); if (expBarItem == null) { expBarItem = CreateExpBarItem(entity); m_ActiveExpBarItems.Add(expBarItem); } expBarItem.Init(entity, m_CachedCanvas, fromHPRatio, toHPRatio); }
private ExpBarItem CreateExpBarItem(Entity entity) { ExpBarItem expBarItem = null; ExpBarItemObject expBarItemObject = m_ExpBarItemObjectPool.Spawn(); if (expBarItemObject != null) { expBarItem = (ExpBarItem)expBarItemObject.Target; } else { expBarItem = Instantiate(m_ExpBarItemTemplate); Transform transform = expBarItem.GetComponent <Transform>(); transform.SetParent(m_ExpBarInstanceRoot); transform.localScale = Vector3.one; m_ExpBarItemObjectPool.Register(ExpBarItemObject.Create(expBarItem), true); } return(expBarItem); }
private void HideExpBar(ExpBarItem expBarItem) { expBarItem.Reset(); m_ActiveExpBarItems.Remove(expBarItem); m_ExpBarItemObjectPool.Unspawn(expBarItem); }