public bool IsDead() { if (item != null && item.visual != null) { return(item.IsDead()); } return(false); }
public void Update() { // for (int i = 0; i < mEffects.Keys.Count; ++i) // { // uint key = mEffects.Keys.ElementAt(i); // if (!mEffects.ContainsKey(key)) // { // continue; // } // // } IDictionaryEnumerator itr = mEffects.GetEnumerator(); while (itr.MoveNext()) { ParticleItem item = itr.Value as ParticleItem; if (item != null) { //检测特效是否播放完成 if (item == null || item.IsDead()) { //自然消失的特效放在这里,管理器将其销毁 if (item != null) { mDestroys.Add((uint)itr.Key); } } else { item.OnUpdate(); } } } for (int i = 0; i < mDestroys.Count; ++i) { uint key = (uint)mDestroys[i]; if (mEffects.ContainsKey(key)) { ParticleItem item = mEffects[key] as ParticleItem; if (item.visual != null) { ParticleVisual.DestroyParticle(item.visual); } mEffects.Remove(key); } } mDestroys.Clear(); }
/// <summary> /// 更新挂接特效 /// </summary> public void UpdateAttachParticle() { SceneParticleManager particlemng = SceneManager.Instance.GetCurScene().GetParticleManager(); int nCount = mAttachParticles.Count; List <ParticleAttachMent> toDel = null; for (int i = 0; i < nCount; ++i) { ParticleAttachMent attach = mAttachParticles[i]; ParticleItem item = particlemng.GetParticle(attach.particleid); if (attach == null || item == null || item.IsDead()) { if (toDel == null) { toDel = new List <ParticleAttachMent>(); } toDel.Add(attach); continue; } //将特效更新到对应位置上 if (attach.parent == null || item.parent == null) { PrimitiveVisual aVisual = null; if (attach.atype != AttachMountType.AttachCount) { AttachMent buildinAttach = mAttachMents[(int)attach.atype]; if (buildinAttach != null) { aVisual = buildinAttach.visual; } } else { aVisual = mVisual; } if (aVisual != null && aVisual is MeshVisual && aVisual.Visual != null) { Transform tr = null; if (string.IsNullOrEmpty(attach.socketname)) { tr = aVisual.VisualTransform; } else { tr = (aVisual as MeshVisual).GetBoneByName(attach.socketname); if (tr == null) { tr = aVisual.VisualTransform; } } attach.parent = tr.gameObject; EffectTableItem effectitem = DataManager.EffectTable[attach.resid] as EffectTableItem; //不跟随释放者的特效,取挂点的方向 if (effectitem.notFollow && tr != null && attach.transform != null) { if (tr != null) { attach.transform.Rot = tr.rotation.eulerAngles; } else { attach.transform.Rot = Vector3.zero; } } } if (attach.parent != null) { if (item.visual != null && item.visual.Visual != null) { item.visual.Visual.SetActive(true); } DressingRoom.AttachParticleTo(item, attach.parent.transform); } } } if (toDel != null) { foreach (ParticleAttachMent at in toDel) { mAttachParticles.Remove(at); } } }