mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
76 lines
1.8 KiB
TypeScript
76 lines
1.8 KiB
TypeScript
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;
|
|
|
|
//角色基类
|
|
export default abstract class GRoleBase<T> extends GObject<T>{
|
|
|
|
@property(sp.Skeleton)
|
|
spine:sp.Skeleton;
|
|
|
|
//状态机
|
|
fsm:GFSMBattle;
|
|
|
|
//动画状态机
|
|
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) {
|
|
this.node.removeFromParent();
|
|
return;
|
|
}
|
|
|
|
//创建角色状态机
|
|
this.fsm = this.fsmCreate();
|
|
//创建角色动画状态机
|
|
this.fsmAnim = this.fsmAnimCreate();
|
|
|
|
}
|
|
|
|
//创建一个状态机
|
|
protected abstract fsmCreate():GFSMBattle;
|
|
//创建一个动画状态机
|
|
protected abstract fsmAnimCreate():GFSMBattleAmin;
|
|
|
|
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T){
|
|
//更新状态机
|
|
this.fsm && this.fsm.onUpdate(dt);
|
|
this.fsmAnim && this.fsmAnim.onUpdate(dt);
|
|
}
|
|
|
|
//普攻更新
|
|
onAttackUpdate(dt:number){
|
|
|
|
this.fsmAnim.isAttack = true;
|
|
}
|
|
|
|
}
|
|
|