2024-12-11 15:08:57 +08:00
|
|
|
/*
|
|
|
|
|
文件名:AssetManager.nut
|
|
|
|
|
路径:User/Asset/AssetManager.nut
|
|
|
|
|
创建日期:2024-11-24 08:44
|
|
|
|
|
文件用途: 资源管理器
|
|
|
|
|
*/
|
|
|
|
|
class _AssetManager_ {
|
|
|
|
|
|
|
|
|
|
//角色列表
|
|
|
|
|
CharacterList = null;
|
|
|
|
|
//角色信息表
|
|
|
|
|
CharacterInfoList = null;
|
|
|
|
|
//地图列表
|
|
|
|
|
MapList = null;
|
2024-12-25 11:32:34 +08:00
|
|
|
//城镇列表
|
|
|
|
|
TownList = null;
|
2024-12-12 14:51:27 +08:00
|
|
|
//装备列表
|
|
|
|
|
EquipmentList = null;
|
2024-12-11 15:08:57 +08:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-15 20:23:11 +08:00
|
|
|
//默认时装
|
|
|
|
|
else if (Key == "[default avatar]") {
|
|
|
|
|
DataTable.default_avatar <- [];
|
|
|
|
|
while (true) {
|
|
|
|
|
local Ret = Data.Get();
|
|
|
|
|
if (Ret == "[/default avatar]") break;
|
|
|
|
|
DataTable.default_avatar.append(Ret);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-11 15:08:57 +08:00
|
|
|
//基础属性
|
|
|
|
|
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);
|
|
|
|
|
}
|
2024-12-12 14:51:27 +08:00
|
|
|
}
|
2024-12-11 15:08:57 +08:00
|
|
|
|
2024-12-12 14:51:27 +08:00
|
|
|
function InitEquipmentList() {
|
|
|
|
|
EquipmentList = ScriptData.GetFileData("equipment/equipment.lst", function(DataTable, Data) {
|
|
|
|
|
while (!Data.Eof()) {
|
|
|
|
|
local Key = Data.Get();
|
2024-12-15 20:23:11 +08:00
|
|
|
//注册装备列表 路径写入 数据未读取
|
|
|
|
|
DataTable.rawset(Key, {
|
|
|
|
|
Path = Data.Get(),
|
|
|
|
|
Data = null
|
|
|
|
|
});
|
2024-12-12 14:51:27 +08:00
|
|
|
}
|
|
|
|
|
if (_DEBUG_) print("加载装备List完成, 共" + DataTable.len() + "个");
|
|
|
|
|
});
|
2024-12-11 15:08:57 +08:00
|
|
|
}
|
|
|
|
|
|
2024-12-25 11:32:34 +08:00
|
|
|
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() + "个");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 15:08:57 +08:00
|
|
|
constructor() {
|
2024-12-25 11:32:34 +08:00
|
|
|
//初始化城镇列表
|
|
|
|
|
InitTownList();
|
2024-12-11 15:08:57 +08:00
|
|
|
//初始化地图列表
|
|
|
|
|
InitMapList();
|
|
|
|
|
//初始化角色
|
|
|
|
|
InitCharacter();
|
2024-12-12 14:51:27 +08:00
|
|
|
//初始化装备列表
|
|
|
|
|
InitEquipmentList();
|
2024-12-11 15:08:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
getroottable().AssetManager <- this;
|
|
|
|
|
}
|
2024-12-12 14:51:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
//Public::
|
|
|
|
|
|
|
|
|
|
//获取装备信息
|
|
|
|
|
function GetEquipment(Idx) {
|
|
|
|
|
//如果没有这件装备则返回
|
|
|
|
|
if (!(EquipmentList.rawin(Idx))) return;
|
2024-12-15 20:23:11 +08:00
|
|
|
//如果装备数据已经读取过存在了则直接返回
|
|
|
|
|
if (EquipmentList[Idx].Data) return EquipmentList[Idx].Data;
|
|
|
|
|
local Path = EquipmentList[Idx].Path;
|
2024-12-12 14:51:27 +08:00
|
|
|
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
|
2024-12-13 20:52:58 +08:00
|
|
|
if (Pack == "[name]" || Pack == "[part set index]" || Pack == "[grade]" || Pack == "[minimum level]") {
|
2024-12-12 14:51:27 +08:00
|
|
|
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 <- 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();
|
|
|
|
|
}
|
2024-12-17 09:41:42 +08:00
|
|
|
//光环效果
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-12 14:51:27 +08:00
|
|
|
//Ani
|
|
|
|
|
else if (Pack == "[animation job]") {
|
|
|
|
|
local Job = Data.Get().slice(1, -1);
|
2024-12-13 20:52:58 +08:00
|
|
|
if (!(DataTable.rawin("Ani"))) DataTable["Ani"] <- {};
|
|
|
|
|
DataTable["Ani"]["Ani_" + Job] <- {};
|
2024-12-12 14:51:27 +08:00
|
|
|
Data.Get();
|
|
|
|
|
|
|
|
|
|
local Index1 = Data.Get();
|
|
|
|
|
local Index2 = Data.Get();
|
2024-12-13 20:52:58 +08:00
|
|
|
DataTable["Ani"]["Ani_" + Job].variation <- [Index1, Index2];
|
|
|
|
|
DataTable["Ani"]["Ani_" + Job].layer_variation <- [];
|
2024-12-12 14:51:27 +08:00
|
|
|
|
|
|
|
|
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();
|
2024-12-13 20:52:58 +08:00
|
|
|
DataTable["Ani"]["Ani_" + Job].layer_variation.append(InfoBuf);
|
2024-12-12 14:51:27 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-12-15 20:23:11 +08:00
|
|
|
EquipmentList[Idx].Data = m_data;
|
2024-12-12 14:51:27 +08:00
|
|
|
return m_data;
|
|
|
|
|
}
|
2024-12-11 15:08:57 +08:00
|
|
|
}
|