This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-10-26 03:06:44 +08:00
parent cb70ba12c7
commit 09225a33c7
158 changed files with 26537 additions and 639 deletions

View File

@@ -1,5 +1,5 @@
import { _decorator, sp } from "cc";
import GObject from "../GObject";
import GObject, { GTowards } from "../GObject";
import { JNFrameInfo } from "../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
import GFSMBattle from "../fsm/base/GFSMBattle/GFSMBattle";
import { GFSMBattleAmin, GFSMBattleAminEnum } from "../fsm/base/GFSMBattle/GFSMBattleAmin";
@@ -8,6 +8,8 @@ import { v3 } from "cc";
import { GTactical } from "../../entity/GTactical";
import { JEasing, JTween } from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/tween/JNFrameTween";
import { v2 } from "cc";
import GRole from "../../entity/GRole";
import { app } from "../../../App";
const { ccclass, property } = _decorator;
export enum GRoleAnimEvent{
@@ -20,6 +22,9 @@ export default abstract class GRoleBase<T> extends GObject<T>{
@property(sp.Skeleton)
spine:sp.Skeleton;
//角色
role:GRole
//状态机
fsm:GFSMBattle;
@@ -35,7 +40,12 @@ export default abstract class GRoleBase<T> extends GObject<T>{
//在阵容中的下标
tacticalIndex:number;
//阵容
tactical:GTactical;
_tactical:GTactical;
get tactical(){return this._tactical};
set tactical(value:GTactical){
this.setTowards(value.towards);
this._tactical = value;
}
//阵容位置
_tacticalPos:Vec2;
get tacticalPos(){ return this._tacticalPos}
@@ -67,6 +77,8 @@ export default abstract class GRoleBase<T> extends GObject<T>{
this.node.removeFromParent();
return;
}
this.bind(this.role);
//创建角色状态机
this.fsm = this.fsmCreate();
@@ -80,15 +92,24 @@ export default abstract class GRoleBase<T> extends GObject<T>{
}
//设置角色
bind(role:GRole){
if(this.spine)
this.spine.skeletonData = app.role.skData[role.id];
this.role = role;
}
//创建一个状态机
protected abstract fsmCreate():GFSMBattle;
//创建一个动画状态机
protected abstract fsmAnimCreate():GFSMBattleAmin;
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T){
//更新状态机
this.fsm && this.fsm.onUpdate(dt / 1000);
this.fsmAnim && this.fsmAnim.onUpdate(dt / 1000);
}
//向目标点移动
@@ -98,6 +119,16 @@ export default abstract class GRoleBase<T> extends GObject<T>{
let mins = this.v2World.subtract(target);
let normal = this.v2World.subtract(target).normalize();
//设置朝向
if(normal.x != 0){
if(normal.x < 0){
this.setTowards(GTowards.RIGHT)
}else{
this.setTowards(GTowards.LEFT)
}
}
if(Vec2.len(normal) >= Vec2.len(mins)){
this.node.setWorldPosition(Object.assign(v3(),target.clone()));
return true;
@@ -112,7 +143,7 @@ export default abstract class GRoleBase<T> extends GObject<T>{
//攻击
onAttack(){
//敌人扣血
this.fsm.enemy.onHit();
this.fsm.enemy?.onHit();
}
//受击
@@ -145,6 +176,11 @@ export default abstract class GRoleBase<T> extends GObject<T>{
}
//恢复阵容朝向
onRecoverTacticalTowards(){
this.setTowards(this.tactical.towards);
}
}

View File

@@ -2,13 +2,14 @@ import { _decorator } from "cc";
import GRoleBase from "../GRoleBase";
import GFSMBase from "../../fsm/GFSMBase";
import GFSMPVP from "../../fsm/PVP/GFSMPVP";
import GPVPMode, { GPVPModePlayerEnum } from "../../../PVP/GPVPMode";
import GPVPMode, { GPVPModePlayerEnum } from "../../../modes/GPVPMode";
import { GTactical } from "../../../entity/GTactical";
import { GFSMBattleAmin } from "../../fsm/base/GFSMBattle/GFSMBattleAmin";
import { JNFrameInfo } from "../../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
import { Vec2 } from "cc";
import { v2 } from "cc";
import { ProgressBar } from "cc";
import { GTowards } from "../../GObject";
const { ccclass, property } = _decorator;
export interface GDemoMessage{
@@ -26,12 +27,6 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
return this._ones;
}
set ones(value:GPVPModePlayerEnum){
//如果是敌方则设置镜像
if(value == GPVPModePlayerEnum.ENEMY){
this.isMirror = true;
}else{
this.isMirror = false;
}
this._ones = value;
}
@@ -66,6 +61,7 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
this._mode = value;
}
protected fsmCreate(): GFSMPVP {
return new GFSMPVP(this);
}