This commit is contained in:
PC-20230316NUNE\Administrator
2023-10-24 19:12:25 +08:00
parent 72f3d7e880
commit fb1696d079
24 changed files with 1478 additions and 91 deletions

View File

@@ -2,6 +2,10 @@ import { _decorator, sp } from "cc";
import GObject from "../GObject";
import { JNFrameInfo } from "../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
import GFSMBase from "../fsm/GFSMBase";
import GFSMBattle from "../fsm/base/GFSMBattle/GFSMBattle";
import { GFSMBattleAmin } from "../fsm/base/GFSMBattle/GFSMBattleAmin";
import { Vec2 } from "cc";
import { v2 } from "cc";
const { ccclass, property } = _decorator;
//角色基类
@@ -11,9 +15,31 @@ export default abstract class GRoleBase<T> extends GObject<T>{
spine:sp.Skeleton;
//状态机
fsm:GFSMBase;
fsm:GFSMBattle;
onLoad(){
//动画状态机
fsmAnim:GFSMBattleAmin;
//玩家是否镜像
_isMirror:boolean = false;
//玩家攻击范围
range:number = 10;
get isMirror(){
return this._isMirror;
}
set isMirror(value:boolean){
if(value){
GObject.SetMirror(this);
}else{
GObject.SetMirror(this,false);
}
this._isMirror = value;
}
onSyncLoad(){
if(!this.spine) this.spine = this.node.getComponent(sp.Skeleton);
//如果没有生成则直接销毁
if(!this.spine) {
@@ -23,15 +49,26 @@ export default abstract class GRoleBase<T> extends GObject<T>{
//创建角色状态机
this.fsm = this.fsmCreate();
//创建角色动画状态机
this.fsmAnim = this.fsmAnimCreate();
}
//创建一个状态机
protected abstract fsmCreate():GFSMBase;
protected abstract fsmCreate():GFSMBattle;
//创建一个动画状态机
protected abstract fsmAnimCreate():GFSMBattleAmin;
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T){
//更新状态机
this.fsm.onUpdate(dt);
this.fsm && this.fsm.onUpdate(dt);
this.fsmAnim && this.fsmAnim.onUpdate(dt);
}
//普攻更新
onAttackUpdate(dt:number){
this.fsmAnim.isAttack = true;
}
}

View File

@@ -4,18 +4,53 @@ import GFSMBase from "../../fsm/GFSMBase";
import GFSMPVP from "../../fsm/PVP/GFSMPVP";
import GPVPMode, { GPVPModePlayerEnum } from "../../../PVP/GPVPMode";
import { GTactical } from "../../../entity/GTactical";
import { GFSMBattleAmin } from "../../fsm/base/GFSMBattle/GFSMBattleAmin";
import { JNFrameInfo } from "../../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
const { ccclass, property } = _decorator;
export interface GDemoMessage{
isAttack?:boolean;
isRun?:boolean;
}
//PVP 角色
@ccclass('GRolePVPEntity')
export default class GRolePVPEntity extends GRoleBase<{}>{
export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
//所属阵容
ones:GPVPModePlayerEnum;
_ones:GPVPModePlayerEnum;
get ones():GPVPModePlayerEnum{
return this._ones;
}
set ones(value:GPVPModePlayerEnum){
//如果是敌方则设置镜像
if(value == GPVPModePlayerEnum.ENEMY){
this.isMirror = true;
}else{
this.isMirror = false;
}
this._ones = value;
}
//攻击距离
//在阵容中的下标
tacticalIndex:number;
tactical:GTactical;
getClassName():string{return "GDemoMessage"}
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: GDemoMessage) {
super.onSyncUpdate(dt,frame,input);
if(input){
if(Object.prototype.hasOwnProperty.call(input,"isAttack")){
this.fsmAnim.isAttack = input.isAttack;
}
if(Object.prototype.hasOwnProperty.call(input,"isRun")){
this.fsmAnim.isMove = input.isRun;
}
}
}
get mode():GPVPMode{
@@ -25,9 +60,13 @@ export default class GRolePVPEntity extends GRoleBase<{}>{
this._mode = value;
}
protected fsmCreate(): GFSMBase {
protected fsmCreate(): GFSMPVP {
return null;
return new GFSMPVP(this);
}
protected fsmAnimCreate(): GFSMBattleAmin {
return new GFSMBattleAmin(this.spine);
}
}