public static int Create(int effectId, Vector3 pos, Vector3 rota, Action <Entity> loaded = null) { 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) { Debug.LogError("特效为空:" + effectId); return(0); } EntityBaseInfo entInfo = new EntityBaseInfo(); entInfo.m_resID = m_effectData.resId; entInfo.m_vPos = pos; entInfo.m_vRotate = rota; CEffect effect = new CEffect(effectId, entInfo, loaded); Entity ent = effect.GetEntity(); ent.SetLayer((int)LusuoLayer.eEL_Dynamic); ent.SetPos(pos); ent.SetDirection(rota); m_mapEffect.Add(ent.m_hid, effect); return(ent.m_hid); }
/// <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 float m_headPos; // 头顶位置,因为外部逻辑,这个位置会变动 public Entity(int handle, Action <Entity> notity, eEntityType tpye, EntityBaseInfo baseInfo) { if (baseInfo.m_resID == 0) { Debug.LogError("资源id为0,请检查配置"); return; } m_entityInitNofity = notity; m_hid = handle; m_entityType = tpye; m_entityInfo = baseInfo; m_LoadingDestory = false; //Debug.LogError("请求加载资源。。。。。。。。。。。。"+ m_entityInfo.m_resID); if (!string.IsNullOrEmpty(m_entityInfo.m_strName)) { m_res = ResourceFactory.Inst.LoadResource(m_entityInfo.m_strName, ResourceLoaded); } else { ResInfo resInfo = ResInfosResource.GetResInfo(m_entityInfo.m_resID); if (resInfo != null && resInfo.strUrl != null) { m_entityInfo.m_strName = resInfo.strName; m_res = ResourceFactory.Inst.LoadResource(m_entityInfo.m_resID, ResourceLoaded); } else { Debug.LogError("创建失败,无资源id:" + m_entityInfo.m_resID + " 现用灰色盒子代替,请注意更换!"); m_res = ResourceFactory.Inst.LoadResource(4, ResourceLoaded); } } }
/// <summary> /// 创建模型 /// </summary> public virtual void Create(sVOjectBaseInfo baseInfo) { m_baseInfo = baseInfo; EntityBaseInfo info = new EntityBaseInfo(); info.m_uid = baseInfo.m_uid; info.m_resID = baseInfo.m_resId; info.m_ilayer = (int)LusuoLayer.eEL_Dynamic; info.m_vPos = baseInfo.m_pos; info.m_vScale = Vector3.one * baseInfo.m_scale; if (baseInfo.m_dir != Vector3.zero) { info.m_vRotate = Quaternion.LookRotation(baseInfo.m_dir).eulerAngles; } eEntityType eType = eEntityType.eBattleEntity; if (this is VObject) { eType = eEntityType.eBattleEntity; } else if (this is VTrigger) { eType = eEntityType.eEffectEntity; } int hid = EntityManager.Inst.CreateEntity(eType, info, CreateEnd); SetDir(baseInfo.m_dir); SetPos(baseInfo.m_pos, true); SetSpeed(baseInfo.m_speed); m_ent = EntityManager.Inst.GetEnity(hid); }
public int CreatEquip(int resId, string parentName) { EntityBaseInfo info = new EntityBaseInfo(); info.m_resID = resId; info.m_parent = GetBone(parentName); info.m_ilayer = (int)LusuoLayer.eEL_Dynamic; return(EntityManager.Inst.CreateEntity(eEntityType.eNone, info, null)); }
private void OnLoadModel() { EntityBaseInfo info = new EntityBaseInfo(); info.m_resID = (int)m_sceneInfo.resId; info.m_ilayer = (int)LusuoLayer.eEL_Static; int handleId = EntityManager.Inst.CreateEntity(eEntityType.eSceneEntity, info, OnLoadCollider); m_ent = EntityManager.Inst.GetEnity(handleId); }
public void OnLoadCollider(Entity ent) { EntityBaseInfo info = new EntityBaseInfo(); info.m_resID = (int)m_sceneInfo.collider; info.m_ilayer = (int)LusuoLayer.eEL_Static; int handleId = EntityManager.Inst.CreateEntity(eEntityType.eSceneEntity, info, OnLoadStaticData); m_colliderEnt = EntityManager.Inst.GetEnity(handleId); }
/// <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 virtual void Revive(int handleId, Action <Entity> notity, EntityBaseInfo baseInfo) { if (m_res == null) { return; } m_hid = handleId; m_entityInitNofity = notity; m_entityInfo = baseInfo; SetBaseInfo(); // 重复利用的对象池时,不用再去获取组件信息,设置基本信息就行 m_bRevive = true; //OnInited(); }
public override void ChangeResource(Action <Entity> notity, EntityBaseInfo baseInfo) { m_animation = null; m_bones = null; if (m_dicBone != null) { m_dicBone.Clear(); m_dicBone = null; } if (m_bindObject != null) { m_bindObject.Clear(); } base.ChangeResource(notity, baseInfo); }
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 Entity TryGetEntityFromCache(int handleId, Action <Entity> notify, EntityBaseInfo info) { LinkedList <Entity> entityList; if (m_cacheEntityMap.TryGetValue(info.m_resID, out entityList)) { LinkedListNode <Entity> entNode = entityList.First; if (entNode != null) { Entity ent = entNode.Value; info.m_active = true; ent.Revive(handleId, notify, info); entityList.RemoveFirst(); //Debug.Log("===========================取出缓存" + ent.GetObject() + " " + ent.GetResource().GetResInfo().nResID); return(ent); } } return(null); }
public static int Create(int effectId, Transform uiBindPoint) { if (effectId == 0) { return(0); } EntityBaseInfo baseInfo = new EntityBaseInfo(); baseInfo.m_parent = uiBindPoint; baseInfo.m_vScale = Vector3.one; CEffect effect = new CEffect(effectId, baseInfo, null); Entity ent = effect.GetEntity(); ent.SetLayer((int)LusuoLayer.eEL_Dynamic); ent.SetParent(uiBindPoint); m_mapEffect.Add(ent.m_hid, effect); return(ent.m_hid); }
public int Play(int resId, Vector3 pos, SoundCsvData data, Action <Entity> initEnd = null, Action playEnd = null) { if (resId == 0) { return(0); } EntityBaseInfo bInfo = new EntityBaseInfo(); bInfo.m_resID = resId; bInfo.m_soundMute = m_dicTypeMute[(int)data.type]; bInfo.m_soundType = (int)data.type; bInfo.m_soundLoop = data.Loop; bInfo.m_vPos = pos; bInfo.m_ilayer = (int)LusuoLayer.eEL_Sound; int handle = EntityManager.Inst.CreateEntity(eEntityType.eSoundEntity, bInfo, initEnd); SoundEntity entity = (SoundEntity)EntityManager.Inst.GetEnity(handle); m_dicSoundEntity.Add(entity.m_hid, entity); entity.m_playEnd = playEnd; return(handle); }
/// <summary> /// 创建基于UI的特效绑定 /// </summary> public static int CreateUI(int effectId, Transform uiBindPoint, int order = 0, Action <CEffect> playend = null, Action <Entity> loaded = null, float scale = 1.0f) { if (effectId == 0) { return(0); } EntityBaseInfo baseInfo = new EntityBaseInfo(); baseInfo.m_parent = uiBindPoint; baseInfo.m_vScale = new Vector3(scale, scale, scale); CEffect effect = new CEffect(effectId, baseInfo, loaded); Entity ent = effect.GetEntity(); ent.SetLayer((int)LusuoLayer.eEL_UI); ent.SetOrder(order); ent.SetParent(uiBindPoint); m_mapEffect.Add(ent.m_hid, effect); effect.AddPlayEnd(playend); return(ent.m_hid); }
private void Create(int csvId, EntityBaseInfo entInfo, Action <Entity> loaded = null) { EffectCsv effectCsv = CsvManager.Inst.GetCsv <EffectCsv>((int)eAllCSV.eAC_Effect); m_effectData = effectCsv.GetData(csvId); if (m_effectData == null || m_effectData.resId == 0) { Debug.LogError("找不到特效id:" + csvId); return; } if (entInfo == null) { entInfo = new EntityBaseInfo(); } entInfo.m_resID = m_effectData.resId; int handldId = EntityManager.Inst.CreateEntity(eEntityType.eEffectEntity, entInfo, loaded); m_ent = EntityManager.Inst.GetEnity(handldId); m_maxTime = m_effectData.lifeTime; if (m_maxTime.Equals(0.0f)) { m_bAutoDel = false; } //if (GameManager.Instance.m_speedUpInLoading) // return; if (m_effectData == null || m_ent == null) { return; } int soundHid = SoundManager.Inst.PlaySound(m_effectData.soundId, m_ent.GetPos()); m_soundEnt = EntityManager.Inst.GetEnity(soundHid); if (m_effectData.shakeCamera == 1) { CameraMgr.Inst.OnShake(); } }
/// <summary> /// 改变模型资源的接口 /// </summary> /// <param name="notity"></param> /// <param name="baseInfo"></param> public virtual void ChangeResource(Action <Entity> notity, EntityBaseInfo baseInfo) { m_entityInitNofity = notity; m_entityInfo = baseInfo; // 先卸载 if (!m_res.IsLoaded()) { return; } m_listRenderer.Clear(); if (m_originalColorList != null) { m_originalColorList.Clear(); m_originalColorList = null; } if (m_originalShaderList != null) { m_originalShaderList.Clear(); m_originalShaderList = null; } if (m_orderList != null) { m_orderList = null; } if (m_object != null) { GameObject.Destroy(m_object); } ResourceFactory.Inst.UnLoadResource(m_res, true); m_object = null; m_res = null; m_LoadingDestory = false; // 开始下载资源 m_res = ResourceFactory.Inst.LoadResource(m_entityInfo.m_resID, ChangeResourceLoaded); }
private void OnLoadSelect() { m_master = CCreatureMgr.GetMaster(); m_master.UpdateUI_Skill(); EntityBaseInfo info = new EntityBaseInfo(); info.m_resID = 3; info.m_ilayer = (int)LusuoLayer.eEL_Dynamic; m_skillChoseHid = EntityManager.Inst.CreateEntity(eEntityType.eNone, info, (ent) => { ent.SetDirection(Vector3.zero); //ent.SetColor(SKLL_BLUE); ent.SetRenderQueue(3001); GameObject skillChose = ent.GetObject(); m_skillChose = skillChose.transform; m_skillDistance = m_skillChose.FindChild("distance"); m_skillCenter = m_skillChose.FindChild("center"); m_skillSectorDir = m_skillCenter.FindChild("sector_dir"); m_skillDir = m_skillCenter.FindChild("dir"); m_skillPos = m_skillCenter.FindChild("pos"); CancelSkill(); }); }
public override void Revive(int handleId, Action <Entity> notity, EntityBaseInfo baseInfo) { base.Revive(handleId, notity, baseInfo); }
/// <summary> /// 部位-资源id /// 最终表现层借口 /// </summary> public void UpdateEquip(Dictionary <eEquipType, int> dic, Action end = null) { if (dic == null) { return; } if (!IsInited()) { return; } if (!dic.ContainsKey(eEquipType.Clothes)) { dic[eEquipType.Clothes] = 0; } if (dic[eEquipType.Clothes] == 0) { Debug.Log("衣服资源Id不能为0,请检查"); //return; } // 如果和原始模型不一样,需要换装,并且销毁之前的其他装备 if (dic[eEquipType.Clothes] != 0 && dic[eEquipType.Clothes] != GetResource().GetResInfo().nResID) { RemoveAllEquip(); EntityBaseInfo info = new EntityBaseInfo(); info.m_resID = dic[eEquipType.Clothes]; info.m_ilayer = (int)LusuoLayer.eEL_Dynamic; info.m_vPos = GetPos(); info.m_vScale = GetScale(); info.m_vRotate = GetRotate(); ChangeResource((newEnt) => { //Debug.Log("换装完成,已经清除之前的装备,重新装备武器"); foreach (KeyValuePair <eEquipType, int> item in dic) { if (item.Key == eEquipType.Clothes) { continue; } if (item.Value == 0) { RemoveEquip(item.Key); } else { AddEquip(item.Key, item.Value); } } if (end != null) { end(); } }, info); } else { //Debug.Log("无换装,切换武器"); foreach (KeyValuePair <eEquipType, int> item in dic) { if (item.Key == eEquipType.Clothes) { continue; } if (item.Value == 0) { RemoveEquip(item.Key); } else { AddEquip(item.Key, item.Value); } } if (end != null) { end(); } } }
public int m_followType; // 跟随类型的特效,1脚底,2头顶 public CEffect(int csvId, EntityBaseInfo entInfo, Action <Entity> loaded = null) { m_entBaseInfo = entInfo; Create(csvId, m_entBaseInfo, loaded); }
public SoundEntity(int handle, Action <Entity> notify, eEntityType eType, EntityBaseInfo entityInfo) : base(handle, notify, eType, entityInfo) { }
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); }