public void ActionHandle(BuffHandlerVar buffHandlerVar)
    {
        Buff_PlaySound buff_PlaySound = (Buff_PlaySound)buffHandlerVar.data;

        if (!buffHandlerVar.GetBufferValue(out BufferValue_TargetUnits targetUnits))
        {
            return;
        }

        foreach (var v in targetUnits.targets)
        {
            if (v.UnitData.unitLayer == UnitLayer.Default)
            {
                continue;
            }
            if (buffHandlerVar.GetBufferValue(out BufferValue_AttackSuccess attackSuccess))
            {
                if (attackSuccess.successDic.ContainsKey(v.Id))
                {
                    if (!attackSuccess.successDic[v.Id])
                    {
                        continue;
                    }
                }
            }
            PlayAudio(buff_PlaySound, v, buffHandlerVar.playSpeed, buffHandlerVar.skillId);
        }
    }
    public void PlayAudio(Buff_PlaySound buff_PlaySound, Unit v, float playSpeed, string skillId)
    {
#if !SERVER
        PlayAudio(buff_PlaySound.audioClipName, v, playSpeed, buff_PlaySound.onlyPlayOnceTime ? 0 : buff_PlaySound.duration);
#else
        bool          isInApplyData = false;
        BaseSkillData baseSkillData = SkillHelper.GetBaseSkillData(skillId);
        foreach (var _v in baseSkillData.applyDatas)
        {
            PipelineDataWithBuff pipelineDataWithBuff = _v as PipelineDataWithBuff;
            if (pipelineDataWithBuff != null)
            {
                if (pipelineDataWithBuff.buffs.Find(b => b.buffData.buffSignal == buff_PlaySound.buffSignal) != null)
                {
                    isInApplyData = true;
                    break;
                }
            }
        }
        if (!isInApplyData)
        {
            return;
        }
        M2C_PlaySound m2C = new M2C_PlaySound();
        m2C.Duration      = buff_PlaySound.onlyPlayOnceTime ? 0 : buff_PlaySound.duration;
        m2C.AudioClipName = buff_PlaySound.audioClipName;
        m2C.Id            = v.Id;
        m2C.PlaySpeed     = playSpeed;
        ETHotfix.MessageHelper.Broadcast(m2C);
#endif
    }
示例#3
0
 static void AddAudioCache(AudioCacheComponent audioCacheComponent, BaseBuffData buff, GameObject skillAssetsPrefabGo)
 {
     if (buff.GetBuffIdType() == BuffIdType.PlaySound)
     {
         Buff_PlaySound buff_PlaySound = (Buff_PlaySound)buff;
         Log.Debug("添加音效" + buff_PlaySound.audioClipName);
         audioCacheComponent.Add(buff_PlaySound.audioClipName, skillAssetsPrefabGo.Get <AudioClip>(buff_PlaySound.audioClipName));
     }
 }