/// <summary> /// 创建基于实体位置跟随的特效,followType一般就2种 /// 1.脚底 /// 2.头顶 /// </summary> public static int CreateByCreaturePos(int effectId, Entity newEnt, int followType, Action <Entity> loaded = null) { if (effectId == 0) { return(0); } //BoneEntity bindEnt = (BoneEntity)EntityManager.Inst.GetEnity(bindHandleId); // 获取绑定点 BoneEntity bindEnt = newEnt as BoneEntity; EntityBaseInfo baseInfo = new EntityBaseInfo(); baseInfo.m_vPos = bindEnt.GetPos(); CEffect effect = new CEffect(effectId, baseInfo, loaded); Entity ent = effect.GetEntity(); if (ent == null) { return(0); } ent.SetLayer((int)LusuoLayer.eEL_Dynamic); effect.m_parentEnt = bindEnt; effect.m_followType = followType; bindEnt.AddBindObject(ent); m_mapEffect.Add(ent.m_hid, effect); m_followPos.Add(effect, bindEnt); return(ent.m_hid); }
public void SetBind(int bindHandleId, string bingPoint) { if (m_parentEnt != null) { m_parentEnt.RemoveBindObject(m_ent); // 移除之前的绑定 } BoneEntity bindEnt = (BoneEntity)EntityManager.Inst.GetEnity(bindHandleId); if (bindEnt == null || bindEnt.GetObject() == null) { return; } Transform bindTransform = bindEnt.GetBone(bingPoint); if (bindTransform == null) { //m_ent.SetPos(bindEnt.GetPos()); bindTransform = bindEnt.GetObject().transform; } //else //{ m_ent.SetParent(bindTransform); m_parentEnt = bindEnt; bindEnt.AddBindObject(m_ent); //} }
/// <summary> /// 创建基于绑定实体身上的特效,和角色一起显隐,无绑定点的在角色位置,不和角色一起显隐,比如刺客的施法特效 /// 挂载特效可能需要缩放,在设置挂载之后 /// </summary> public static int Create(int effectId, Entity newEnt, string bingPoint, Action <Entity> loaded = null, float scale = 1.0f) { if (effectId == 0) { return(0); } EffectCsv effectCsv = CsvManager.Inst.GetCsv <EffectCsv>((int)eAllCSV.eAC_Effect); EffectCsvData m_effectData = effectCsv.GetData(effectId); if (m_effectData == null) { return(0); } EntityBaseInfo baseInfo = new EntityBaseInfo(); baseInfo.m_resID = m_effectData.resId; baseInfo.m_ilayer = (int)LusuoLayer.eEL_Dynamic; baseInfo.m_vScale = Vector3.one * scale; // 获取绑定点 BoneEntity boneEnt = newEnt as BoneEntity; Transform bindTransform = boneEnt.GetBone(bingPoint); CEffect effect; Entity ent; if (bindTransform == null) { //baseInfo.m_vPos = boneEnt.GetPos(); //baseInfo.m_vRotate = boneEnt.GetRotate(); //effect = new CEffect(effectId, baseInfo, loaded); //ent = effect.GetEntity(); GameObject obj = boneEnt.GetObject(); if (obj == null) { return(0); } bindTransform = obj.transform; } //else //{ baseInfo.m_parent = bindTransform; effect = new CEffect(effectId, baseInfo, loaded); ent = effect.GetEntity(); effect.m_parentEnt = boneEnt; boneEnt.AddBindObject(ent); //} if (ent == null) { return(0); } m_mapEffect.Add(ent.m_hid, effect); return(ent.m_hid); }
public int CreateEntity(eEntityType eType, EntityBaseInfo baseInfo, Action <Entity> initEnd) { // 在这里可以让各种Entity继承EntityManager单独做个管理类 // 然后通过管理类去new实体对象,暂时先用switch了 // tips:这种静态的公共变量,如果在多个异步调用时,它的值会被最新值替换掉,在下面add时,就不能使用这个变量 ++s_entityHandleId; // 如果缓存中有,就取缓存,如果没有就创建 Entity entity = TryGetEntityFromCache(s_entityHandleId, initEnd, baseInfo); if (entity == null) { switch (eType) { case eEntityType.eNone: entity = new Entity(s_entityHandleId, initEnd, eType, baseInfo); break; case eEntityType.eSceneEntity: entity = new SceneEntity(s_entityHandleId, initEnd, eType, baseInfo); break; case eEntityType.eBoneEntity: entity = new BoneEntity(s_entityHandleId, initEnd, eType, baseInfo); break; case eEntityType.eEffectEntity: entity = new EffectEntity(s_entityHandleId, initEnd, eType, baseInfo); break; case eEntityType.eSoundEntity: entity = new SoundEntity(s_entityHandleId, initEnd, eType, baseInfo); break; case eEntityType.eBattleEntity: entity = new BattleEntity(s_entityHandleId, initEnd, eType, baseInfo); break; } if (null == entity) { Debug.LogError("error eType:" + eType); return(0); } } m_entityMap.Add(entity.m_hid, entity); return(entity.m_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); }