73 lines
2.5 KiB
Plaintext
73 lines
2.5 KiB
Plaintext
/*
|
|
文件名:AiCharacterObjectClass.nut
|
|
路径:User/GameClass/ObjectClass/AiCharacterObjectClass.nut
|
|
创建日期:2024-05-14 10:05
|
|
文件用途:APC
|
|
*/
|
|
class AICharacter extends Character {
|
|
|
|
//职业
|
|
Job = null;
|
|
//APC编号
|
|
Id = null;
|
|
|
|
function Init(Idx) {
|
|
|
|
Id = Idx;
|
|
Info = sq_DeepCopy(ScriptData.GetAICharacter(Idx));
|
|
//因为Info会被重新赋值 这里copy一下 下面读取属性要用
|
|
local ScriptInfo = sq_DeepCopy(Info);
|
|
|
|
Job = ScriptInfo["minimum info"][1];
|
|
|
|
//根据脚本穿上装备
|
|
ReloadEquipment();
|
|
|
|
//根据职业构造基础角色 注意这一步会直接重新赋值Info
|
|
base.Init(Job);
|
|
|
|
//加载脚本属性
|
|
Attribute.Init(ScriptInfo.Attributes, this);
|
|
}
|
|
|
|
//重载装备
|
|
function ReloadEquipment() {
|
|
// Util.PrintTable(Info);
|
|
for (local i = 0; i< Info["equipment"].len(); i += 3) {
|
|
local EquiId = Info["equipment"][i];
|
|
local EquiInfo = ScriptData.GetEquipment(EquiId);
|
|
|
|
if (EquiInfo.type.path == "skin avatar") skin = Info["equipment"][i];
|
|
else if (EquiInfo.type.path == "weapon") weapon = Info["equipment"][i];
|
|
else if (EquiInfo.type.path == "cap avatar") cap = Info["equipment"][i];
|
|
else if (EquiInfo.type.path == "hair avatar") hair = Info["equipment"][i];
|
|
else if (EquiInfo.type.path == "coat avatar") coat = Info["equipment"][i];
|
|
else if (EquiInfo.type.path == "pants avatar") pants = Info["equipment"][i];
|
|
else if (EquiInfo.type.path == "shoes avatar") shoes = Info["equipment"][i];
|
|
}
|
|
}
|
|
|
|
|
|
function OnAddchild(Parent) {
|
|
if (getroottable().AiCharacterObjectFunction.rawin("AiCharacterObject_Create_" + Id))
|
|
getroottable().AiCharacterObjectFunction["AiCharacterObject_Create_" + Id](this, Parent);
|
|
base.OnAddchild(Parent);
|
|
}
|
|
|
|
function OnRemove(Parent) {
|
|
if (getroottable().AiCharacterObjectFunction.rawin("AiCharacterObject_Destroy_" + Id))
|
|
getroottable().AiCharacterObjectFunction["AiCharacterObject_Destroy_" + Id](this, Parent);
|
|
base.OnRemove(Parent);
|
|
}
|
|
|
|
//被调用
|
|
function OnUpdate(dt) {
|
|
//如果有APC的Proc脚本则调用
|
|
if (getroottable().AiCharacterObjectFunction.rawin("AiCharacterObject_Proc_" + Id))
|
|
getroottable().AiCharacterObjectFunction["AiCharacterObject_Proc_" + Id](this, dt);
|
|
//属性更新
|
|
if (Attribute) Attribute.Proc(this, dt);
|
|
|
|
base.OnUpdate(dt);
|
|
}
|
|
} |