新增 命名空间 GameObject 新增 CharacterObject 更换时装逻辑
This commit is contained in:
parent
e4ceee9b73
commit
a0158020d4
|
|
@ -4,7 +4,8 @@
|
|||
创建日期:2024-11-29 23:05
|
||||
文件用途:动态Obj对象
|
||||
*/
|
||||
class ActiveObject extends BaseObject {
|
||||
|
||||
class GameObject.ActiveObject extends GameObject.BaseClass {
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,60 +4,21 @@
|
|||
创建日期:2024-05-11 21:03
|
||||
文件用途:角色类
|
||||
*/
|
||||
class Character extends ActiveObject {
|
||||
class GameObject.Character extends GameObject.ActiveObject {
|
||||
|
||||
hair = null; //头部
|
||||
cap = null; //帽子
|
||||
hat = null; //帽子
|
||||
face = null; //脸部
|
||||
neck = null; //胸部
|
||||
breast = null; //胸部
|
||||
coat = null; //上衣
|
||||
skin = null; //皮肤
|
||||
belt = null; //腰部
|
||||
waist = null; //腰部
|
||||
pants = null; //下装
|
||||
shoes = null; //鞋子
|
||||
weapon = null; //武器
|
||||
|
||||
//当前动画组
|
||||
CurrentAni = null;
|
||||
|
||||
//等待Ani
|
||||
WaitingAni = null;
|
||||
//移动Ani
|
||||
MoveAni = null;
|
||||
//蹲下Ani
|
||||
SitAni = null;
|
||||
//受伤Ani
|
||||
DamageAni1 = null;
|
||||
DamageAni2 = null;
|
||||
//倒地Ani
|
||||
DownAni = null;
|
||||
//被击后退Ani
|
||||
OverturnAni = null;
|
||||
//跳跃Ani
|
||||
JumoAni = null;
|
||||
//跳跃攻击Ani
|
||||
JumpAttackAni = null;
|
||||
//站立Ani
|
||||
RestAni = null;
|
||||
//引导Ani
|
||||
ThrowAni1_1 = null;
|
||||
ThrowAni1_2 = null;
|
||||
ThrowAni2_1 = null;
|
||||
ThrowAni2_2 = null;
|
||||
ThrowAni3_1 = null;
|
||||
ThrowAni3_2 = null;
|
||||
ThrowAni4_1 = null;
|
||||
ThrowAni4_2 = null;
|
||||
//奔跑Ani
|
||||
DashAni = null;
|
||||
//奔跑攻击Ani
|
||||
DashAttackAni = null;
|
||||
//拾取Ani
|
||||
GetItemAni = null;
|
||||
//释放BUFFAni
|
||||
BuffAni = null;
|
||||
//普通攻击Ani
|
||||
AttackAni = null;
|
||||
//动画对象管理器
|
||||
AnimationManager = null;
|
||||
|
||||
//属性对象
|
||||
Attribute = null;
|
||||
|
|
@ -70,9 +31,10 @@ class Character extends ActiveObject {
|
|||
Info = sq_DeepCopy(AssetManager.CharacterInfoList[Idx]);
|
||||
base.Init(Info);
|
||||
|
||||
|
||||
//初始化基础Ani
|
||||
InitBaseAni();
|
||||
//构造角色动画对象
|
||||
AnimationManager = Character_Animation();
|
||||
Addchild(AnimationManager);
|
||||
AnimationManager.Init();
|
||||
|
||||
//构造属性对象
|
||||
// Attribute = AttributeClass();
|
||||
|
|
@ -115,221 +77,43 @@ class Character extends ActiveObject {
|
|||
|
||||
//设置Ani
|
||||
function SetAnimation(Ani) {
|
||||
//因为是Ani组所以要foreach调用
|
||||
//如果已经有Ani了
|
||||
if (CurrentAni) {
|
||||
foreach(AniObj in CurrentAni) {
|
||||
Removechild(AniObj);
|
||||
}
|
||||
}
|
||||
if (type(Ani) == "integer") {
|
||||
//TODO 进阶ANI
|
||||
} else {
|
||||
CurrentAni = Ani;
|
||||
}
|
||||
//重置Ani 并添加子对象
|
||||
foreach(AniObj in CurrentAni) {
|
||||
AniObj.Reset();
|
||||
Addchild(AniObj);
|
||||
}
|
||||
//如果存在动画管理器则设置
|
||||
if (AnimationManager) AnimationManager.SetAnimation(Ani);
|
||||
}
|
||||
|
||||
|
||||
function FormatAvatarAniImgPath(AniInfo, FormatValue1, FormatValue2) {
|
||||
for (local i = 0; i< AniInfo.Frame.len(); i++) {
|
||||
AniInfo.Frame[i].Img_Path = format(AniInfo.Frame[i].Img_Path, FormatValue1, FormatValue2);
|
||||
//切换装备
|
||||
function ChangeEquipment(Equ) {
|
||||
//如果当前装备槽已经有装备则移除
|
||||
if (this[Equ.SlotType]) {
|
||||
this[Equ.SlotType].OnWearEnd();
|
||||
this[Equ.SlotType] = null;
|
||||
}
|
||||
return AniInfo;
|
||||
}
|
||||
//将装备对象赋值给对应装备槽
|
||||
this[Equ.SlotType] = Equ;
|
||||
this[Equ.SlotType].OnWearStart();
|
||||
|
||||
function ReadAndSetAni(AniObj, Src) {
|
||||
//如果有这个标签Ani则初始化
|
||||
if (Info.rawin(Src)) Src = Info[Src];
|
||||
else return;
|
||||
|
||||
//如果Ani组不存在就初始化数组
|
||||
if (this[AniObj] == null) this[AniObj] = [];
|
||||
|
||||
|
||||
foreach(Type in getconsttable().AvatarType) {
|
||||
//如果有时装就初始化Ani
|
||||
//除了皮肤 在没有的情况下初始化0
|
||||
if (Type == "skin") {
|
||||
local SkinAni;
|
||||
if (this[Type] == null) {
|
||||
local BufInfo = sq_DeepCopy(ScriptData.GetAni(Src));
|
||||
local Ao = {
|
||||
ImgVariation = [0, 0],
|
||||
ImgFormat = function(ImgPath) {
|
||||
if (ImgVariation[0] > 0) {
|
||||
local Pos = ImgPath.find("%04d");
|
||||
ImgPath = ImgPath.slice(0, Pos) + "%02d%02d" + ImgPath.slice(Pos + 4);
|
||||
return format(ImgPath, ImgVariation[0], ImgVariation[1]);
|
||||
} else {
|
||||
return format(ImgPath, ImgVariation[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
SkinAni = Animation(BufInfo, Ao);
|
||||
} else {
|
||||
local AvaInfo = AssetManager.GetEquipment(this[Type]);
|
||||
local JobInfo = AvaInfo["Ani_" + Info["job"]];
|
||||
local BufInfo = sq_DeepCopy(ScriptData.GetAni(Src));
|
||||
local Ao = {
|
||||
ImgVariation = JobInfo["variation"],
|
||||
ImgFormat = function(ImgPath) {
|
||||
if (ImgVariation[0] > 0) {
|
||||
local Pos = ImgPath.find("%04d");
|
||||
ImgPath = ImgPath.slice(0, Pos) + "%02d%02d" + ImgPath.slice(Pos + 4);
|
||||
return format(ImgPath, ImgVariation[0], ImgVariation[1]);
|
||||
} else {
|
||||
return format(ImgPath, ImgVariation[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
SkinAni = Animation(BufInfo, Ao);
|
||||
}
|
||||
//如果是皮肤Ani 绑定状态机 确保唯一性
|
||||
SkinAni.BindenvStateMachine(StateMachine);
|
||||
//将Ani类型设置为皮肤
|
||||
SkinAni.Type = "skin";
|
||||
//加入组
|
||||
this[AniObj].append(SkinAni);
|
||||
} else {
|
||||
//先判断类型
|
||||
if (this[Type] != null) {
|
||||
local AvaInfo = AssetManager.GetEquipment(this[Type]);
|
||||
if (AvaInfo) {
|
||||
local JobInfo = AvaInfo["Ani_" + Info["job"]];
|
||||
foreach(_index, value in JobInfo["layer_variation"]) {
|
||||
local BufInfo = sq_DeepCopy(ScriptData.GetAni(AvaInfo["DirPath"] + value["Path"] + Src.slice(Src.lastfind("/"))));
|
||||
local Ao = {
|
||||
ImgVariation = JobInfo["variation"],
|
||||
ImgFormat = function(ImgPath) {
|
||||
return format(ImgPath, ImgVariation[0], ImgVariation[1]);
|
||||
}
|
||||
}
|
||||
local AniBuf = Animation(BufInfo, Ao);
|
||||
//设置Ani类型
|
||||
AniBuf.Type = Type;
|
||||
AniBuf.SetZOrder(value["Zorder"]);
|
||||
this[AniObj].append(AniBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//如果是武器或者时装则同步动画
|
||||
if (Equ.SlotType == "weapon" || Equ.Type == "avatar") {
|
||||
AnimationManager.Init(Equ.SlotType);
|
||||
}
|
||||
}
|
||||
|
||||
function ReadAndSetAttackAni() {
|
||||
local AttackAniArrSrc = Info["attack_motion"];
|
||||
AttackAni = array(AttackAniArrSrc.len());
|
||||
foreach(_Index, Path in AttackAniArrSrc) {
|
||||
local Src = Path;
|
||||
AttackAni[_Index] = [];
|
||||
foreach(Type in getconsttable().AvatarType) {
|
||||
//如果有时装就初始化Ani
|
||||
//除了皮肤 在没有的情况下初始化0
|
||||
if (Type == "skin") {
|
||||
local SkinAni;
|
||||
if (this[Type] == null) {
|
||||
local BufInfo = sq_DeepCopy(ScriptData.GetAni(Src));
|
||||
local Ao = {
|
||||
ImgVariation = [0, 0],
|
||||
ImgFormat = function(ImgPath) {
|
||||
if (ImgVariation[0] > 0) {
|
||||
local Pos = ImgPath.find("%04d");
|
||||
ImgPath = ImgPath.slice(0, Pos) + "%02d%02d" + ImgPath.slice(Pos + 4);
|
||||
return format(ImgPath, ImgVariation[0], ImgVariation[1]);
|
||||
} else {
|
||||
return format(ImgPath, ImgVariation[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
SkinAni = Animation(BufInfo, Ao);
|
||||
} else {
|
||||
local AvaInfo = AssetManager.GetEquipment(this[Type]);
|
||||
local JobInfo = AvaInfo["Ani_" + Info["job"]];
|
||||
local BufInfo = sq_DeepCopy(ScriptData.GetAni(Src));
|
||||
local Ao = {
|
||||
ImgVariation = JobInfo["variation"],
|
||||
ImgFormat = function(ImgPath) {
|
||||
return format(ImgPath, ImgVariation[0], ImgVariation[1]);
|
||||
}
|
||||
}
|
||||
SkinAni = Animation(BufInfo, Ao);
|
||||
}
|
||||
//如果是皮肤Ani 绑定状态机 确保唯一性
|
||||
SkinAni.BindenvStateMachine(StateMachine);
|
||||
//将Ani类型设置为皮肤
|
||||
SkinAni.Type = "skin";
|
||||
//加入组
|
||||
AttackAni[_Index].append(SkinAni);
|
||||
} else {
|
||||
if (this[Type] != null) {
|
||||
|
||||
local AvaInfo = AssetManager.GetEquipment(this[Type]);
|
||||
local JobInfo = AvaInfo["Ani_" + Info["job"]];
|
||||
foreach(_index, value in JobInfo["layer_variation"]) {
|
||||
local BufInfo = sq_DeepCopy(ScriptData.GetAni(AvaInfo["DirPath"] + value["Path"] + Src.slice(Src.lastfind("/"))));
|
||||
local Ao = {
|
||||
ImgVariation = JobInfo["variation"],
|
||||
ImgFormat = function(ImgPath) {
|
||||
return format(ImgPath, ImgVariation[0], ImgVariation[1]);
|
||||
}
|
||||
}
|
||||
local AniBuf = Animation(BufInfo, Ao);
|
||||
//设置Ani类型
|
||||
AniBuf.Type = Type;
|
||||
AniBuf.SetZOrder(value["Zorder"]);
|
||||
AttackAni[_Index].append(AniBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//切换装备列表
|
||||
function ChangeEquipmentList(EquList) {
|
||||
foreach(Equ in EquList) {
|
||||
ChangeEquipment(Equ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InitBaseAni() {
|
||||
//读取并设置 等待Ani
|
||||
ReadAndSetAni("WaitingAni", "waiting motion");
|
||||
//读取并设置 移动Ani
|
||||
ReadAndSetAni("MoveAni", "move motion");
|
||||
//读取并设置 蹲下Ani
|
||||
ReadAndSetAni("SitAni", "sit motion");
|
||||
//读取并设置 受伤Ani
|
||||
ReadAndSetAni("DamageAni1", "damage motion 1");
|
||||
//读取并设置 受伤Ani
|
||||
ReadAndSetAni("DamageAni2", "damage motion 2");
|
||||
//读取并设置 倒地Ani
|
||||
ReadAndSetAni("DownAni", "down motion");
|
||||
//读取并设置 被击后退Ani
|
||||
ReadAndSetAni("OverturnAni", "overturn motion");
|
||||
//读取并设置 跳跃Ani
|
||||
ReadAndSetAni("JumoAni", "jump motion");
|
||||
//读取并设置 跳跃攻击Ani
|
||||
ReadAndSetAni("JumpAttackAni", "jumpattack motion");
|
||||
//读取并设置 站立Ani
|
||||
ReadAndSetAni("RestAni", "rest motion");
|
||||
//读取并设置 引导Ani
|
||||
ReadAndSetAni("ThrowAni1_1", "throw motion 1-1");
|
||||
ReadAndSetAni("ThrowAni1_2", "throw motion 1-2");
|
||||
ReadAndSetAni("ThrowAni2_1", "throw motion 2-1");
|
||||
ReadAndSetAni("ThrowAni2_2", "throw motion 2-2");
|
||||
ReadAndSetAni("ThrowAni3_1", "throw motion 3-1");
|
||||
ReadAndSetAni("ThrowAni3_2", "throw motion 3-2");
|
||||
ReadAndSetAni("ThrowAni4_1", "throw motion 4-1");
|
||||
ReadAndSetAni("ThrowAni4_2", "throw motion 4-2");
|
||||
//读取并设置 奔跑Ani
|
||||
ReadAndSetAni("DashAni", "dash motion");
|
||||
//读取并设置 奔跑攻击Ani
|
||||
ReadAndSetAni("DashAttackAni", "dashattack motion");
|
||||
//读取并设置 拾取Ani
|
||||
ReadAndSetAni("GetItemAni", "getitem motion");
|
||||
//读取并设置 释放BUFFAni
|
||||
ReadAndSetAni("BuffAni", "buff motion");
|
||||
//读取并设置 AttackAni
|
||||
ReadAndSetAttackAni();
|
||||
|
||||
//通过职业和装备列表来构造一个角色
|
||||
GameObject.CreateCharacter <- function(Job = 0, EquIdList = []) {
|
||||
//构造角色
|
||||
local Character = GameObject.Character();
|
||||
Character.Init(Job);
|
||||
foreach(EquId in EquIdList) {
|
||||
local EquObj = GameItem.Equipment(EquId);
|
||||
Character.ChangeEquipment(EquObj);
|
||||
}
|
||||
return Character;
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
创建日期:2024-05-14 10:05
|
||||
文件用途:APC
|
||||
*/
|
||||
class AICharacter extends Character {
|
||||
class GameObject.AICharacter extends GameObject.Character {
|
||||
|
||||
//职业
|
||||
Job = null;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
创建日期:2024-05-10 19:40
|
||||
文件用途:怪物对象类
|
||||
*/
|
||||
class Monster extends ActiveObject {
|
||||
class GameObject.Monster extends GameObject.ActiveObject {
|
||||
|
||||
Attackinfo = null;
|
||||
//怪物Id
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
创建日期:2024-05-11 09:14
|
||||
文件用途:被动对象
|
||||
*/
|
||||
class PassiveObject extends ActiveObject {
|
||||
class GameObject.PassiveObject extends GameObject.ActiveObject {
|
||||
|
||||
OnCreateFunction = null;
|
||||
OnProcFunction = null;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
创建日期:2024-05-09 22:28
|
||||
文件用途:静态Obj对象
|
||||
*/
|
||||
class StaticObject extends BaseObject {
|
||||
class GameObject.StaticObject extends GameObject.BaseClass {
|
||||
|
||||
AniObject = null;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue