public void RemoveSfx(int actionID) { var sfxs = sfxTimerIDDic.GetValueOrDefault(actionID, new List <uint>()); foreach (var item in sfxs) { FrameTimerHeap.DelTimer(item); } Dictionary <int, float> sfx = SkillActionData.dataMap[actionID].sfx; if (null == sfx) { return; } SfxHandler handler = theOwner.sfxHandler; foreach (var item in sfx) { if (item.Key < 1000) { StopUIFx(item.Key); } else { handler.RemoveFx(item.Key); } } }
/// <summary> /// 处理淡入淡出 /// </summary> /// <param name="fx"></param> private void HandleFade(FXData fx) { if (fx.fadeStart != fx.fadeEnd) { try { if (this.m_mat != null) { var color = GetMatColor("_Color"); if (color.a == fx.fadeEnd)//如果淡出的alpha为0,就隐藏renderer { if (this.m_renderer != null && fx.fadeEnd == 0) { this.SetRendererEnable(false); } return; } } } catch (Exception e) { Debug.LogException(e); } var startTime = Time.realtimeSinceStartup; var repeatTimer = FrameTimerHeap.AddTimer((uint)fx.fadeDelay, 100, () => { if (this.m_mat != null) { var deltaTime = Time.realtimeSinceStartup - startTime; //偏移的时间 var target = fx.fadeStart + ((fx.fadeStart - fx.fadeEnd) * deltaTime * 1000 / fx.fadeDuration); this.SetMatColor("_Color", new Color(1, 1, 1, target)); //设置成白色 } }); FrameTimerHeap.AddTimer((uint)fx.fadeDelay + (uint)fx.fadeDuration, 0, () => { FrameTimerHeap.DelTimer(repeatTimer); if (this.m_renderer != null && fx.fadeEnd == 0) { this.SetRendererEnable(false); } }); } }