/// <summary> /// 回收血条 /// </summary> public void Recycle(object owner) { IHpBarBase hpBar = null; if (TryGetValue(owner, out hpBar)) { RecycleBar(hpBar); hpBar.Recycle(); hpData.Remove(owner); var hpType = GetHpOwnerType(owner); if (hpCache.ContainsKey(hpType)) { hpCache[hpType].Enqueue(hpBar); } else { var cache = new Queue <IHpBarBase>(); cache.Enqueue(hpBar); hpCache.Add(hpType, cache); } } }
private bool TryGetValue(object data, out IHpBarBase bar) { return(hpData.TryGetValue(data, out bar)); }
protected abstract void RecycleBar(IHpBarBase bar);
protected override void RecycleBar(IHpBarBase bar) { bar.SetState(false); }