//缓存血条 private void CacheBlood(UBlood ub) { if (null == ub) { return; } if (!m_CacheBloodMap.ContainsKey(ub.BloodType)) { DestroyBlood(ub); return; } if (ub.ISHero) { return; } if (m_BloodMap.ContainsKey(ub.ID)) { ub.SetEnable(false); ub.ChangeBloodColor(false); ub.ChangeParent(CacheBloodRoot.transform); Queue <UBlood> m_list = m_CacheBloodMap[ub.BloodType]; m_list.Enqueue(ub); m_BloodMap.Remove(ub.ID); } else { DestroyBlood(ub); } }
/// <summary> /// 普通血条更新 /// </summary> private void NormalUpdate() { m_InvalidList.Clear(); if (null != m_BloodMap) { foreach (UBlood var in m_BloodMap.Values) { UBlood ub = var; EntityView view = ub.Entity; if (view == null || !view.IsValid) { m_InvalidList.Enqueue(ub); continue; } //如果实体未激活,或者尚未加载完毕则隐藏血条 if (SkinInstance.isNullOrEmpry(view.SkinControl.CurrentSkinInstance) || !view.StateMachine.GetVisible()) { ub.SetEnable(false); if (view.Type == ENTITY_TYPE.TYPE_PLAYER_ROLE) { ub.OnUpdate(); } } else { ub.SetEnable(true); //需要更新的血条进行正常更新 ub.OnUpdate(); } } } while (m_InvalidList.Count > 0) { UBlood ub = m_InvalidList.Dequeue(); if (bPreWarmBlood) { CacheBlood(ub); } else { DestroyBlood(ub); } } m_InvalidList.Clear(); }
//预热血条 public void PreWarmBlood() { if (bPreWarmBlood) { return; } bPreWarmBlood = true; for (int i = 0; i < (int)BloodStyleType.Boss; i++) { BloodStyleType eType = (BloodStyleType)i; if (!m_CacheBloodMap.ContainsKey(eType)) { m_CacheBloodMap.Add(eType, new Queue <UBlood>()); } Queue <UBlood> BloodList = m_CacheBloodMap[eType]; BloodList.Clear(); for (int n = 0; n < CacheCountArry[i]; n++) { BloodCanvasNode canvNode = new BloodCanvasNode(); if (!AllocBloodPos(eType, ref canvNode)) { continue; } UBlood ub = InstanceUBlood(eType, canvNode); if (null != ub) { ub.Init(null, 0, eType, canvNode); ub.ChangeParent(CacheBloodRoot.transform); ub.SetEnable(false); BloodList.Enqueue(ub); } } } if (EntityFactory.MainHero != null) { bossBloodTarget = EntityFactory.MainHero.transform; } }