예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 播放特效
        /// </summary>
        /// <param name="actionId"></param>
        public void PlaySfx(int actionId)
        {
            if (!SkillAction.dataMap.ContainsKey(actionId))
            {
                return;
            }
            Dictionary <int, float> sfx = SkillAction.dataMap[actionId].sfx;
            SfxHandler sfxHandler       = theOwner.sfxHandler;

            if (sfx != null && sfx.Count > 0)
            {
                if (!sfxTimerIDDic.ContainsKey(actionId))
                {
                    sfxTimerIDDic.Add(actionId, new List <uint>());
                }
                foreach (var pair in sfx)
                {
                    ///如果actionId小于1000的话是UI特效
                    if (pair.Key < 1000)
                    {
                        sfxTimerIDDic[actionId].Add(FrameTimerHeap.AddTimer((uint)(1000 * pair.Value), 0, PlayUIFx, pair.Key));
                    }
                    else
                    {
                        sfxTimerIDDic[actionId].Add(FrameTimerHeap.AddTimer((uint)(1000 * pair.Value), 0, TriggerCue, sfxHandler, pair.Key));
                    }
                }
            }
        }
예제 #3
0
 /// <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);
             }
         });
     }
 }