新增 命名空间 GameObject 新增 CharacterObject 更换时装逻辑
This commit is contained in:
parent
c40f1483a3
commit
01ae0de6f3
|
|
@ -4,7 +4,8 @@
|
||||||
创建日期:2024-11-29 23:05
|
创建日期:2024-11-29 23:05
|
||||||
文件用途:动态Obj对象
|
文件用途:动态Obj对象
|
||||||
*/
|
*/
|
||||||
class ActiveObject extends BaseObject {
|
|
||||||
|
class GameObject.ActiveObject extends GameObject.BaseClass {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,60 +4,21 @@
|
||||||
创建日期:2024-05-11 21:03
|
创建日期:2024-05-11 21:03
|
||||||
文件用途:角色类
|
文件用途:角色类
|
||||||
*/
|
*/
|
||||||
class Character extends ActiveObject {
|
class GameObject.Character extends GameObject.ActiveObject {
|
||||||
|
|
||||||
hair = null; //头部
|
hair = null; //头部
|
||||||
cap = null; //帽子
|
hat = null; //帽子
|
||||||
face = null; //脸部
|
face = null; //脸部
|
||||||
neck = null; //胸部
|
breast = null; //胸部
|
||||||
coat = null; //上衣
|
coat = null; //上衣
|
||||||
skin = null; //皮肤
|
skin = null; //皮肤
|
||||||
belt = null; //腰部
|
waist = null; //腰部
|
||||||
pants = null; //下装
|
pants = null; //下装
|
||||||
shoes = null; //鞋子
|
shoes = null; //鞋子
|
||||||
weapon = null; //武器
|
weapon = null; //武器
|
||||||
|
|
||||||
//当前动画组
|
//动画对象管理器
|
||||||
CurrentAni = null;
|
AnimationManager = 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;
|
|
||||||
|
|
||||||
//属性对象
|
//属性对象
|
||||||
Attribute = null;
|
Attribute = null;
|
||||||
|
|
@ -70,9 +31,10 @@ class Character extends ActiveObject {
|
||||||
Info = sq_DeepCopy(AssetManager.CharacterInfoList[Idx]);
|
Info = sq_DeepCopy(AssetManager.CharacterInfoList[Idx]);
|
||||||
base.Init(Info);
|
base.Init(Info);
|
||||||
|
|
||||||
|
//构造角色动画对象
|
||||||
//初始化基础Ani
|
AnimationManager = Character_Animation();
|
||||||
InitBaseAni();
|
Addchild(AnimationManager);
|
||||||
|
AnimationManager.Init();
|
||||||
|
|
||||||
//构造属性对象
|
//构造属性对象
|
||||||
// Attribute = AttributeClass();
|
// Attribute = AttributeClass();
|
||||||
|
|
@ -115,221 +77,43 @@ class Character extends ActiveObject {
|
||||||
|
|
||||||
//设置Ani
|
//设置Ani
|
||||||
function SetAnimation(Ani) {
|
function SetAnimation(Ani) {
|
||||||
//因为是Ani组所以要foreach调用
|
//如果存在动画管理器则设置
|
||||||
//如果已经有Ani了
|
if (AnimationManager) AnimationManager.SetAnimation(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function FormatAvatarAniImgPath(AniInfo, FormatValue1, FormatValue2) {
|
//切换装备
|
||||||
for (local i = 0; i< AniInfo.Frame.len(); i++) {
|
function ChangeEquipment(Equ) {
|
||||||
AniInfo.Frame[i].Img_Path = format(AniInfo.Frame[i].Img_Path, FormatValue1, FormatValue2);
|
//如果当前装备槽已经有装备则移除
|
||||||
|
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 (Equ.SlotType == "weapon" || Equ.Type == "avatar") {
|
||||||
if (Info.rawin(Src)) Src = Info[Src];
|
AnimationManager.Init(Equ.SlotType);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//切换装备列表
|
||||||
function ReadAndSetAttackAni() {
|
function ChangeEquipmentList(EquList) {
|
||||||
local AttackAniArrSrc = Info["attack_motion"];
|
foreach(Equ in EquList) {
|
||||||
AttackAni = array(AttackAniArrSrc.len());
|
ChangeEquipment(Equ);
|
||||||
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 InitBaseAni() {
|
//通过职业和装备列表来构造一个角色
|
||||||
//读取并设置 等待Ani
|
GameObject.CreateCharacter <- function(Job = 0, EquIdList = []) {
|
||||||
ReadAndSetAni("WaitingAni", "waiting motion");
|
//构造角色
|
||||||
//读取并设置 移动Ani
|
local Character = GameObject.Character();
|
||||||
ReadAndSetAni("MoveAni", "move motion");
|
Character.Init(Job);
|
||||||
//读取并设置 蹲下Ani
|
foreach(EquId in EquIdList) {
|
||||||
ReadAndSetAni("SitAni", "sit motion");
|
local EquObj = GameItem.Equipment(EquId);
|
||||||
//读取并设置 受伤Ani
|
Character.ChangeEquipment(EquObj);
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return Character;
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
创建日期:2024-05-14 10:05
|
创建日期:2024-05-14 10:05
|
||||||
文件用途:APC
|
文件用途:APC
|
||||||
*/
|
*/
|
||||||
class AICharacter extends Character {
|
class GameObject.AICharacter extends GameObject.Character {
|
||||||
|
|
||||||
//职业
|
//职业
|
||||||
Job = null;
|
Job = null;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
创建日期:2024-05-10 19:40
|
创建日期:2024-05-10 19:40
|
||||||
文件用途:怪物对象类
|
文件用途:怪物对象类
|
||||||
*/
|
*/
|
||||||
class Monster extends ActiveObject {
|
class GameObject.Monster extends GameObject.ActiveObject {
|
||||||
|
|
||||||
Attackinfo = null;
|
Attackinfo = null;
|
||||||
//怪物Id
|
//怪物Id
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
创建日期:2024-05-11 09:14
|
创建日期:2024-05-11 09:14
|
||||||
文件用途:被动对象
|
文件用途:被动对象
|
||||||
*/
|
*/
|
||||||
class PassiveObject extends ActiveObject {
|
class GameObject.PassiveObject extends GameObject.ActiveObject {
|
||||||
|
|
||||||
OnCreateFunction = null;
|
OnCreateFunction = null;
|
||||||
OnProcFunction = null;
|
OnProcFunction = null;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
创建日期:2024-05-09 22:28
|
创建日期:2024-05-09 22:28
|
||||||
文件用途:静态Obj对象
|
文件用途:静态Obj对象
|
||||||
*/
|
*/
|
||||||
class StaticObject extends BaseObject {
|
class GameObject.StaticObject extends GameObject.BaseClass {
|
||||||
|
|
||||||
AniObject = null;
|
AniObject = null;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue