public void ActionChange(ActionStatus status) { if (m_animator) { m_animator.SetInteger("Action", (int)status); switch (status) { case ActionStatus.ActionNormal: { timerID = FrameTimerHeap.AddTimer(100, 0, () => { ActionChange((ActionStatus)ActionDefault); }); } break; case ActionStatus.ActionHand: { timerID = FrameTimerHeap.AddTimer(100, 0, () => { ActionChange((ActionStatus)ActionDefault); }); } break; } } }
private void PlayFX(int id, EffectData fx, System.Action <GameObject, string> action = null, string bone_path = "") { //HandleWeaponTrial(fx); HandleAnim(fx); HandleFade(fx); string path = GameCommonUtils.GetResourceData(fx.resourceName).resourcePath; GameObject obj = Res.ResourceManager.Instance.Instantiate <GameObject>(path); string guid = path; m_loadedFX.Add(path); var go = obj as GameObject; if (!m_fxDic.ContainsKey(id)) { m_fxDic[id] = new Dictionary <string, GameObject>(); } if (!m_fxDic[id].ContainsKey(guid)) { m_fxDic[id].Add(guid, go); } else { m_fxDic[id][guid] = go; } //处理音效 var audio = go.GetComponent <AudioSource>(); if (audio != null) { audio.volume = 1f; FrameTimerHeap.AddTimer((uint)fx.soundDelay, 0, () => { if (audio != null) { audio.enabled = true; } }); } switch ((FXLocationType)fx.locationType) { case FXLocationType.SelfSlot: // 判断输入路径是否指定,若未指定则绑在预设的骨上 if (bone_path == "") { if (!m_locationDic.ContainsKey(fx.slot)) { m_locationDic.Add(fx.slot, GetBone(transform, fx.slot)); } go.transform.parent = m_locationDic[fx.slot]; } // 若已经指定则绑在指定的骨上 else { if (!m_locationDic.ContainsKey(bone_path)) { m_locationDic.Add(bone_path, GetBone(transform, bone_path)); } go.transform.parent = m_locationDic[bone_path]; // 记下index,以便删除 slotCueHandler.SetFxList(id, bone_path, guid); } go.transform.localPosition = go.transform.position; go.transform.localRotation = go.transform.rotation; break; case FXLocationType.World: go.transform.position = fx.location; break; case FXLocationType.SelfLocal: go.transform.parent = transform; //LoggerHelper.Debug(go.transform.position.x + " " + go.transform.position.y + " " + go.transform.position.z); go.transform.localPosition = go.transform.position; go.transform.localRotation = go.transform.rotation; go.transform.forward = transform.forward; break; case FXLocationType.SelfWorld: go.transform.localPosition = transform.localPosition; go.transform.localRotation = go.transform.rotation; go.transform.position = transform.position; go.transform.forward = transform.forward; break; case FXLocationType.SlotWorld: if (!m_locationDic.ContainsKey(fx.slot)) { m_locationDic.Add(fx.slot, GetBone(transform, fx.slot)); } var solt = m_locationDic[fx.slot]; go.transform.localPosition = solt.transform.localPosition; go.transform.position = solt.transform.position; go.transform.localRotation = solt.transform.rotation; break; default: break; } if (fx.isStatic == (int)FXStatic.NotStatic) { Action actRemove = () => { if (this) { RemoveFX(id, guid); } }; if (fx.duration > 0) { FrameTimerHeap.AddTimer((uint)(fx.duration * 1000), 0, actRemove); } else { FrameTimerHeap.AddTimer(3000, 0, actRemove); } } else { //如果技能为静态技能,分组标记非0,而且特效绑定到自身 } if (action != null) { action(go, guid); } }
///// <param name="bone_path">绑特效的骨骼,默认为空(即使用xml里面指定的骨骼)</param> //private void HandleNormalFX(int id, string bone_path = "") //{ // if (!FXData.dataMap.ContainsKey(id)) // { // Debug.LogWarning(string.Format("Can not find fx {0}", id)); // return; // } // HandleFX(id, FXData.dataMap[id], bone_path); //} /// <param name="bone_path">绑特效的骨骼,默认为空(即使用xml里面指定的骨骼)</param> private void PlayFX(int id, FXData fx, Action <GameObject, int> action = null, string bone_path = "") { //HandleWeaponTrial(fx); HandleAnim(fx); HandleFade(fx); if (!string.IsNullOrEmpty(fx.shader)) { HandleShaderFX(fx); } if (!string.IsNullOrEmpty(fx.dissonShader)) { HandleDissonFx(fx); } if (string.IsNullOrEmpty(fx.resourcePath)) { return; } //销毁自身冲突 if (fx.isConflict == FXConflict.Conflict && m_fxDic.ContainsKey(id)) { RemoveFXs(id); } //去除组内冲突 if (fx.group != 0) { RemoveFXByGroup(fx.group); } //AssetCacheMgr.GetResourceAutoRelease(fx.resourcePath, (obj) => AssetCacheMgr.GetNoCacheInstance(fx.resourcePath, (prefab, guid, obj) => { m_loadedFX.Add(fx.resourcePath); //Debug.LogError("m_loadedFX.Add: " + fx.resourcePath + " " + m_loadedFX.Count); //var go = GameObject.Instantiate(obj) as GameObject; //var guid = go.GetInstanceID(); var go = obj as GameObject; if (!go || !this) { AssetCacheMgr.SynReleaseInstance(go); return; } if (!m_fxDic.ContainsKey(id)) { m_fxDic[id] = new Dictionary <int, GameObject>(); } m_fxDic[id].Add(guid, go); //处理音效 var audio = go.GetComponent <AudioSource>(); if (audio != null) { if (SettingsUIViewManager.Instance != null) { audio.volume = SoundManager.SoundVolume; } FrameTimerHeap.AddTimer((uint)fx.soundDelay, 0, () => { if (audio != null) { audio.enabled = true; } }); } switch (fx.locationType) { case FXLocationType.SelfSlot: // 判断输入路径是否指定,若未指定则绑在预设的骨上 if (bone_path == "") { if (!m_locationDic.ContainsKey(fx.slot)) { m_locationDic.Add(fx.slot, GetBone(transform, fx.slot)); } go.transform.parent = m_locationDic[fx.slot]; } // 若已经指定则绑在指定的骨上 else { if (!m_locationDic.ContainsKey(bone_path)) { m_locationDic.Add(bone_path, GetBone(transform, bone_path)); } go.transform.parent = m_locationDic[bone_path]; // 记下index,以便删除 slotCueHandler.SetFxList(id, bone_path, guid); } go.transform.localPosition = go.transform.position; go.transform.localRotation = go.transform.rotation; break; case FXLocationType.World: go.transform.position = fx.location; break; case FXLocationType.SelfLocal: go.transform.parent = transform; //Debug.Log(go.transform.position.x + " " + go.transform.position.y + " " + go.transform.position.z); go.transform.localPosition = go.transform.position; go.transform.localRotation = go.transform.rotation; go.transform.forward = transform.forward; break; case FXLocationType.SelfWorld: go.transform.localPosition = transform.localPosition; go.transform.localRotation = go.transform.rotation; go.transform.position = transform.position; go.transform.forward = transform.forward; break; case FXLocationType.SlotWorld: if (!m_locationDic.ContainsKey(fx.slot)) { m_locationDic.Add(fx.slot, GetBone(transform, fx.slot)); } var solt = m_locationDic[fx.slot]; go.transform.localPosition = solt.transform.localPosition; go.transform.position = solt.transform.position; go.transform.localRotation = solt.transform.rotation; break; default: break; } if (fx.isStatic == FXStatic.NotStatic) { Action actRemove = () => { if (this) { RemoveFX(id, guid, fx.group); } }; if (fx.duration > 0) { FrameTimerHeap.AddTimer((uint)(fx.duration * 1000), 0, actRemove); } else { FrameTimerHeap.AddTimer(3000, 0, actRemove); } } else { //如果技能为静态技能,分组标记非0,而且特效绑定到自身 if (fx.group != 0 && (fx.locationType == FXLocationType.SelfSlot || fx.locationType == FXLocationType.SelfLocal)) { if (!m_groupFXList.ContainsKey(fx.group)) { m_groupFXList.Add(fx.group, new List <int>()); } m_groupFXList[fx.group].Add(id); } } if (action != null) { action(go, guid); } }); // m_fxDic.Add(id, new Dictionary<int, GameObject>()); //return go; }