private void OnCreateUI() { if (m_photoImage == null) { return; } m_photoImage.gameObject.SetActiveNew(true); UIDragListener.Get(m_photoImage.gameObject).OnDragEvent = (ev, delta) => { if (m_boneEnt == null) { return; } if (m_boneEnt.m_animation != null && m_boneEnt.m_animation.IsPlaying("born")) { return; } if (ev == eDragEvent.Drag) { m_boneEnt.SetDirection(m_boneEnt.GetRotate() + new Vector3(0f, -1 * delta.x, 0f)); } }; UIEventListener.Get(m_photoImage.gameObject).onClick = (obj) => { if (m_boneEnt == null || m_boneEnt.m_animation == null || !m_bCanClick) { return; } if (m_boneEnt.m_animation.IsPlaying("idle") && !m_boneEnt.m_animation.IsPlaying(m_showEffectData.clickAnimaName)) // 在休闲时,才播放点击动作 { m_bCanClick = false; AnimationAction anima = new AnimationAction(); anima.crossTime = 0.2f; anima.strFull = m_showEffectData.clickAnimaName; anima.eMode = WrapMode.Once; anima.endEvent = () => { m_bCanClick = true; AnimationAction anima2 = new AnimationAction(); anima2.crossTime = 0.2f; anima2.strFull = "idle"; anima2.eMode = WrapMode.Loop; Play(anima2); OnCreateIdleEffect(); }; Play(anima); OnDestroyIdleEffect(); // 点击播放动作时,播放对应的特效,切换动作时删除 int hId = CEffectMgr.Create(m_showEffectData.clickEffectId, m_boneEnt, "origin"); CEffect ef = CEffectMgr.GetEffect(hId); if (ef != null) { ef.SetLayer(LusuoLayer.eEL_Photo); } } }; }
public void OnCreateIdleEffect() { OnDestroyIdleEffect(); // 待机动作时的特效 m_idleEffectHid = CEffectMgr.Create(m_showEffectData.idleEffectId, m_boneEnt, "origin"); CEffect effect = CEffectMgr.GetEffect(m_idleEffectHid); if (effect != null) { effect.SetLayer(LusuoLayer.eEL_Photo); } }
private void OnCreateEnterEffect(object obj) { if (m_photoObject == null) { return; } int effectId = (int)obj; int hId = CEffectMgr.Create(effectId, m_photoObject.transform.position, Vector3.zero); CEffect ef = CEffectMgr.GetEffect(hId); if (ef != null) { ef.SetLayer(LusuoLayer.eEL_Photo); } m_enterEffectHid.Add(hId); }
private void OnEnter() { // 先播放入场特效 if (m_showEffectData == null) { Debug.LogError("英雄展示特效表无资源id:" + m_resId); OnCreateEnterPhoto("born"); return; } string[] timeList = m_showEffectData.enterEffectTime.Split('|'); string[] effectList = m_showEffectData.enterEffectId.Split('|'); for (int i = 0; i < timeList.Length; i++) { float time = 0; float.TryParse(timeList[i], out time); int effectId = 0; int.TryParse(effectList[i], out effectId); int eEventId = TimeMgr.Inst.RegisterEvent(time, () => { int hId = CEffectMgr.Create(effectId, m_photoObject.transform.position, Vector3.zero); CEffect ef = CEffectMgr.GetEffect(hId); if (ef != null) { ef.SetLayer(LusuoLayer.eEL_Photo); } m_enterEffectHid.Add(hId); }); m_eventList.Add(eEventId); } // 入场播放动作 int eventId = TimeMgr.Inst.RegisterEvent(m_showEffectData.enterAnimaTime, () => { if (m_photoObject == null) { return; } string animaName = m_showEffectData.enterAnimaName; EntityBaseInfo info = new EntityBaseInfo(); info.m_resID = (int)m_resId; info.m_ilayer = (int)LusuoLayer.eEL_Photo; m_handleId = EntityManager.Inst.CreateEntity(eEntityType.eBoneEntity, info, (ent) => { if (m_photoObject == null) { return; } // 播放人物动作 if (m_type == PhotoType.hero) { m_boneEnt = ent as BoneEntity; m_boneEnt.SetParent(m_photoObject.transform); string idleAnima = "idle"; AnimationAction anima = new AnimationAction(); anima.strFull = animaName; anima.eMode = WrapMode.Once; anima.endEvent = () => { AnimationAction anima2 = new AnimationAction(); anima2.crossTime = AnimationInfo.m_crossTime; anima2.strFull = idleAnima; anima2.eMode = WrapMode.Loop; Play(anima2); OnCreateIdleEffect(); }; Play(anima); } else if (m_type == PhotoType.uieffect) { m_boneEnt = ent as BoneEntity; m_boneEnt.SetParent(m_photoObject.transform); AnimationAction anima = new AnimationAction(); anima.strFull = "idle"; anima.eMode = WrapMode.Loop; Play(anima); } }); }); m_eventList.Add(eventId); // 播放英雄声音 m_speakSoundHid = SoundManager.Inst.PlaySound(m_showEffectData.enterSpeakId, null); }