123 lines
5.9 KiB
Plaintext
123 lines
5.9 KiB
Plaintext
/*
|
|
文件名:AssetManager.nut
|
|
路径:User/Asset/AssetManager.nut
|
|
创建日期:2024-11-24 08:44
|
|
文件用途: 资源管理器
|
|
*/
|
|
class _AssetManager_ {
|
|
|
|
//角色列表
|
|
CharacterList = null;
|
|
//角色信息表
|
|
CharacterInfoList = null;
|
|
//地图列表
|
|
MapList = 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 == "[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);
|
|
}
|
|
|
|
}
|
|
|
|
constructor() {
|
|
//初始化地图列表
|
|
InitMapList();
|
|
//初始化角色
|
|
InitCharacter();
|
|
|
|
|
|
|
|
getroottable().AssetManager <- this;
|
|
}
|
|
} |