/// <summary> /// 技能触发特效,一个技能对应多个特效 /// </summary> /// <param name="skillID"></param> public void PlaySfx(int skillID) { SkillAction skillData = SkillAction.GetByID(skillID); if (skillData == null) { Debuger.LogError("not exist spell data:" + skillID); return; } // 从技能表中获取 sfx 配置 // 逐个, 按序, 按时触发特效 //key 特效id value 延时启动时间 Dictionary <int, float> sfx = skillData.sfx; SfxHandler cueHandler = theOwner.sfxHandler; if (sfx != null && sfx.Count > 0) { if (!sfxTimerIDDic.ContainsKey(skillID)) { sfxTimerIDDic.Add(skillID, new List <uint>()); } foreach (var pair in sfx) { sfxTimerIDDic[skillID].Add(FrameTimerHeap.AddTimer((uint)(1000 * pair.Value), 0, TriggerCues, cueHandler, pair.Key)); } } return; }
void Awake() { mainWinPtr = FARDll.FindWindow(null, Application.productName); //ScreenManger.Instance.SetScreenState(); screenNum = F3Device.DeviceManager.Instance.AllMonitors.Count; Common.AppLog.AddMsg(Common.LogLevel.DEBUG, "UISetting.Awake(): screenNum 当前屏幕数量 " + screenNum); //projectionState = liu.GetScreenMode.GetProjectionMode(); projectionState = Projection.GetScreenMode.GetProjectionMode(); //Common.AppLog.AddMsg(Common.LogLevel.DEBUG,"UISetting.Awake(): projectionState= " + projectionState); if (screenNum > 1 && projectionState != 2) { //Common.AppLog.AddMsg(Common.LogLevel.DEBUG,"UISetting.Awake(): 开启扩展模式 " + projectionState); Common.ScreenHelper.SetProjection(Common.ScreenHelper.SDC_TOPOLOGY_EXTEND); } uint id = FrameTimerHeap.AddTimer(1000, 2000, OnUpdateJudge); //FrameTimerHeap.DelTimer(id); //删除定时器 var openFildPath = transform.Find("FieldPath"); AttributeGetValue(); SetScreenToggleListener(); SetOtherListener(); versionText = transform.Find("Version/PathText").GetComponent <Text>(); Invoke("DelayCall", 0.2f); nonARCameraWarnning = aRToggle.transform.Find("NonARCameraWarnning").gameObject; nonARCameraWarnningText = nonARCameraWarnning.GetComponent <Text>(); nonARCameraWarnning.SetActive(false); UGUIEventListener.Get(aRToggle.gameObject).onClick += ClickARToggle; }
public void RemoveSfx(int actionID) { List <uint> sfxs = null; sfxTimerIDDic.TryGetValue(actionID, out sfxs); if (sfxs == null) { return; } foreach (var item in sfxs) { FrameTimerHeap.DelTimer(item); } Dictionary <int, float> sfx = SkillAction.dataMap[actionID].sfx; if (sfx == null) { return; } SfxHandler cueHandler = theOwner.sfxHandler; foreach (var item in sfx) { if (cueHandler) { cueHandler.RemoveFXs(item.Key); } } sfxs.Clear(); }
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 = SkillAction.dataMap[actionID].sfx; if (sfx == null) { return; } SfxHandler cueHandler = theOwner.sfxHandler; foreach (var item in sfx) { if (item.Key < 1000) { StopUIFx(item.Key); } else { if (cueHandler) { cueHandler.RemoveFXs(item.Key); } } } sfxs.Clear(); }
public void PlaySfx(int actionID) { if (!SkillAction.dataMap.ContainsKey(actionID)) { LoggerHelper.Error("not exist spell data:" + actionID); return; } // 从技能表中获取 sfx 配置 // 逐个, 按序, 按时触发特效 Dictionary <int, float> sfx = SkillAction.dataMap[actionID].sfx; SfxHandler cueHandler = theOwner.sfxHandler; if (sfx != null && sfx.Count > 0) { if (!sfxTimerIDDic.ContainsKey(actionID)) { sfxTimerIDDic.Add(actionID, new List <uint>()); } foreach (var pair in sfx) { 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, TriggerCues, cueHandler, pair.Key)); } } } return; }
void Tick() { if (!InitFinished) { return; } TimerHeap.Tick(); FrameTimerHeap.Tick(); }
void Update() { TimerHeap.Tick(); FrameTimerHeap.Tick(); if (hasInitFinish) { MogoWorld.Process(); if (MogoWorld.thePlayer != null && MogoWorld.thePlayer.ViewTransform != null) { transform.localPosition = MogoWorld.thePlayer.ViewTransform.localPosition; } } }
/// <summary> /// 处理淡入淡出 /// </summary> /// <param name="fx"></param> private void HandleFade(FXData fx) { if (fx.fadeStart != fx.fadeEnd) { try { if (m_mat != null) { var color = GetMatColor("_Color"); if (color.a == fx.fadeEnd) { if (m_randerer != null && fx.fadeEnd == 0) { SetRanderEnable(false); } return; } } } catch (System.Exception ex) { Debug.LogException(ex); } var startTime = Time.realtimeSinceStartup; Debug.Log("startTime: " + startTime); var repeatTimer = FrameTimerHeap.AddTimer((uint)fx.fadeDelay, 100, () => { if (m_mat != null) { var deltaTime = Time.realtimeSinceStartup - startTime; //Debug.Log("deltaTime: " + deltaTime); var target = fx.fadeStart + ((fx.fadeEnd - fx.fadeStart) * deltaTime * 1000 / fx.fadeDulation); Debug.Log("target: " + target); SetMatColor("_Color", new Color(1, 1, 1, target)); } }); FrameTimerHeap.AddTimer((uint)(fx.fadeDelay + fx.fadeDulation), 0, () => { FrameTimerHeap.DelTimer(repeatTimer); if (m_randerer != null && fx.fadeEnd == 0) { SetRanderEnable(false); } }); } }
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; } } }
void Tick() { TimerHeap.Tick(); FrameTimerHeap.Tick(); }
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; }
void Update() { TimerHeap.Tick(); FrameTimerHeap.Tick(); }