/* 文件名:AssetManager.nut 路径:User/Asset/AssetManager.nut 创建日期:2024-11-24 08:44 文件用途: 资源管理器 */ class _AssetManager_ { //角色列表 CharacterList = null; //角色信息表 CharacterInfoList = null; //地图列表 MapList = null; //城镇列表 TownList = null; //装备列表 EquipmentList = null; //消耗品列表 StackableList = null; //NPC列表 NpcList = null; function InitMapList() { MapList = ScriptData.GetFileData("map/map.lst", function(DataTable, Data) { while (!Data.Eof()) { local Key = Data.Get(); DataTable.rawset(Key, Data.Get()); } if (_DEBUG_) print("加载地图List完成, 共" + DataTable.len() + "个"); }); } function InitCharacter() { CharacterList = ScriptData.GetFileData("character/character.lst", function(DataTable, Data) { local dirpath = DataTable.filepath.slice(0, DataTable.filepath.lastfind("/") + 1); while (!Data.Eof()) { local Index = Data.Get(); local Path = Data.Get(); DataTable.rawset(Index, dirpath + Path.tolower()); } if (_DEBUG_) print("加载角色List完成, 共" + DataTable.len() + "个"); }); CharacterInfoList = []; foreach(Index, Path in CharacterList) { if (Index == "filepath") continue; local Info = ScriptData.GetFileData(Path, function(DataTable, Data) { local dirpath = DataTable.filepath.slice(0, DataTable.filepath.lastfind("/") + 1); while (!Data.Eof()) { local Key = Data.Get(); if (Key == "[job]") { DataTable.job <- Data.Get().slice(1, -1); } else if (Key == "[growtype name]") { DataTable.growtype <- array(6, {}); for (local i = 0; i< 5; i++) { local name = Data.Get(); DataTable.growtype[i].name <- name; } } //默认时装 else if (Key == "[default avatar]") { DataTable.default_avatar <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/default avatar]") break; DataTable.default_avatar.append(Ret); } } //基础属性 else if (Key == "[HP MAX]]" || Key == "[MP MAX]]" || Key == "[physical attack]]" || Key == "[physical defense]]" || Key == "[magical attack]]" || Key == "[magical defense]]" || Key == "[inventory limit]]" || Key == "[MP regen speed]]" || Key == "[move speed]]" || Key == "[attack speed]]" || Key == "[cast speed]]" || Key == "[hit recovery]]" || Key == "[jump power]]" || Key == "[weight]]" || Key == "[jump speed]]") { local RealKey = Key.slice(1, Key.len() - 1); DataTable[RealKey] <- Data.Get().tofloat(); } //基础Ani else if (Key == "[waiting motion]" || Key == "[move motion]" || Key == "[sit motion]" || Key == "[damage motion 1]" || Key == "[damage motion 2]" || Key == "[down motion]" || Key == "[overturn motion]" || Key == "[jump motion]" || Key == "[jumpattack motion]" || Key == "[rest motion]" || Key == "[throw motion 1-1]" || Key == "[throw motion 1-2]" || Key == "[throw motion 2-1]" || Key == "[throw motion 2-2]" || Key == "[throw motion 3-1]" || Key == "[throw motion 3-2]" || Key == "[throw motion 4-1]" || Key == "[throw motion 4-2]" || Key == "[dash motion]" || Key == "[dashattack motion]" || Key == "[getitem motion]" || Key == "[buff motion]" || Key == "[simple rest motion]" || Key == "[simple move motion]" || Key == "[back motion]") { local RealKey = Key.slice(1, Key.len() - 1); DataTable[RealKey] <- dirpath + Data.Get().tolower(); } //普攻Ani else if (Key == "[attack motion]") { DataTable.attack_motion <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/attack motion]") break; DataTable.attack_motion.append(dirpath + Ret.tolower()); } } //进阶Ani else if (Key == "[etc motion]") { DataTable.etc_motion <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/etc motion]") break; DataTable.etc_motion.append(dirpath + Ret.tolower()); } } //基础Atk else if (Key == "[jumpattack info]" || Key == "[dashattack info]") { local RealKey = Key.slice(1, Key.len() - 1); DataTable[RealKey] <- (dirpath + Data.Get().tolower()); } //普攻Atk else if (Key == "[attack info]") { DataTable.attack_info <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/attack info]") break; DataTable.attack_info.append(dirpath + Ret.tolower()); } } //进阶Atk else if (Key == "[etc attack info]") { DataTable.etc_attack_info <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/etc attack info]") break; DataTable.etc_attack_info.append(dirpath + Ret.tolower()); } } } // print(DataTable); if (_DEBUG_) print("初始化角色" + DataTable.job); }); CharacterInfoList.push(Info); } } function InitEquipmentList() { EquipmentList = ScriptData.GetFileData("equipment/equipment.lst", function(DataTable, Data) { while (!Data.Eof()) { local Key = Data.Get(); //注册装备列表 路径写入 数据未读取 DataTable.rawset(Key, { Path = Data.Get(), Data = null }); } if (_DEBUG_) print("加载装备List完成, 共" + DataTable.len() + "个"); }); //顺带初始化装备信息标签tag配置 GameItem.EquipmentInfoTag = ScriptData.GetFileData("equipment/equipmentinfo.etc", function(DataTable, Data) { while (!Data.Eof()) { local Pack = Data.Get(); //名称 grade 套装Id 稀有度 最低穿戴登记 重量 if (Pack == "[item group name table]") { DataTable.item_group_name_table <- {}; while (true) { local Ret = Data.Get(); if (Ret == "[/item group name table]") break; DataTable.item_group_name_table.rawset(Ret, Data.Get()); } } else if (Pack == "[elemental property tag]") { DataTable.elemental_property_tag <- {}; while (true) { local Ret = Data.Get(); if (Ret == "[/elemental property tag]") break; DataTable.elemental_property_tag.rawset(Ret, Data.Get()); } } else if (Pack == "[rarity frame color idx]") { DataTable.rarityframe_color_idx <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/rarity frame color idx]") break; DataTable.rarityframe_color_idx.push(Ret); } } else if (Pack == "[rarity name tag]") { DataTable.rarity_name_tag <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/rarity name tag]") break; DataTable.rarity_name_tag.push(Ret); } } else if (Pack == "[rarity color]") { DataTable.rarity_color <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/rarity color]") break; local color = HexStringToInt(Ret); DataTable.rarity_color.push(color); } } else if (Pack == "[percentage text]") { DataTable.percentage_text <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/percentage text]") break; DataTable.percentage_text.push(Ret); } } else if (Pack == "[percentage range boundaries]") { DataTable.percentage_range_boundaries <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/percentage range boundaries]") break; DataTable.percentage_range_boundaries.push(Ret); } } else if (Pack == "[trade type text]") { DataTable.trade_type_text <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/trade type text]") break; DataTable.trade_type_text.push(Ret); } } else if (Pack == "[trade type color]") { DataTable.trade_type_color <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/trade type color]") break; local color = HexStringToInt(Ret); DataTable.trade_type_color.push(color); } } } }); } function InitStackableList() { StackableList = ScriptData.GetFileData("stackable/stackable.lst", function(DataTable, Data) { while (!Data.Eof()) { local Key = Data.Get(); //注册装备列表 路径写入 数据未读取 DataTable.rawset(Key, { Path = Data.Get(), Data = null }); } if (_DEBUG_) print("加载消耗品List完成, 共" + DataTable.len() + "个"); }); } function InitNpcList() { NpcList = ScriptData.GetFileData("npc/npc.lst", function(DataTable, Data) { while (!Data.Eof()) { local Key = Data.Get(); //注册NPC列表 路径写入 数据未读取 DataTable.rawset(Key, { Path = Data.Get(), Data = null }); } if (_DEBUG_) print("加载NPCList完成, 共" + DataTable.len() + "个"); }); } function InitTownList() { TownList = ScriptData.GetFileData("town/town.lst", function(DataTable, Data) { while (!Data.Eof()) { local Key = Data.Get(); //注册城镇列表 路径写入 数据未读取 DataTable.rawset(Key, { Path = Data.Get(), Data = null }); } if (_DEBUG_) print("加载城镇List完成, 共" + DataTable.len() + "个"); }); } constructor() { //初始化城镇列表 InitTownList(); //初始化地图列表 InitMapList(); //初始化角色 InitCharacter(); //初始化装备列表 InitEquipmentList(); //初始化消耗品列表 InitStackableList(); //初始化NPC列表 InitNpcList(); getroottable().AssetManager <- this; } //Public:: //获取装备信息 function GetEquipment(Idx) { //如果没有这件装备则返回 if (!(EquipmentList.rawin(Idx))) return; //如果装备数据已经读取过存在了则直接返回 if (EquipmentList[Idx].Data) return EquipmentList[Idx].Data; local Path = EquipmentList[Idx].Path; local m_data = ScriptData.GetFileData("equipment/" + Path, function(DataTable, Data) { DataTable.DirPath <- DataTable.filepath.slice(0, DataTable.filepath.lastfind("/") + 1); while (!Data.Eof()) { local Pack = Data.Get(); //名称 grade 套装Id 稀有度 最低穿戴登记 重量 组名 购买价格 出售价格 耐久 名望 四维 所有属强 四属强 双暴 命中 四属抗 属性攻击 if (Pack == "[name]" || Pack == "[part set index]" || Pack == "[grade]" || Pack == "[rarity]" || Pack == "[minimum level]" || Pack == "[weight]" || Pack == "[item group name]" || Pack == "[price]" || Pack == "[repair price]" || Pack == "[value]" || Pack == "[durability]" || Pack == "[physical attack]" || Pack == "[magical attack]" || Pack == "[physical defense]" || Pack == "[magical defense]" || Pack == "[all elemental attack]" || Pack == "[dark attack]" || Pack == "[light attack]" || Pack == "[water attack]" || Pack == "[fire attack]" || Pack == "[attack speed]" || Pack == "[cast speed]" || Pack == "[move speed]" || Pack == "[physical critical hit]" || Pack == "[magical critical hit]" || Pack == "[stuck]" || Pack == "[fire resistance]" || Pack == "[dark resistance]" || Pack == "[light resistance]" || Pack == "[water resistance]" || Pack == "[elemental property]" || Pack == "[flavor text]") { local RealKey = Pack.slice(1, -1); DataTable[RealKey] <- Data.Get(); } //适用角色 else if (Pack == "[usable job]") { DataTable.usable_job <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/usable job]") break; DataTable.usable_job.append(Ret.slice(1, -1).tolower()); } } //读取三攻 和 双防 else if (Pack == "[equipment physical attack]" || Pack == "[equipment magical attack]" || Pack == "[separate attack]" || Pack == "[equipment physical defense]" || Pack == "[equipment magical defense]") { local RealKey = Pack.slice(1, -1); DataTable[RealKey] <- [Data.Get(), Data.Get()]; } //图标 else if (Pack == "[icon]") { DataTable.icon <- {}; local Ret = Data.Get(); DataTable.icon.path <- "sprite/" + Ret.tolower(); Ret = Data.Get(); DataTable.icon.index <- Ret.tointeger(); } //装备类型 else if (Pack == "[equipment type]") { DataTable.type <- {}; local Ret = Data.Get(); DataTable.type.path <- Ret.tolower().slice(1, -1); Ret = Data.Get(); DataTable.type.index <- Ret.tointeger(); } //光环效果 else if (Pack == "[aurora graphic effects]") { DataTable.aurora_effects <- []; local Count = Data.Get(); for (local i = 0; i< Count; i++) { local T = { type = Data.Get(), path = Data.Get().tolower() } DataTable.aurora_effects.push(T); } } //Ani else if (Pack == "[animation job]") { local Job = Data.Get().slice(1, -1); if (!(DataTable.rawin("Ani"))) DataTable["Ani"] <- {}; DataTable["Ani"]["Ani_" + Job] <- {}; Data.Get(); local Index1 = Data.Get(); local Index2 = Data.Get(); DataTable["Ani"]["Ani_" + Job].variation <- [Index1, Index2]; DataTable["Ani"]["Ani_" + Job].layer_variation <- []; while (true) { local Ret = Data.Get(); if (Ret == "[animation job]" || (endswith(Ret, "]") && Ret != "[equipment ani script]" && Ret != "[layer variation]")) { Data.Pos--; break; } else if (Ret == "[layer variation]") { local InfoBuf = {}; InfoBuf.Zorder <- Data.Get(); InfoBuf.Path <- Data.Get(); DataTable["Ani"]["Ani_" + Job].layer_variation.append(InfoBuf); } } } } }); EquipmentList[Idx].Data = m_data; return m_data; } //获取消耗品信息 function GetStackable(Idx) { //如果没有这件消耗品则返回 if (!(StackableList.rawin(Idx))) return; //如果装备数据已经读取过存在了则直接返回 if (StackableList[Idx].Data) return StackableList[Idx].Data; local Path = StackableList[Idx].Path; local m_data = ScriptData.GetFileData("stackable/" + Path, function(DataTable, Data) { DataTable.DirPath <- DataTable.filepath.slice(0, DataTable.filepath.lastfind("/") + 1); while (!Data.Eof()) { local Pack = Data.Get(); //名称 if (Pack == "[name]" || Pack == "[item group name]" || Pack == "[explain]") { local RealKey = Pack.slice(1, -1); DataTable[RealKey] <- Data.Get(); } //适用角色 else if (Pack == "[usable job]") { DataTable.usable_job <- []; while (true) { local Ret = Data.Get(); if (Ret == "[/usable job]") break; DataTable.usable_job.append(Ret.slice(1, -1).tolower()); } } //图标 else if (Pack == "[icon]") { DataTable.icon <- {}; local Ret = Data.Get(); DataTable.icon.path <- "sprite/" + Ret.tolower(); Ret = Data.Get(); DataTable.icon.index <- Ret.tointeger(); } //消耗品类型 else if (Pack == "[stackable type]") { DataTable.type <- {}; local Ret = Data.Get(); DataTable.type.path <- Ret.tolower().slice(1, -1); Ret = Data.Get(); DataTable.type.index <- Ret.tointeger(); } //交易类型 else if (Pack == "[attach type]") { local Ret = Data.Get(); if (Ret == "[free]") DataTable.trade_type <- 0; else if (Ret == "[trade]") DataTable.trade_type <- 1; else if (Ret == "[sealing]") DataTable.trade_type <- 2; else if (Ret == "[account]") DataTable.trade_type <- 3; } } }); StackableList[Idx].Data = m_data; return m_data; } //Public:: //获取NPC信息 function GetNpc(Idx) { //如果没有这个NPC则返回 if (!(NpcList.rawin(Idx))) return; //如果NPC数据已经读取过存在了则直接返回 if (NpcList[Idx].Data) return NpcList[Idx].Data; local Path = NpcList[Idx].Path; local m_data = ScriptData.GetFileData("npc/" + Path, function(DataTable, Data) { DataTable.DirPath <- DataTable.filepath.slice(0, DataTable.filepath.lastfind("/") + 1); while (!Data.Eof()) { local Pack = Data.Get(); //各种头像 if (Pack == "[small face]" || Pack == "[big face]" || Pack == "[popup face]") { local RealKey = Pack.slice(1, Pack.find(" face")) + "_face"; DataTable[RealKey] <- { img = Data.Get().tolower(), idx = Data.Get() } } else if (Pack == "[field animation]") { DataTable.field_animation <- DataTable.DirPath + Data.Get().tolower(); } else if (Pack == "[field wav]") { DataTable.field_wav <- Data.Get(); } else if (Pack == "[popup wav]") { DataTable.popup_wav <- [Data.Get(), Data.Get()]; } else if (Pack == "[name]") { DataTable.name <- Data.Get(); } else if (Pack == "[field name]") { DataTable.field_name <- Data.Get(); } //功能 else if (Pack == "[role]") { DataTable.role <- {}; while (true) { local Ret = Data.Get(); if (Ret == "[/role]") break; DataTable.role.rawset(Ret.slice(1, -1).tolower(), Data.Get()); } } } }); NpcList[Idx].Data = m_data; return m_data; } }