/// <summary> /// 加载关卡配置 /// </summary> /// <param name="path"></param> private void LoadLevelFile(string path, bool async) { #if UNITY_EDITOR if (!System.IO.File.Exists(path)) { Neptune.DataManager.Instance.Data.Clear(); return; } #endif Neptune.Data data = null; if (data == null) { if (async) { MainGame.HeartBehavior.StartCoroutine(CoLoadLevelFile(path)); } else { data = LoadLevelFileTemporary(path); OnLevelLoadFinished(data); } } else { OnLevelLoadFinished(data); } }
/// <summary> /// 获取boss角色id列表 /// </summary> /// <param name="data"></param> /// <returns></returns> static public List <uint> GetBossMonsterList(Neptune.Data data = null) { if (data == null) { data = Neptune.DataManager.Instance.Data; } Dictionary <int, Neptune.BaseGenericNode> monsters = data.GetData <Neptune.MonsterBase>().Data; List <uint> actorIdList = new List <uint>(); actorIdList.Clear(); if (monsters != null) { foreach (var monsterBase in monsters.Values) { if (monsterBase is Neptune.Monster) { Neptune.Monster monster = (Neptune.Monster)monsterBase; if (ActorHelper.IsBoss(monster.ExcelId) == true) { actorIdList.Add(monster.ExcelId); } } } } return(actorIdList); }
static int _m_GetBossMonsterList_xlua_st_(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 1 && translator.Assignable <Neptune.Data>(L, 1)) { Neptune.Data data = (Neptune.Data)translator.GetObject(L, 1, typeof(Neptune.Data)); System.Collections.Generic.List <uint> __cl_gen_ret = xc.Dungeon.LevelObjectHelper.GetBossMonsterList(data); translator.Push(L, __cl_gen_ret); return(1); } if (__gen_param_count == 0) { System.Collections.Generic.List <uint> __cl_gen_ret = xc.Dungeon.LevelObjectHelper.GetBossMonsterList( ); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to xc.Dungeon.LevelObjectHelper.GetBossMonsterList!")); }
/// <summary> /// 临时的加载回调 /// </summary> /// <param name="data"></param> private void OnLevelLoadFinished(Neptune.Data data) { if (data == null) { return; } AreaExclude = mAreaDefault; Neptune.DataManager.Instance.Data = data; }
static int _g_get_mAllDatas(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { Neptune.Data __cl_gen_to_be_invoked = (Neptune.Data)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.mAllDatas); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(1); }
static int _s_set_PathManager(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { Neptune.Data __cl_gen_to_be_invoked = (Neptune.Data)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.PathManager = (Neptune.Path.PathManager)translator.GetObject(L, 2, typeof(Neptune.Path.PathManager)); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(0); }
static int _s_set_mAllDatas(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { Neptune.Data __cl_gen_to_be_invoked = (Neptune.Data)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.mAllDatas = (System.Collections.Generic.List <Neptune.Data.Container>)translator.GetObject(L, 2, typeof(System.Collections.Generic.List <Neptune.Data.Container>)); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(0); }
static public Vector3 GetTagPosition(uint id, Neptune.Data data = null) { if (data == null) { data = Neptune.DataManager.Instance.Data; } Neptune.Tag tagInfo = data.GetNode <Neptune.Tag>((int)id); if (tagInfo != null) { return(tagInfo.Position); } return(Vector3.zero); }
/// <summary> /// 根据怪物组id获取怪物的位置 /// </summary> /// <param name="id"></param> /// <param name="data"></param> /// <returns></returns> static public Vector3 GetMonsterPosition(uint id, Neptune.Data data = null) { if (data == null) { data = Neptune.DataManager.Instance.Data; } Neptune.MonsterBase monsterBase = data.GetNode <Neptune.MonsterBase>((int)id); if (monsterBase != null) { return(monsterBase.Position); } return(Vector3.zero); }
static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if (LuaAPI.lua_gettop(L) == 1) { Neptune.Data __cl_gen_ret = new Neptune.Data(); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to Neptune.Data constructor!")); }
/// <summary> /// 根据角色id获取怪物的位置 /// </summary> static public List <Vector3> GetMonsterPositionsByActorId(uint actorId, Neptune.Data data = null) { if (data == null) { data = Neptune.DataManager.Instance.Data; } Dictionary <int, Neptune.BaseGenericNode> monsters = data.GetData <Neptune.MonsterBase>().Data; List <Vector3> retPositions = new List <Vector3>(); retPositions.Clear(); if (monsters != null) { foreach (var monsterBase in monsters.Values) { if (monsterBase is Neptune.Monster) { Neptune.Monster monster = (Neptune.Monster)monsterBase; if (monster != null && monster.ExcelId == actorId) { retPositions.Add(monster.Position); } } else if (monsterBase is Neptune.MonsterGroup) { Neptune.MonsterGroup monsterGroup = (Neptune.MonsterGroup)monsterBase; if (monsterGroup != null) { List <string> strs = DBManager.Instance.QuerySqliteField <string>(GlobalConfig.DBFile, "data_monster", "id", monsterGroup.ExcelId.ToString(), "actor"); foreach (string str in strs) { uint ret = 0; uint.TryParse(str, out ret); if (ret == actorId) { retPositions.Add(monsterGroup.Position); break; } } } } } } return(retPositions); }
public static string GetNpcName(uint instanceId, uint npcJsonId) { if (instanceId == 0) { instanceId = SceneHelp.Instance.CurSceneID; } Neptune.Data levelData = xc.Dungeon.LevelManager.Instance.LoadLevelFileTemporary(SceneHelp.GetFirstStageId(instanceId)); if (levelData != null) { Neptune.NPC npcInfo = levelData.GetNode <Neptune.NPC>((int)npcJsonId); if (npcInfo != null) { return(RoleHelp.GetActorName(NpcHelper.MakeNpcDefine(npcInfo.ExcelId).ActorId)); } } return(string.Empty); }
/// <summary> /// 获取指定tag的位置 /// </summary> /// <returns></returns> static public List <Vector3> GetTagPositionsByType(string type, Neptune.Data data = null) { if (data == null) { data = Neptune.DataManager.Instance.Data; } List <Vector3> posList = new List <Vector3>(); posList.Clear(); List <Neptune.Tag> tagList = Neptune.DataHelper.GetTagListByType(data, type); foreach (Neptune.Tag tag in tagList) { posList.Add(tag.Position); } return(posList); }
static int _m_Clear(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Neptune.Data __cl_gen_to_be_invoked = (Neptune.Data)translator.FastGetCSObj(L, 1); try { { __cl_gen_to_be_invoked.Clear( ); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_RegisterData(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Neptune.Data __cl_gen_to_be_invoked = (Neptune.Data)translator.FastGetCSObj(L, 1); try { { System.Type node_type = (System.Type)translator.GetObject(L, 2, typeof(System.Type)); __cl_gen_to_be_invoked.RegisterData(node_type); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
/// <summary> /// 协程加载关卡配置 /// </summary> /// <param name="path"></param> /// <returns></returns>\ private IEnumerator CoLoadLevelFile(string path) { SGameEngine.AssetResource result = new SGameEngine.AssetResource(); yield return(MainGame.HeartBehavior.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_asset(path, typeof(TextAsset), result))); if (result.asset_ == null) { yield break; } TextAsset textAsset = result.asset_ as TextAsset; if (textAsset == null || textAsset.text == null) { result.destroy(); Debug.LogError("LevelManager::CoLoadLevelFile, can not read level file:" + path); yield break; } Neptune.Data data = new Neptune.Data(); FullSerializer.fsData fsdata = FullSerializer.fsJsonParser.Parse(textAsset.text); var serializer = new FullSerializer.fsSerializer(); var processor = new Neptune.FileSerializerProcessor(); serializer.AddProcessor(processor); serializer.TryDeserialize <Neptune.Data>(fsdata, ref data); if (data == null) { result.destroy(); yield break; } OnLevelLoadFinished(data); ObjCachePoolMgr.Instance.RecycleCSharpObject(data, ObjCachePoolType.JSON, path); result.destroy(); }
static int _m_GetTagPositionsByType_xlua_st_(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && translator.Assignable <Neptune.Data>(L, 2)) { string type = LuaAPI.lua_tostring(L, 1); Neptune.Data data = (Neptune.Data)translator.GetObject(L, 2, typeof(Neptune.Data)); System.Collections.Generic.List <UnityEngine.Vector3> __cl_gen_ret = xc.Dungeon.LevelObjectHelper.GetTagPositionsByType(type, data); translator.Push(L, __cl_gen_ret); return(1); } if (__gen_param_count == 1 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)) { string type = LuaAPI.lua_tostring(L, 1); System.Collections.Generic.List <UnityEngine.Vector3> __cl_gen_ret = xc.Dungeon.LevelObjectHelper.GetTagPositionsByType(type); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to xc.Dungeon.LevelObjectHelper.GetTagPositionsByType!")); }
static int _m_GetDistanceBetweenLocalPlayerAndTag_xlua_st_(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1) && translator.Assignable <Neptune.Data>(L, 2)) { uint id = LuaAPI.xlua_touint(L, 1); Neptune.Data data = (Neptune.Data)translator.GetObject(L, 2, typeof(Neptune.Data)); float __cl_gen_ret = xc.Dungeon.LevelObjectHelper.GetDistanceBetweenLocalPlayerAndTag(id, data); LuaAPI.lua_pushnumber(L, __cl_gen_ret); return(1); } if (__gen_param_count == 1 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1)) { uint id = LuaAPI.xlua_touint(L, 1); float __cl_gen_ret = xc.Dungeon.LevelObjectHelper.GetDistanceBetweenLocalPlayerAndTag(id); LuaAPI.lua_pushnumber(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to xc.Dungeon.LevelObjectHelper.GetDistanceBetweenLocalPlayerAndTag!")); }
/// <summary> /// 根据角色id获取最近怪物的位置 /// </summary> static public Vector3 GetNearestMonsterPositionByActorId(uint actorId, Neptune.Data data = null) { List <Vector3> posList = GetMonsterPositionsByActorId(actorId, data); Actor localPlayer = Game.GetInstance().GetLocalPlayer(); if (localPlayer != null) { Vector3 nearestPos = Vector3.zero; Transform localPlayerTrans = localPlayer.transform; if (posList.Count > 0) { float minDistance = Vector3.Distance(localPlayerTrans.position, posList[0]); nearestPos = posList[0]; foreach (Vector3 pos in posList) { float distance = Vector3.Distance(localPlayerTrans.position, pos); if (minDistance > distance) { minDistance = distance; nearestPos = pos; } } return(nearestPos); } else { return(nearestPos); } } else if (posList.Count > 0) { return(posList[0]); } else { return(Vector3.zero); } }
static int _m_GetNearestMonsterPositionByActorId_xlua_st_(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1) && translator.Assignable <Neptune.Data>(L, 2)) { uint actorId = LuaAPI.xlua_touint(L, 1); Neptune.Data data = (Neptune.Data)translator.GetObject(L, 2, typeof(Neptune.Data)); UnityEngine.Vector3 __cl_gen_ret = xc.Dungeon.LevelObjectHelper.GetNearestMonsterPositionByActorId(actorId, data); translator.PushUnityEngineVector3(L, __cl_gen_ret); return(1); } if (__gen_param_count == 1 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1)) { uint actorId = LuaAPI.xlua_touint(L, 1); UnityEngine.Vector3 __cl_gen_ret = xc.Dungeon.LevelObjectHelper.GetNearestMonsterPositionByActorId(actorId); translator.PushUnityEngineVector3(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to xc.Dungeon.LevelObjectHelper.GetNearestMonsterPositionByActorId!")); }
static int _m_GetDataAtIndex(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Neptune.Data __cl_gen_to_be_invoked = (Neptune.Data)translator.FastGetCSObj(L, 1); try { { int index = LuaAPI.xlua_tointeger(L, 2); Neptune.Data.Container __cl_gen_ret = __cl_gen_to_be_invoked.GetDataAtIndex(index); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_LoadLevelFileTemporary(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); xc.Dungeon.LevelManager __cl_gen_to_be_invoked = (xc.Dungeon.LevelManager)translator.FastGetCSObj(L, 1); try { { uint id = LuaAPI.xlua_touint(L, 2); Neptune.Data __cl_gen_ret = __cl_gen_to_be_invoked.LoadLevelFileTemporary(id); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
Neptune.Data LoadLevelFileTemporary(string path) { Neptune.Data data = null; if (m_NepCache.TryGetValue(path, out data)) { return(data); } string text = DBManager.Instance.LoadDBFile(path.Replace("Assets/Res/", "")); if (string.IsNullOrEmpty(text) == true) { return(null); } data = new Neptune.Data(); FullSerializer.fsData fsdata = FullSerializer.fsJsonParser.Parse(text); var serializer = new FullSerializer.fsSerializer(); var processor = new Neptune.FileSerializerProcessor(); serializer.AddProcessor(processor); serializer.TryDeserialize <Neptune.Data>(fsdata, ref data); if (data == null) { return(null); } if (m_NepCache.Count >= 3) { string first_path = m_NepPath.Dequeue(); m_NepCache.Remove(first_path); } m_NepCache[path] = data; m_NepPath.Enqueue(path); return(data); }
/// <summary> /// 获取本地玩家到指定id的tag的距离 /// </summary> /// <param name="id"></param> /// <param name="data"></param> /// <returns></returns> static public float GetDistanceBetweenLocalPlayerAndTag(uint id, Neptune.Data data = null) { if (data == null) { data = Neptune.DataManager.Instance.Data; } Actor localPlayer = Game.Instance.GetLocalPlayer(); if (localPlayer == null) { return(float.MaxValue); } Neptune.Tag tagInfo = data.GetNode <Neptune.Tag>((int)id); if (tagInfo != null) { return(Vector3.Distance(localPlayer.ActorTrans.position, tagInfo.Position)); } else { return(float.MaxValue); } }
/// <summary> /// 获取指定id和type的tag的位置 /// </summary> /// <param name="idAndType">id和type的字符串组合,例如boss_pos_2</param> /// <param name="data"></param> /// <returns></returns> static public Vector3 GetTagPosition(string idAndType, Neptune.Data data = null) { if (data == null) { data = Neptune.DataManager.Instance.Data; } var tag_data = data.GetData <Neptune.Tag>().Data; // 解析idAndType中的id int id = -1; int digit_place = 1; int type_length = -1; int num_0 = (int)'0'; for (int i = idAndType.Length - 1; i >= 0; --i) { char c = idAndType[i]; if (c >= '0' && c <= '9') { if (id == -1) { id = digit_place * ((int)c - num_0); } else { id += digit_place * ((int)c - num_0); } digit_place *= 10; } else if (c == '_') { type_length = i; break; } } Neptune.BaseGenericNode node_info = null; if (!tag_data.TryGetValue(id, out node_info)) { return(Vector3.zero); } Neptune.Tag tag_info = node_info as Neptune.Tag; if (tag_info != null) { // 判断类型是否相同 string type = tag_info.Type; for (int i = 0; i < type.Length && i < type_length; ++i) { char c1 = type[i]; char c2 = idAndType[i]; if (c1 != c2) { return(Vector3.zero); } } return(tag_info.Position); } else { return(Vector3.zero); } }
uint CalcTargetNum(uint instanceId, string targetStr) { uint targetNum = 0; Neptune.Data levelData = xc.Dungeon.LevelManager.Instance.LoadLevelFileTemporary(SceneHelp.GetFirstStageId(instanceId)); if (levelData == null) { return(targetNum); } if (targetStr == "kill_all") { Dictionary <int, Neptune.BaseGenericNode> monsters = levelData.GetData <Neptune.MonsterBase>().Data; foreach (var monsterBase in monsters.Values) { if (monsterBase is Neptune.Monster) { ++targetNum; } else if (monsterBase is Neptune.MonsterGroup) { Neptune.MonsterGroup monsterGroup = (Neptune.MonsterGroup)monsterBase; DBMonster dbMonster = DBManager.Instance.GetDB <DBMonster>(); DBMonster.MonsterInfo monsterInfo = dbMonster.GetMonsterInfo(monsterGroup.ExcelId); if (monsterInfo != null) { targetNum += monsterInfo.Num; } } } } else { var matchs = System.Text.RegularExpressions.Regex.Matches(targetStr, @"\{kill,(\S+)\}"); foreach (System.Text.RegularExpressions.Match match in matchs) { if (match.Success) { List <uint> ids = DBTextResource.ParseArrayUint(match.Groups[1].Value, ","); foreach (uint id in ids) { Dictionary <int, Neptune.BaseGenericNode> monsters = levelData.GetData <Neptune.MonsterBase>().Data; foreach (var monsterBase in monsters.Values) { if (monsterBase.Id == id) { if (monsterBase is Neptune.Monster) { ++targetNum; } else if (monsterBase is Neptune.MonsterGroup) { Neptune.MonsterGroup monsterGroup = (Neptune.MonsterGroup)monsterBase; DBMonster dbMonster = DBManager.Instance.GetDB <DBMonster>(); DBMonster.MonsterInfo monsterInfo = dbMonster.GetMonsterInfo(monsterGroup.ExcelId); if (monsterInfo != null) { targetNum += monsterInfo.Num; } } } } } } } } return(targetNum); }