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); }
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); }