public static int AddEffect(IEntity en, int nEffectID) { if (en == null) { return(0); } //RemoveEffect(en, nEffectID); table.FxResDataBase edb = GameTableManager.Instance.GetTableItem <table.FxResDataBase>((uint)nEffectID); if (edb != null) { AddLinkEffect node = new AddLinkEffect(); table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(edb.resPath); if (resDB == null) { Engine.Utility.Log.Error("找不到特效资源路径配置{0}", edb.resPath); } node.strEffectName = resDB.strPath; node.strLinkName = edb.attachNode; node.nFollowType = (int)edb.flowType; node.rotate = new Vector3(edb.rotate[0], edb.rotate[1], edb.rotate[2]); node.vOffset = new Vector3(edb.offset[0], edb.offset[1], edb.offset[2]); node.strEffectName = resDB.strPath; node.strLinkName = edb.attachNode; node.bIgnoreRide = false; // 特效要挂在坐骑上 node.scale = Vector3.one; return((int)en.SendMessage(EntityMessage.EntityCommand_AddLinkEffect, node)); } return(0); }
public static string GetModelPath(uint itemID, uint faceID, bool ifJudgeSex = true) { var modelPath = ""; var tbl = Table.Query <table.EquipDataBase>().FirstOrDefault(i => i.equipID == itemID); if (tbl == null) { return(modelPath); } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)tbl.apperMale); string male = (null != resDB) ? resDB.strPath : "";; resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)tbl.apperFemale); string female = (null != resDB) ? resDB.strPath : "";; if (ifJudgeSex) { modelPath = GameUtil.FaceToSex(faceID) == enmCharSex.MALE ? male : female; } else { if (tbl != null) { modelPath = male; } } return(modelPath); }
public void ShowFxTips(uint effectResId) { m_trans_fxRoot.gameObject.SetActive(true); table.ResourceDataBase rdb = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(effectResId); if (rdb == null) { return; } Engine.IRenderSystem es = Engine.RareEngine.Instance().GetRenderSystem(); if (es == null) { return; } string path = rdb.strPath; Engine.IEffect effect = null; if (es.CreateEffect(ref path, ref effect)) { Transform transf = effect.GetNodeTransForm(); if (transf == null) { return; } transf.parent = m_trans_fxRootContent; transf.localPosition = Vector3.zero; m_trans_fxRootContent.SetChildLayer(LayerMask.NameToLayer("UI")); } }
void LoadEntity() { for (int i = 0; i < preLoadNpcList.Count; i++) { // yield return null; uint resID = preLoadNpcList[i]; table.ResourceDataBase rdb = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(resID); if (rdb != null) { Engine.IRenderObj[] objList; Log.LogGroup("ZDY", "preload npc {0} num is {1}", rdb.strPath, m_uPreLoadNum); Engine.RareEngine.Instance().CacheRenderObj(rdb.strPath, 1, out objList); if (!m_preLoadDic.ContainsKey(rdb.strPath)) { m_preLoadDic.Add(rdb.strPath, objList); } } } for (int i = 0; i < preLoadMonsterList.Count; i++) { //yield return null; uint resID = preLoadMonsterList[i]; table.ResourceDataBase rdb = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(resID); if (rdb != null) { Engine.IRenderObj[] objList; Log.LogGroup("ZDY", "preload entity {0} num is {1}", rdb.strPath, m_uPreLoadNum); Engine.RareEngine.Instance().CacheRenderObj(rdb.strPath, m_uPreLoadNum, out objList); if (!m_preLoadDic.ContainsKey(rdb.strPath)) { m_preLoadDic.Add(rdb.strPath, objList); } } } }
// 根据资源ID创建 public IRenerTextureObj CreateRenderTextureObj(int nResID, int nSize) { if (renderTexturePool == null) { return(null); } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)nResID); if (resDB == null) { Engine.Utility.Log.Error("创建模型资源路径配置{0}", nResID); return(null); } RenderTextureObj obj = new RenderTextureObj(++m_uIDSeed); if (!obj.Create(resDB.strPath, nSize, renderTexturePool)) { obj = null; return(null); } obj.SetYOffset(obj.GetID() * 10); return((IRenerTextureObj)obj); }
Transform CreateEffect(int num = 1) { Engine.IEffect m_effect = null; for (int i = 0; i < num; i++) { Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem(); if (rs != null) { table.ResourceDataBase rd = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(50007); if (rd == null) { return(null); } string path = rd.strPath; bool success = rs.CreateEffect(ref path, ref m_effect, OnCreateEffectEvent, Engine.TaskPriority.TaskPriority_Immediate); if (success) { m_effect.GetNode().SetScale(Vector3.one); m_effect.GetNode().GetTransForm().SetChildLayer(LayerMask.NameToLayer("UI")); } } } if (m_effect != null) { return(m_effect.GetNodeTransForm()); } return(null); }
private void OnCreateRenderObj(Engine.IRenderObj obj, object param) { if (m_EntityView == null) { return; } m_EntityView.SetRenderObj(obj); int nID = GetProp((int)EntityProp.BaseID); var table_data = GameTableManager.Instance.GetTableItem <table.HomeLandViewDatabase>((uint)nID, GetProp((int)HomeProp.State)); if (table_data == null) { Engine.Utility.Log.Error("不存在这个对象: " + nID); return; } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)table_data.dwModelID); if (resDB == null) { Engine.Utility.Log.Error("Homeland:找不到Homeland模型资源路径配置{0}", table_data.dwModelID); return; } //string strPartName = "main"; //string strResName = resDB.strPath; // m_EntityView.ChangePart( ref strPartName , ref strResName ); // 根据全局配置设置阴影 int nShadowLevel = EntitySystem.m_ClientGlobal.gameOption.GetInt("Render", "shadow", 1); m_EntityView.SetShadowLevel(nShadowLevel); }
/// <summary> /// 给没有实体的模型挂接特效 /// </summary> effect资源表id /// <param name="fxResID"></param> public void AddLinkEffectWithoutEntity(uint fxResID) { if (m_RenderObj != null) { table.FxResDataBase edb = GameTableManager.Instance.GetTableItem <table.FxResDataBase>(fxResID); if (edb != null) { ufxid = fxResID; AddLinkEffect node = new AddLinkEffect(); node.nFollowType = (int)edb.flowType; node.rotate = new Vector3(edb.rotate[0], edb.rotate[1], edb.rotate[2]); node.vOffset = new Vector3(edb.offset[0], edb.offset[1], edb.offset[2]); Quaternion rot = new Quaternion(); rot.eulerAngles = node.rotate; // 使用资源配置表 table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(edb.resPath); if (resDB == null) { Engine.Utility.Log.Error("EffectViewFactory:找不到特效资源路径配置{0}", edb.resPath); return; } node.strEffectName = resDB.strPath; node.strLinkName = edb.attachNode; m_RenderObj.AddLinkEffect(ref node.strEffectName, ref node.strLinkName, node.vOffset, rot, node.scale, (Engine.LinkFollowType)node.nFollowType); } } }
private void ApplyMaterial(Client.IPlayer pPlayer, uint uSuit) { table.SuitDataBase data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(uSuit); if (data == null) { return; } if (data.defaultMaterial == 0) { return; } table.ResourceDataBase res = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(data.defaultMaterial); if (res == null) { return; } if (res.strPath == "") { return; } Engine.IRenderObj renderObj = pPlayer.renderObj; if (renderObj != null) { renderObj.ApplyMaterial(res.strPath); } }
public void AddParticle(uint resId, Action <Engine.IEffect> oncomplete = null, Engine.EffectCallback endCallback = null) { //ReleaseParticle(); m_uResId = resId; Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem(); if (rs != null) { table.ResourceDataBase rd = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(resId); if (rd == null) { Engine.Utility.Log.Error("ID为{0}的资源为空", resId); return; } string path = rd.strPath; if (string.IsNullOrEmpty(path)) { return; } m_oncomplete = oncomplete; bool success = rs.CreateEffect(ref path, ref m_effect, OnCreateEffectEvent, Engine.TaskPriority.TaskPriority_Immediate, cb: endCallback); if (success) { UpdateEffectWidget(); } } }
//------------------------------------------------------------------------------------------------------- public override bool CreateEntityView(EntityCreateData data) { base.CreateEntityView(data); if (GetEntityType() != EntityType.EntityType_Box) { Engine.Utility.Log.Error("Box:CreateEntityView failed:{0}", GetName()); return(false); } int nID = GetProp((int)EntityProp.BaseID); string strResName = ""; var table_data = GameTableManager.Instance.GetTableItem <table.ItemDataBase>((uint)nID); if (table_data == null) { Engine.Utility.Log.Error("不存在这个NPC: " + nID); return(false); } if (nID == 0) { SetName(table_data.itemName + "X" + GetProp((int)BoxProp.Number)); } else { SetName(table_data.itemName); } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(table_data.dropIcon); if (resDB == null) { Engine.Utility.Log.Error("Box:找不到Box模型资源路径配置{0}", table_data.dropIcon); return(false); } strResName = resDB.strPath; string strPath, strFileName, strExt, strFileNameNoExt; Engine.Utility.StringUtility.ParseFileName(ref strResName, out strPath, out strFileName, out strFileNameNoExt, out strExt); m_strObjName = strFileNameNoExt; if (data.bImmediate) { // 立即创建 if (!m_EntityView.Create(ref strResName, OnCreateRenderObj)) { Engine.Utility.Log.Error("CreateEntityView failed:{0}", strResName); } } else { EntityViewCreator.Instance.AddView(GetUID(), m_EntityView, ref strResName, OnCreateRenderObj); } return(false); }
//------------------------------------------------------------------------------------------------------- public static string GetModelPath(uint uSuitID, Client.EquipPos pos, byte profession, byte sex) { var modelPath = ""; var table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(uSuitID); if (table_data == null) { int nSex = sex; // 根据职业、性别和部位去查找 var database = table.SelectRoleDataBase.Where((GameCmd.enumProfession)profession, (GameCmd.enmCharSex)nSex); if (database != null) { switch (pos) { case Client.EquipPos.EquipPos_Body: { var sult_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)database.bodyPathID); if (sult_data != null) { table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(sult_data.resid); if (db != null) { modelPath = db.strPath; } } break; } case Client.EquipPos.EquipPos_Weapon: { var sult_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)database.weaponPath); if (sult_data != null) { table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(sult_data.resid); if (db != null) { modelPath = db.strPath; } } break; } } } } else { table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(table_data.resid); if (db != null) { modelPath = db.strPath; } } return(modelPath); }
//自己 private void OnSceneLoadCompelete(int nEventId, object param) { Client.stLoadSceneComplete loadScene = (Client.stLoadSceneComplete)param; uint nMapID = (uint)loadScene.nMapID; m_nCurMapID = nMapID; table.MapDataBase mapDB = GameTableManager.Instance.GetTableItem <table.MapDataBase>(nMapID); if (mapDB == null) { return; } if (mapDB.dwMaterial == 0) { // 使用默认材质 Client.IPlayer pPlayer = Client.ClientGlobal.Instance().MainPlayer; if (pPlayer != null) { // 时装id uint uSuit = 0; List <GameCmd.SuitData> lstSuit = null; pPlayer.GetSuit(out lstSuit); if (lstSuit.Count > 0) { uSuit = lstSuit[0].baseid; ApplyMaterial(pPlayer, uSuit); } } } else { table.ResourceDataBase res = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(mapDB.dwMaterial); if (res == null) { return; } if (res.strPath == "") { return; } Engine.IRenderObj renderObj = Client.ClientGlobal.Instance().MainPlayer.renderObj; if (renderObj != null) { renderObj.ApplyMaterial(res.strPath); } } }
public override bool CreateEntityView(EntityCreateData data) { base.CreateEntityView(data); if (GetEntityType() != EntityType.EntityType_Monster) { Engine.Utility.Log.Error("CreateEntityView failed:{0}", GetName()); return(false); } int nID = GetProp((int)EntityProp.BaseID); string strResName = ""; if (nID == 0) { // 则使用默认数据 // strResName = data.strName; } else { var table_data = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)nID); if (table_data == null) { Engine.Utility.Log.Error("不存在这个NPC: " + nID); return(false); } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(table_data.dwModelSet); if (resDB == null) { Engine.Utility.Log.Error("NPC:找不到NPC模型资源路径配置{0}", table_data.dwModelSet); return(false); } strResName = resDB.strPath; SetName(table_data.strName); } string strPath, strFileName, strExt, strFileNameNoExt; Engine.Utility.StringUtility.ParseFileName(ref strResName, out strPath, out strFileName, out strFileNameNoExt, out strExt); m_strObjName = strFileNameNoExt; // TODO: 根据配置表读取数据 //if (!m_EntityView.Create(ref strResName, OnCreateRenderObj)) //{ // Engine.Utility.Log.Error("CreateEntityView failed:{0}", strResName); //} EntityViewCreator.Instance.AddView(GetUID(), m_EntityView, ref strResName, OnCreateRenderObj); return(false); }
/// <summary> /// 播放UI音效 /// </summary> /// <param name="audioID"></param> public void PlayUIAudioEffect(uint audioID) { if (audioID != 0) { Engine.IAudio audio = Engine.RareEngine.Instance().GetAudio(); if (audio != null) { table.ResourceDataBase rd = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)audioID); if (rd != null) { audio.PlayUIEffect(rd.strPath); } } } }
public bool SceneFileExists(uint mapid) { if (KDownloadInstance.Instance().IsSmallPackage() == false) { return(true); } table.MapDataBase mapDB = GameTableManager.Instance.GetTableItem <table.MapDataBase>(mapid); if (mapDB == null) { Engine.Utility.Log.Error("MapSystem:找不到地图配置数据{0}", mapid); return(false); } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(mapDB.dwResPath); if (resDB == null) { Engine.Utility.Log.Error("MapSystem:找不到地图资源路径配置{0}", mapDB.dwResPath); return(false); } string strMapName = resDB.strPath.ToLower(); if (Application.platform == RuntimePlatform.Android) { string strPath = System.IO.Path.Combine(Application.persistentDataPath + "/assets/", strMapName); bool exists = System.IO.File.Exists(strPath); if (exists == false) { strPath = System.IO.Path.Combine(Application.streamingAssetsPath, strMapName); exists = System.IO.File.Exists(strPath); } return(exists); } else if (Application.platform == RuntimePlatform.IPhonePlayer) { string strPath = Application.persistentDataPath + "/" + strMapName; bool exists = System.IO.File.Exists(strPath); if (exists == false) { strPath = System.IO.Path.Combine(Application.streamingAssetsPath, strMapName); exists = System.IO.File.Exists(strPath); } return(exists); } return(true); }
void AddNpcTip(Client.IEntity entity, uint effectId, uint nTaskId, GameCmd.TaskProcess process) { NpcTips tips; if (m_DictNpceffect.TryGetValue(entity.GetID(), out tips)) { if (tips.process == process) { return; } } table.FxResDataBase edb = GameTableManager.Instance.GetTableItem <table.FxResDataBase>(effectId); if (edb != null) { Client.AddLinkEffect node = new Client.AddLinkEffect(); table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(edb.resPath); if (resDB == null) { Engine.Utility.Log.Error("找不到特效资源路径配置{0}", edb.resPath); } node.strEffectName = resDB.strPath; node.strLinkName = edb.attachNode; node.nFollowType = (int)edb.flowType; node.rotate = new UnityEngine.Vector3(edb.rotate[0], edb.rotate[1], edb.rotate[2]); node.vOffset = new UnityEngine.Vector3(edb.offset[0], edb.offset[1], edb.offset[2]); node.strEffectName = resDB.strPath; node.strLinkName = edb.attachNode; if (node.strEffectName.Length != 0) { int eId = (int)entity.SendMessage(Client.EntityMessage.EntityCommand_AddLinkEffect, node); if (m_DictNpceffect.ContainsKey(entity.GetID())) { entity.SendMessage(Client.EntityMessage.EntityCommand_RemoveLinkEffect, m_DictNpceffect[entity.GetID()].effectid); m_DictNpceffect[entity.GetID()].effectid = eId; m_DictNpceffect[entity.GetID()].process = process; } else { m_DictNpceffect.Add(entity.GetID(), new NpcTips() { effectid = eId, npcid = entity.GetID(), taskid = nTaskId, process = process }); } } } }
public override bool CreateEntityView(EntityCreateData data) { base.CreateEntityView(data); //if (GetEntityType() != EntityType.EntityType_NPC) //{ // Engine.Utility.Log.Error("NPC:CreateEntityView failed:{0}", GetName()); // return false; //} int nID = GetProp((int)EntityProp.BaseID); string strResName = ""; if (nID == 0) { // 则使用默认数据 // strResName = data.strName; } else { var table_data = GameTableManager.Instance.GetTableItem <table.HomeLandViewDatabase>((uint)nID, GetProp((int)HomeProp.State)); if (table_data == null) { Engine.Utility.Log.Error("不存在这个对象: " + nID); return(false); } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)table_data.dwModelID); if (resDB == null) { Engine.Utility.Log.Error("Homeland:找不到Homeland模型资源路径配置{0}", table_data.dwModelID); return(false); } strResName = resDB.strPath; } SetName(data.strName); // TODO: 根据配置表读取数据 if (!m_EntityView.Create(ref strResName, OnCreateRenderObj)) { Engine.Utility.Log.Error("CreateEntityView failed:{0}", strResName); } return(false); }
public static SuitInfo GetResPathBySuitID(uint uSuitID, Client.EquipPos pos, uint profession, uint sex, uint skillStatu) { SuitInfo info = new SuitInfo(); info.pos = (SuitPos)pos; var table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(uSuitID); if (table_data == null) { GameCmd.enmCharSex nSex = (GameCmd.enmCharSex)GameUtil.FaceToSex(sex); // 根据职业、性别和部位去查找 var database = table.SelectRoleDataBase.Where((GameCmd.enumProfession)profession, (GameCmd.enmCharSex)nSex); if (database != null) { switch (pos) { case Client.EquipPos.EquipPos_Body: { table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)database.bodyPathID); break; } case Client.EquipPos.EquipPos_Weapon: { table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)database.weaponPath); break; } } } } if (table_data == null) { return(info); } uint viewID = skillStatu == 0?table_data.viewresid:table_data.viewresid2; table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(viewID); // 使用观察路径 if (db != null) { info.modelPath = db.strPath; info.locatorName = table_data.locator_name; } return(info); }
//------------------------------------------------------------------------------------------------------- public override bool CreateEntityView(EntityCreateData data) { base.CreateEntityView(data); //if (GetEntityType() != EntityType.EntityType_NPC) //{ // Engine.Utility.Log.Error("NPC:CreateEntityView failed:{0}", GetName()); // return false; //} int nID = GetProp((int)EntityProp.BaseID); string strResName = ""; if (nID == 0) { // 则使用默认数据 // strResName = data.strName; } else { int nModepathID = GameTableManager.Instance.GetClientGlobalConst <int>("Homeland", "PastureObjPath"); table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)nModepathID); if (resDB == null) { Engine.Utility.Log.Error("Homeland:找不到Homeland模型资源路径配置{0}", nModepathID); return(false); } strResName = resDB.strPath; } SetName(data.strName); string strPath, strFileName, strExt, strFileNameNoExt; Engine.Utility.StringUtility.ParseFileName(ref strResName, out strPath, out strFileName, out strFileNameNoExt, out strExt); m_strObjName = strFileNameNoExt; // TODO: 根据配置表读取数据 //if (!m_EntityView.Create(ref strResName, OnCreateRenderObj)) //{ // Engine.Utility.Log.Error("CreateEntityView failed:{0}", strResName); //} EntityViewCreator.Instance.AddView(GetUID(), m_EntityView, ref strResName, OnCreateRenderObj); return(false); }
void PlayAudio() { Transform trans = m_Owner.GetTransForm(); if (trans != null) { uint resID = 0; uint delayTime = 0; if (m_Owner.GetEntityType() == EntityType.EntityType_Player) { int profession = m_Owner.GetProp((int)PlayerProp.Job); int nSex = m_Owner.GetProp((int)PlayerProp.Sex); var database = table.SelectRoleDataBase.Where((GameCmd.enumProfession)profession, (GameCmd.enmCharSex)nSex); if (database != null) { resID = database.deadAudio; delayTime = database.deadAudioDelay; } } else { INPC npc = m_Owner as INPC; if (npc != null) { int baseID = npc.GetProp((int)EntityProp.BaseID); table.NpcDataBase db = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)baseID); if (db != null) { resID = db.dwDeathMagicSoundID; delayTime = db.dwDeathMagicSoundDelay; } } } if (resID != 0) { table.ResourceDataBase rdb = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(resID); if (rdb != null) { m_strAudioPath = rdb.strPath; TimerAxis.Instance().SetTimer(m_timerID, delayTime, this, 1); } } } }
private void OnCreateRenderObj(Engine.IRenderObj obj, object param) { if (m_EntityView == null) { return; } m_EntityView.SetRenderObj(obj); int nID = GetProp((int)EntityProp.BaseID); var table_data = GameTableManager.Instance.GetTableItem <table.HomeLandViewDatabase>((uint)nID, GetProp((int)HomeProp.State)); if (table_data == null) { Engine.Utility.Log.Error("不存在这个对象: " + nID); return; } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)table_data.dwModelID); if (resDB == null) { Engine.Utility.Log.Error("Homeland:找不到Homeland模型资源路径配置{0}", table_data.dwModelID); return; } string strPartName = "main"; string strResName = resDB.strPath; m_EntityView.ChangePart(ref strPartName, ref strResName); // 根据全局配置设置阴影 int nShadowLevel = EntitySystem.m_ClientGlobal.gameOption.GetInt("Render", "shadow", 1); m_EntityView.SetShadowLevel(nShadowLevel); Vector3 currPos = GetPos(); SetPos(ref currPos); //Client.stCreateEntity createEntity = new Client.stCreateEntity(); //createEntity.uid = GetUID(); //Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_CREATEENTITY, createEntity); }
public void OnTimer(uint uTimerID) { if (m_uTimerID == uTimerID) { if (preLoadNpcList.Count > 0) { uint resID = preLoadNpcList[0]; table.ResourceDataBase rdb = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(resID); if (rdb != null) { Engine.IRenderObj[] objList; Log.LogGroup("ZDY", "preload npc {0} num is {1}", rdb.strPath, m_uPreLoadNum); Engine.RareEngine.Instance().CacheRenderObj(rdb.strPath, 1, out objList); if (!m_preLoadDic.ContainsKey(rdb.strPath)) { m_preLoadDic.Add(rdb.strPath, objList); } } preLoadNpcList.RemoveAt(0); } if (preLoadMonsterList.Count > 0) { uint resID = preLoadMonsterList[0]; table.ResourceDataBase rdb = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(resID); if (rdb != null) { Engine.IRenderObj[] objList; Log.LogGroup("ZDY", "preload entity {0} num is {1}", rdb.strPath, m_uPreLoadNum); Engine.RareEngine.Instance().CacheRenderObj(rdb.strPath, m_uPreLoadNum, out objList); if (!m_preLoadDic.ContainsKey(rdb.strPath)) { m_preLoadDic.Add(rdb.strPath, objList); } } preLoadMonsterList.RemoveAt(0); } if (preLoadNpcList.Count == 0 && preLoadMonsterList.Count == 0) { TimerAxis.Instance().KillTimer(m_uTimerID, this); } } }
public override void FireEvent() { if (!AffectedObject) { return; } if (!Application.isPlaying && Application.isEditor) { } else { table.MapDataBase data = GameTableManager.Instance.GetTableItem <table.MapDataBase>(sceneID); if (data == null) { return; } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(data.dwResPath); if (resDB == null) { return; } Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem(); if (rs != null) { string str = resDB.strPath; Engine.IScene scene = rs.EnterScene(ref str, SequencerManager.Instance()); if (scene != null) { ///¼ÓÔس¡¾° SequencerManager.Instance().Pause(); scene.StartLoad(Vector3.one); //±£´æÏÂmapid Client.IMapSystem map = Client.ClientGlobal.Instance().GetMapSystem(); SequencerManager.Instance().m_MapID = map.GetMapID(); } } } }
/// <summary> /// 执行跳过 /// </summary> private void DoJump() { if (m_dialogInfo != null) { if (m_dialogInfo.talkVoice != null && m_dialogInfo.lstTalks.Count == m_dialogInfo.talkVoice.Length) { if (m_nindex == m_dialogInfo.talkVoice.Length - 1) { JumpEnd(); return; } Engine.IAudio audio = Engine.RareEngine.Instance().GetAudio(); if (audio != null && m_nPlayingAudioId != 0) { audio.StopEffect(m_nPlayingAudioId); } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(m_dialogInfo.talkVoice[m_dialogInfo.lstTalks.Count - 1]); if (resDB == null) { Engine.Utility.Log.Error("找不到选择角色的Mp3资源"); } if (audio != null && resDB != null) { //m_nPlayingAudioId = audio.PlayUIEffect(resDB.strPath); Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; Transform tf = mainPlayer.GetTransForm(); if (tf != null) { m_nPlayingAudioId = audio.PlayEffect(tf.gameObject, resDB.strPath, false, true); } } } } JumpEnd(); }
/// <summary> /// 获取模型信息 /// </summary> /// <param name="itemID"></param> /// <param name="pos">装备部位</param> /// <param name="profession">职业</param> /// <param name="faceID"></param> /// <param name="ifJudgeSex">是否需要职业</param> /// <returns></returns> public static string GetModelPath(ushort itemID, Client.EquipPos pos, byte profession, byte faceID, bool ifJudgeSex = true) { var modelPath = ""; //var tbl = Table.Query<table.ItemDatabase>().FirstOrDefault(i => i.dwID == itemID); //if (tbl == null) return modelPath; var table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(itemID); if (table_data == null) { int nSex = 1; if (ifJudgeSex) { //modelPath = GameUtil.FaceToSex(faceID) == GameCmd.enmCharSex.MALE ? tbl.wdMaleModelSetID.ToString() : tbl.wdFemaleModelSetID.ToString(); nSex = (int)GameUtil.FaceToSex(faceID); } // 根据职业、性别和部位去查找 var database = table.SelectRoleDataBase.Where((GameCmd.enumProfession)profession, (GameCmd.enmCharSex)nSex); if (database != null) { //Engine.Utility.Log.Error("BuildPlayerPropList:job{0}或者sex{1}数据非法!", data.mapnpcdata.npcdata.job, data.mapnpcdata.npcdata.sex); //return; switch (pos) { case Client.EquipPos.EquipPos_Body: { var sult_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)database.bodyPathID); if (sult_data != null) { table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(sult_data.resid); if (db != null) { modelPath = db.strPath; } } break; } case Client.EquipPos.EquipPos_Weapon: { var sult_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)database.weaponPath); if (sult_data != null) { table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(sult_data.resid); if (db != null) { modelPath = db.strPath; } } break; } } } } else { table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(table_data.resid); if (db != null) { modelPath = db.strPath; } } return(modelPath); }
public override bool CreateEntityView(EntityCreateData data) { //Profiler.BeginSample("CreateEntityView"); m_Data = data; base.CreateEntityView(data); if (GetEntityType() != EntityType.EntityType_Player) { m_bChangeRestore = false; Engine.Utility.Log.Error("CreateEntityView failed:{0}", GetName()); return(false); } string strResName = ""; //if (data.PropList != null) //{ // for (int i = 0; i < data.PropList.Length; ++i ) // { // if (data.PropList[i].nPropIndex == (int)PlayerProp.TransModelResId) // { int ntransModelID = GetProp((int)PlayerProp.TransModelResId);//.PropList[i].value; if (ntransModelID != 0) { table.ResourceDataBase resData = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>((uint)ntransModelID); if (resData != null) { strResName = resData.strPath; } } // break; // } // } //} table.SuitDataBase table_data = null; if (string.IsNullOrEmpty(strResName) && data.ViewList != null) { //Profiler.BeginSample("CreateEntityView:Table:Query"); for (int i = 0; i < data.ViewList.Length; ++i) { if (data.ViewList[i] == null) { continue; } if (data.ViewList[i].nPos == (int)EquipPos.EquipPos_Body) { table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)data.ViewList[i].value); if (table_data == null) { GameCmd.enumProfession profession = (GameCmd.enumProfession)GetProp((int)PlayerProp.Job); GameCmd.enmCharSex sex = (GameCmd.enmCharSex)GetProp((int)PlayerProp.Sex); var role_data = table.SelectRoleDataBase.Where(profession, sex); if (role_data == null) { Engine.Utility.Log.Error("CreateEntityView:job{0}或者sex{1}数据非法!", profession, sex); return(false); } table_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)role_data.bodyPathID); } if (table_data != null) { table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(table_data.resid); if (db == null) { Debug.LogError("ResourceDataBase is null bodypahtid is " + table_data.resid + " 请检查resource 表格"); return(false); } strResName = db.strPath; } //else //{ // strResName = ""; //} //if(m_EntityView!=null) //{ // m_EntityView.AddSuitData(EquipPos.EquipPos_Body, data.ViewList[i].value, (int)table_data.resid); //} } } //Profiler.EndSample(); } // 修改技能形态值 m_Data.eSkillState = (SkillSettingState)GetProp((int)PlayerProp.SkillStatus); // 设置名称 SetName(data.strName); string strPath, strFileName, strExt, strFileNameNoExt; Engine.Utility.StringUtility.ParseFileName(ref strResName, out strPath, out strFileName, out strFileNameNoExt, out strExt); m_strObjName = strFileNameNoExt; if (m_Data.bImmediate) { // 立即创建 if (!m_EntityView.Create(ref strResName, OnCreateRenderObj, m_Data.bImmediate)) { Engine.Utility.Log.Error("CreateEntityView failed:{0}", strResName); return(false); } } else { EntityViewCreator.Instance.AddView(GetUID(), m_EntityView, ref strResName, OnCreateRenderObj); } //Profiler.EndSample(); //Profiler.EndSample(); return(true); }
private void MovieEnd_Impl() { string strCameraName = "MainCamera"; Engine.ICamera cam = Engine.RareEngine.Instance().GetRenderSystem().GetCamera(ref strCameraName); if (cam == null) { return; } ///rotate cam.GetNode().GetTransForm().DORotate(new Vector3(38f, 45f, 0f), 3); ///fieldofview float fieldOfView = 30; Tween t = DOTween.To(() => fieldOfView, x => fieldOfView = x, 45, 3); // 给执行 t 变化时,每帧回调一次 UpdateTween 方法 t.OnUpdate(() => UpdateTween(fieldOfView)); /// fog float fFogStartDistance = 60; float fFogEndDistance = 250; RenderSettings.fogStartDistance = fFogStartDistance; RenderSettings.fogEndDistance = fFogEndDistance; Tween t1 = DOTween.To(() => fFogStartDistance, x => fFogStartDistance = x, 20, 3); t1.OnUpdate(() => UpdateFogStartDistance(fFogStartDistance)); Tween t2 = DOTween.To(() => fFogEndDistance, x => fFogEndDistance = x, 170, 3); t2.OnUpdate(() => UpdateFogEndDistance(fFogEndDistance)); // move Tweener tweener = cam.GetNode().GetTransForm().DOMove(newPos, 3f); //Audio table.ResourceDataBase rdb = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(45001); if (rdb != null) { PlayAudio(this.gameObject, rdb.strPath); } // Client.IPlayer pPlayer = Client.ClientGlobal.Instance().MainPlayer; if (pPlayer == null) { return; } tweener.OnComplete(() => { CameraFollow.Instance.camera = cam; pPlayer = Client.ClientGlobal.Instance().MainPlayer; CameraFollow.Instance.target = pPlayer; cam.SetCameraCtrl(CameraFollow.Instance); cam.SetFarClipPlane(140); if (post != null) { GameObject.DestroyImmediate(post); post = null; } UIManager.Instance.SetCameraState(true); Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem(); if (cs != null) { cs.GetActiveCtrl().SetHost(pPlayer); } Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.CAMERA_MOVE_END, null); }); }
bool ShowTalkStr(int nindex) { bool success = false; if (m_dialogInfo != null) { if (m_dialogInfo.buttons != null) { if (m_dialogInfo.buttons.Count < 2) { StopAllCoroutines(); //倒计时 tempTime = 0; CLOSETIME = CONST_TASK_CD; m_label_LabelNext.gameObject.SetActive(true); m_label_LabelNext.text = ((int)CLOSETIME).ToString() + "秒后自动跳过"; StartCoroutine(WaitToClose()); } else { m_label_LabelNext.gameObject.SetActive(false); } } } ResetDes(); if (m_dialogInfo != null) { if (m_dialogInfo.lstTalks != null) { if (nindex < m_dialogInfo.lstTalks.Count) { LangTalkData.Talk talkInfo = m_dialogInfo.lstTalks[nindex]; if (talkInfo.bUser) { string name = ""; if (Client.ClientGlobal.Instance().MainPlayer != null) { name = Client.ClientGlobal.Instance().MainPlayer.GetName(); } m_label_nameLabel.text = name; ShowRoleTexture(true); } else { table.NpcDataBase npcdata = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(m_dialogInfo.nNpcId); if (npcdata != null) { ShowRoleTexture(false, npcdata); m_label_nameLabel.text = npcdata.strName; } } bool useRichText = false;//富文本有泄漏bug 暂时不用 if (useRichText) { string desc = string.Format("<size value=\"24\"><color value=\"#1c2850\">{0} </color></size>", talkInfo.strText); if (uiXmlRichText != null) { this.uiXmlRichText.fontSize = 24; this.uiXmlRichText.AddXml(RichXmlHelper.RichXmlAdapt(desc)); } } else { string desc = string.Format("[1c2850]{0}[-]", talkInfo.strText); m_label_normalText.text = desc; } success = true; } } if (m_dialogInfo.talkVoice != null && nindex < m_dialogInfo.talkVoice.Length) { Engine.IAudio audio = Engine.RareEngine.Instance().GetAudio(); if (audio != null && m_nPlayingAudioId != 0) { audio.StopEffect(m_nPlayingAudioId); } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(m_dialogInfo.talkVoice[nindex]); if (resDB == null) { Engine.Utility.Log.Error("找不到选择角色的Mp3资源"); } if (audio != null && resDB != null) { //m_nPlayingAudioId = audio.PlayUIEffect(resDB.strPath); Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; if (mainPlayer != null) { Transform tf = mainPlayer.GetTransForm(); if (tf != null) { m_nPlayingAudioId = audio.PlayEffect(tf.gameObject, resDB.strPath, false, true); } } } } } //是否显示下一个 //bool nextVisible = (null != m_dialogInfo // && null != m_dialogInfo.lstTalks // && (m_dialogInfo.lstTalks.Count > nindex + 1)); //if (null != m_label_LabelNext && m_label_LabelNext.gameObject.activeSelf != nextVisible) //{ // m_label_LabelNext.gameObject.SetActive(nextVisible); //} return(success); }
//------------------------------------------------------------------------------------------------------- public override bool CreateEntityView(EntityCreateData data) { m_Data = data; base.CreateEntityView(data); if (GetEntityType() != EntityType.EntityType_NPC) { Engine.Utility.Log.Error("NPC:CreateEntityView failed:{0}", GetName()); return(false); } int nID = GetProp((int)EntityProp.BaseID); int suitID = GetProp((int)NPCProp.SuitID); int masterID = GetProp((int)NPCProp.Masterid); int type = GetProp((int)NPCProp.MasterType); IEntity en = EntityHelper.GetEntity((GameCmd.SceneEntryType)type, (uint)masterID); if (en != null) { if (EntityHelper.IsMainPlayer(en)) { m_isMySlave = true; } } string strResName = ""; if (nID == 0) { // 则使用默认数据 // strResName = data.strName; } else { var table_data = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)nID); if (table_data == null) { Engine.Utility.Log.Error("不存在这个NPC: " + nID); return(false); } m_bCanSelect = table_data.dwCanBeSelect == 1; if (m_Data.ViewList == null) { uint modelID = table_data.dwModelSet; if (suitID != 0) { table.SuitDataBase sdb = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)suitID, 1); if (sdb != null) { if (sdb.resid != 0) { modelID = sdb.resid; } } } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(modelID); if (resDB == null) { Engine.Utility.Log.Error("NPC:找不到NPC模型资源路径配置{0}", modelID); return(false); } strResName = resDB.strPath; } else { for (int i = 0; i < data.ViewList.Length; ++i) { if (data.ViewList[i] == null) { continue; } if (data.ViewList[i].nPos == (int)EquipPos.EquipPos_Body) { //if(data.ViewList[i].) var suit_data = GameTableManager.Instance.GetTableItem <table.SuitDataBase>((uint)data.ViewList[i].value); if (suit_data != null) { table.ResourceDataBase db = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(suit_data.resid); if (db == null) { Debug.LogError("ResourceDataBase is null bodypahtid is " + suit_data.resid + " 请检查resource 表格"); return(false); } //string bodyPath = db.strPath; //if (data.ViewList[i] != null) //{ // strResName = data.ViewList[i].value == 0 ? bodyPath : EntityHelper.GetModelPath((uint)data.ViewList[i].value, (Cmd.enmCharSex)GetProp((int)PlayerProp.Sex)); //} strResName = db.strPath; } else { strResName = ""; } } } } // 技能形态 m_Data.eSkillState = (SkillSettingState)GetProp((int)NPCProp.SkillStatus); if ((int)GameCmd.ArenaNpcType.ArenaNpcType_Player == GetProp((int)NPCProp.ArenaNpcType)) { SetName(m_Data.strName); } else { if (string.IsNullOrEmpty(data.strName)) { SetName(table_data.strName); } else { SetName(data.strName); } } if (IsSummon()) { IEntitySystem es = EntitySystem.m_ClientGlobal.GetEntitySystem(); if (es != null) { IPlayer player = es.FindEntity <IPlayer>((uint)masterID); if (player != null) { string playerName = player.GetName(); string summonName = GetName(); string tempName = playerName + "的" + summonName; SetName(tempName); } } } } // TODO: 根据配置表读取数据 //if ( !m_EntityView.Create( ref strResName , OnCreateRenderObj ) ) //{ // Engine.Utility.Log.Error( "CreateEntityView failed:{0}" , strResName ); //} string strPath, strFileName, strExt, strFileNameNoExt; Engine.Utility.StringUtility.ParseFileName(ref strResName, out strPath, out strFileName, out strFileNameNoExt, out strExt); m_strObjName = strFileNameNoExt; // 功能NPC立即创建 if (!IsMonster() && !IsPet() && !IsSummon()) { m_Data.bImmediate = true; } if (m_Data.bImmediate) { // 立即创建 if (!m_EntityView.Create(ref strResName, OnCreateRenderObj, false)) { Engine.Utility.Log.Error("CreateEntityView failed:{0}", strResName); } } else { EntityViewCreator.Instance.AddView(GetUID(), m_EntityView, ref strResName, OnCreateRenderObj); } return(false); }