mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
重构继承关系
This commit is contained in:
@@ -5,6 +5,9 @@ import GAttackNormal from "./GAttackNormal";
|
||||
import GAttackParabolicBangRemote from "./GAttackParabolicBangRemote";
|
||||
import { UITransform } from "cc";
|
||||
import GButtleBase from "../bullet/GButtleBase";
|
||||
import { GFSMAnimBase } from "../fsm/GFSMAnimBase";
|
||||
import GFSMBase from "../fsm/GFSMBase";
|
||||
import GRoleDefault from "../role/GRoleDefault";
|
||||
|
||||
//攻击子弹类
|
||||
export class GAttackBullet{
|
||||
@@ -22,7 +25,7 @@ export class GAttackBullet{
|
||||
|
||||
//攻击方式基类
|
||||
export interface GAttackBase{
|
||||
attack(role:GRoleBase<{}>,info:TableGRoleAttack);
|
||||
attack(role:GRoleDefault,info:TableGRoleAttack);
|
||||
}
|
||||
|
||||
//攻击方式
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
|
||||
import GRoleBase from "../role/GRoleBase";
|
||||
import GRoleDefault from "../role/GRoleDefault";
|
||||
import { GAttackBase } from "./GAttack";
|
||||
|
||||
|
||||
//普通攻击
|
||||
export default class GAttackNormal implements GAttackBase{
|
||||
|
||||
attack(role: GRoleBase<{}>, info: TableGRoleAttack) {
|
||||
attack(role: GRoleDefault, info: TableGRoleAttack) {
|
||||
role.fsm.enemy.onHit();
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@ import GEffectUtil from "../../effect/GEffectUtil";
|
||||
import { TableGRoleAttackEffect } from "../../../../resources/config/ts/TableGRoleAttackEffect";
|
||||
import GDetection from "../common/GDetection";
|
||||
import { rect } from "cc";
|
||||
import GRoleDefault from "../role/GRoleDefault";
|
||||
|
||||
/**
|
||||
* 抛物线 爆炸普攻
|
||||
@@ -19,7 +20,7 @@ import { rect } from "cc";
|
||||
*/
|
||||
export default class GAttackParabolicRemote implements GAttackBase{
|
||||
|
||||
attack(role: GRoleBase<{}>, info: TableGRoleAttack): void {
|
||||
attack(role: GRoleDefault, info: TableGRoleAttack): void {
|
||||
|
||||
let enemy = role.fsm.enemy;
|
||||
if(!enemy) return;
|
||||
|
@@ -55,7 +55,7 @@ export default class GSpine{
|
||||
//销毁
|
||||
create.node.destroy();
|
||||
});
|
||||
create.setAnimation(0,play);
|
||||
create.setAnimation(0,play,false);
|
||||
return create;
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "fe4e5e9b-d1dc-4aaf-9fa8-d089fd6ca00a",
|
||||
"uuid": "e6c9fc58-9fb5-4ae1-96b7-a857014d64c3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
@@ -1,7 +1,8 @@
|
||||
import { Vec2 } from "cc";
|
||||
import GRoleBase from "../../../role/GRoleBase";
|
||||
import GFSMBase, { GFSMProcessEnum, GFSMProcessInfo, GFSMProcessMode } from "../../GFSMBase";
|
||||
import { GRoleUtil } from "../../../../entity/GRole";
|
||||
import GRoleBase from "../../role/GRoleBase";
|
||||
import GFSMBase, { GFSMProcessEnum, GFSMProcessInfo, GFSMProcessMode } from "../GFSMBase";
|
||||
import { GRoleUtil } from "../../../entity/GRole";
|
||||
import GRoleDefault from "../../role/GRoleDefault";
|
||||
|
||||
|
||||
//流程枚举
|
||||
@@ -18,18 +19,17 @@ enum ProcessEnum {
|
||||
ReleaseSkills = 4,
|
||||
}
|
||||
|
||||
export default abstract class GFSMBattle extends GFSMBase{
|
||||
export default class GFSMDefault extends GFSMBase{
|
||||
|
||||
protected _player:() => GRoleBase<{}>;
|
||||
get player():GRoleBase<{}>{
|
||||
if(this._player)
|
||||
return this._player();
|
||||
return null;
|
||||
_player:() => GRoleDefault;
|
||||
|
||||
get player(): GRoleDefault {
|
||||
return this._player();
|
||||
}
|
||||
|
||||
//锁定的敌人
|
||||
_enemy:() => GRoleBase<any>;
|
||||
get enemy():GRoleBase<{}>{
|
||||
_enemy:() => GRoleDefault;
|
||||
get enemy():GRoleDefault{
|
||||
if(this._enemy)
|
||||
return this._enemy();
|
||||
return null;
|
||||
@@ -56,9 +56,9 @@ export default abstract class GFSMBattle extends GFSMBase{
|
||||
to:[ProcessEnum.SeekEnemy,ProcessEnum.ReleaseSkills],//移动回阵型 释放技能
|
||||
},
|
||||
[ProcessEnum.MoveToTactical]:{
|
||||
title:"移动回阵型",
|
||||
title:"获取初始点",
|
||||
mode:GFSMProcessMode.WaitExecute,
|
||||
execute: this.onMoveToTacticalProcess.bind(this),
|
||||
execute: this.onMoveToInitPosProcess.bind(this),
|
||||
to:[ProcessEnum.SeekEnemy],//移动回阵型
|
||||
},
|
||||
[ProcessEnum.ReleaseSkills]:{
|
||||
@@ -69,12 +69,16 @@ export default abstract class GFSMBattle extends GFSMBase{
|
||||
}
|
||||
}
|
||||
|
||||
constructor(player:GRoleBase<{}>){
|
||||
constructor(player:GRoleDefault){
|
||||
super();
|
||||
this._player = GRoleUtil.get(player);
|
||||
}
|
||||
|
||||
abstract onSeekEnemy():GRoleBase<any>;
|
||||
|
||||
//寻敌
|
||||
onSeekEnemy(): GRoleDefault {
|
||||
return this.player.onQueryEunmy();
|
||||
}
|
||||
|
||||
//寻敌流程
|
||||
onSeekEnemyProcess(dt:number):number{
|
||||
@@ -126,7 +130,7 @@ export default abstract class GFSMBattle extends GFSMBase{
|
||||
}
|
||||
|
||||
//移动回阵型
|
||||
onMoveToTacticalProcess(dt:number){
|
||||
onMoveToInitPosProcess(dt:number){
|
||||
|
||||
//播放移动
|
||||
this.player.fsmAnim.isMove = true;
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "559e87e4-5a3f-4cc2-873d-e0fb5b61375b",
|
||||
"uuid": "37959c38-50cc-430a-b892-ef0e6df3f15d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@@ -0,0 +1,82 @@
|
||||
import { GFSMAnimBase, GFSMProcessAnimInfo } from "../GFSMAnimBase";
|
||||
|
||||
//角色动画名称枚举
|
||||
export enum GFSMBattleAminEnum {
|
||||
Wait = "std", //等待
|
||||
Walk = "walk", //移动
|
||||
Attack = "atk", //攻击
|
||||
Fly = "jifei", //击飞
|
||||
}
|
||||
|
||||
//流程枚举
|
||||
enum ProcessEnum {
|
||||
//等待
|
||||
Wait = 0,
|
||||
//移动
|
||||
Move = 1,
|
||||
//攻击
|
||||
Attack = 2,
|
||||
//死亡
|
||||
Die = 3,
|
||||
}
|
||||
|
||||
//动画状态机基类
|
||||
export class GFSMDefaultAnim extends GFSMAnimBase{
|
||||
|
||||
//是否攻击
|
||||
isAttack:boolean = false;
|
||||
|
||||
//是否移动
|
||||
isMove:boolean = false;
|
||||
|
||||
//是否死亡
|
||||
isDie:boolean = false;
|
||||
|
||||
// 流程图
|
||||
process: { [key: number]: GFSMProcessAnimInfo; } = {
|
||||
[ProcessEnum.Wait]:{
|
||||
title:"等待",
|
||||
isLoop:true,
|
||||
animName:GFSMBattleAminEnum.Wait,
|
||||
mixs:[0.1,0.1],
|
||||
to:[ProcessEnum.Move,ProcessEnum.Attack,ProcessEnum.Die],
|
||||
ifTo:[
|
||||
() => this.isMove, //前往移动
|
||||
() => this.isAttack, //前往攻击
|
||||
() => this.isDie,
|
||||
],
|
||||
},
|
||||
[ProcessEnum.Move]:{
|
||||
title:"移动",
|
||||
animName:GFSMBattleAminEnum.Walk,
|
||||
isLoop:true,
|
||||
mixs:[0.1,0.1],
|
||||
to:[ProcessEnum.Wait,ProcessEnum.Attack,ProcessEnum.Die],
|
||||
ifTo:[
|
||||
() => !this.isMove, //前往等待
|
||||
() => this.isAttack, //前往攻击
|
||||
() => this.isDie,
|
||||
],
|
||||
},
|
||||
[ProcessEnum.Attack]:{
|
||||
title:"攻击",
|
||||
animName:GFSMBattleAminEnum.Attack,
|
||||
isLoop:true,
|
||||
mixs:[0.1,0.1],
|
||||
to:[ProcessEnum.Wait,ProcessEnum.Move,ProcessEnum.Die],
|
||||
ifTo:[
|
||||
() => !this.isAttack, //前往等待
|
||||
() => !this.isAttack && this.isMove, //前往移动
|
||||
() => this.isDie,
|
||||
],
|
||||
},
|
||||
[ProcessEnum.Die]:{
|
||||
title:"死亡",
|
||||
animName:GFSMBattleAminEnum.Fly,
|
||||
isLoop:true,
|
||||
mixs:[0.1,0.1],
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "9fc034a7-5c68-4f22-9065-447435329c8a",
|
||||
"uuid": "1016ec33-b6d2-453d-9ee2-6ab7ba5bfb7a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "8c02bc4d-30d6-47fe-82ff-e5496d4dca8f",
|
||||
"uuid": "66a8eb65-27e3-4c94-b098-211d582aa677",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "bcd244d3-5392-4926-94f1-3cd24ea2d5c2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -1,8 +1,6 @@
|
||||
import { sp } from "cc";
|
||||
import GFSMBase, { GFSMProcessEnum, GFSMProcessInfo, GFSMProcessMode } from "../../GFSMBase";
|
||||
import GRoleBase from "../../../role/GRoleBase";
|
||||
import GRolePVPEntity from "../../../role/PVP/GRolePVPEntity";
|
||||
import GObject from "../../../GObject";
|
||||
import GFSMBase, { GFSMProcessEnum, GFSMProcessInfo, GFSMProcessMode } from "./GFSMBase";
|
||||
import GObject from "../GObject";
|
||||
|
||||
//角色动画名称枚举
|
||||
export enum GFSMBattleAminEnum {
|
||||
@@ -26,29 +24,8 @@ export interface GFSMProcessAnimInfo extends GFSMProcessInfo{
|
||||
ifTo?:(() => boolean)[];
|
||||
}
|
||||
|
||||
//流程枚举
|
||||
enum ProcessEnum {
|
||||
//等待
|
||||
Wait = 0,
|
||||
//移动
|
||||
Move = 1,
|
||||
//攻击
|
||||
Attack = 2,
|
||||
//死亡
|
||||
Die = 3,
|
||||
}
|
||||
|
||||
//动画状态机基类
|
||||
export class GFSMBattleAmin extends GFSMBase{
|
||||
|
||||
//是否攻击
|
||||
isAttack:boolean = false;
|
||||
|
||||
//是否移动
|
||||
isMove:boolean = false;
|
||||
|
||||
//是否死亡
|
||||
isDie:boolean = false;
|
||||
export abstract class GFSMAnimBase extends GFSMBase{
|
||||
|
||||
//轨道的索引
|
||||
trackIndex:number;
|
||||
@@ -59,10 +36,10 @@ export class GFSMBattleAmin extends GFSMBase{
|
||||
events:{event:string,fun:Function}[] = [];
|
||||
starts:{name:string,fun:Function}[] = [];
|
||||
|
||||
constructor(spine:sp.Skeleton,trackIndex?:number){
|
||||
constructor(spine:sp.Skeleton,trackIndex:number = 0){
|
||||
super();
|
||||
this.spine = spine;
|
||||
this.trackIndex = trackIndex || 0;
|
||||
this.trackIndex = trackIndex;
|
||||
//设置监听
|
||||
this.spine.setEventListener(this.onEventListener.bind(this));
|
||||
//因为SpineBUG所以不使用Spine监听 采用自己调用
|
||||
@@ -110,50 +87,7 @@ export class GFSMBattleAmin extends GFSMBase{
|
||||
}
|
||||
|
||||
// 流程图
|
||||
process: { [key: number]: GFSMProcessAnimInfo; } = {
|
||||
[ProcessEnum.Wait]:{
|
||||
title:"等待",
|
||||
isLoop:true,
|
||||
animName:GFSMBattleAminEnum.Wait,
|
||||
mixs:[0.1,0.1],
|
||||
to:[ProcessEnum.Move,ProcessEnum.Attack,ProcessEnum.Die],
|
||||
ifTo:[
|
||||
() => this.isMove, //前往移动
|
||||
() => this.isAttack, //前往攻击
|
||||
() => this.isDie,
|
||||
],
|
||||
},
|
||||
[ProcessEnum.Move]:{
|
||||
title:"移动",
|
||||
animName:GFSMBattleAminEnum.Walk,
|
||||
isLoop:true,
|
||||
mixs:[0.1,0.1],
|
||||
to:[ProcessEnum.Wait,ProcessEnum.Attack,ProcessEnum.Die],
|
||||
ifTo:[
|
||||
() => !this.isMove, //前往等待
|
||||
() => this.isAttack, //前往攻击
|
||||
() => this.isDie,
|
||||
],
|
||||
},
|
||||
[ProcessEnum.Attack]:{
|
||||
title:"攻击",
|
||||
animName:GFSMBattleAminEnum.Attack,
|
||||
isLoop:true,
|
||||
mixs:[0.1,0.1],
|
||||
to:[ProcessEnum.Wait,ProcessEnum.Move,ProcessEnum.Die],
|
||||
ifTo:[
|
||||
() => !this.isAttack, //前往等待
|
||||
() => !this.isAttack && this.isMove, //前往移动
|
||||
() => this.isDie,
|
||||
],
|
||||
},
|
||||
[ProcessEnum.Die]:{
|
||||
title:"死亡",
|
||||
animName:GFSMBattleAminEnum.Fly,
|
||||
isLoop:true,
|
||||
mixs:[0.1,0.1],
|
||||
}
|
||||
}
|
||||
process: { [key: number]: GFSMProcessAnimInfo; } = {}
|
||||
|
||||
execute(process:GFSMProcessAnimInfo,dt:number){
|
||||
process.ifTo = process.ifTo || [];
|
||||
@@ -188,8 +122,7 @@ export class GFSMBattleAmin extends GFSMBase{
|
||||
//播放动画
|
||||
if(!info.track){
|
||||
console.log(`播放动画-${this.spine.getComponent(GObject).nId}-`,info);
|
||||
info.track = this.spine.setAnimation(this.trackIndex,info.animName,info.isLoop);
|
||||
// this.onStartListener(info.track);
|
||||
info.track = this.spine.setAnimation(this.trackIndex,info.animName,!!info.isLoop);
|
||||
}
|
||||
|
||||
return to;
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "dda21a8f-93da-4421-a0d9-bda29817a6c9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
import { GRoleUtil } from "../../../entity/GRole";
|
||||
import GRoleBase from "../../role/GRoleBase";
|
||||
import GRolePVPEntity from "../../role/PVP/GRolePVPEntity";
|
||||
import GFSMBattle from "../base/GFSMBattle/GFSMBattle";
|
||||
|
||||
|
||||
//PVP 状态机
|
||||
export default class GFSMPVP extends GFSMBattle{
|
||||
|
||||
get player(): GRolePVPEntity {
|
||||
return super.player as GRolePVPEntity;
|
||||
}
|
||||
|
||||
constructor(player:GRolePVPEntity){
|
||||
super(player);
|
||||
this._player = GRoleUtil.get(player);
|
||||
}
|
||||
|
||||
//寻敌
|
||||
onSeekEnemy(): GRoleBase<any> {
|
||||
return this.player.mode.getEnumy(this.player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +0,0 @@
|
||||
import { GFSMBattleAmin } from "../base/GFSMBattle/GFSMBattleAmin";
|
||||
|
||||
export default class GFSMPVPAnim extends GFSMBattleAmin{
|
||||
|
||||
}
|
||||
|
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "552fd09c-0320-46c9-ac7a-abe954b75093",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "05230b14-5c88-45fd-99c6-31b4b0513f45",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
@@ -1,20 +1,15 @@
|
||||
import { _decorator, sp } from "cc";
|
||||
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";
|
||||
import { Vec2 } from "cc";
|
||||
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 { app } from "../../../App";
|
||||
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
|
||||
import { GAttack, GAttackBase } from "../attack/GAttack";
|
||||
import { TableGRole } from "../../../../resources/config/ts/TableGRole";
|
||||
import { TableGRoleSkill } from "../../../../resources/config/ts/TableGRoleSkill";
|
||||
import { GSkill, GSkillBase, GSkillState } from "../../skill/GSkill";
|
||||
import JNSkeleton from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/spine/JNFrameSkeleton";
|
||||
import { GFSMAnimBase } from "../fsm/GFSMAnimBase";
|
||||
import GFSMBase from "../fsm/GFSMBase";
|
||||
import { app } from "../../../App";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export enum GRoleAnimEvent{
|
||||
@@ -28,19 +23,13 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
spine:JNSkeleton;
|
||||
|
||||
//角色
|
||||
role:TableGRole
|
||||
|
||||
//角色技能
|
||||
skills:GSkillBase[] = [];
|
||||
|
||||
//角色类型
|
||||
type:number;
|
||||
role:TableGRole;
|
||||
|
||||
//状态机
|
||||
fsm:GFSMBattle;
|
||||
fsm:GFSMBase;
|
||||
|
||||
//动画状态机
|
||||
fsmAnim:GFSMBattleAmin;
|
||||
fsmAnim:GFSMAnimBase;
|
||||
|
||||
//玩家攻击范围
|
||||
range:number = 100;
|
||||
@@ -48,20 +37,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
//移动速度
|
||||
moveSpeed:number = 80;
|
||||
|
||||
//在阵容中的下标
|
||||
tacticalIndex:number;
|
||||
//阵容
|
||||
_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}
|
||||
set tacticalPos(value:Vec2){ this._tacticalPos = value}
|
||||
|
||||
//血量
|
||||
blood:number = 100;
|
||||
fullBlood:number = 100;
|
||||
@@ -71,8 +46,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
get isDie(){ return this._isDie}
|
||||
set isDie(value:boolean){
|
||||
this._isDie = value;
|
||||
//设置死亡状态
|
||||
this.fsmAnim.isDie = value;
|
||||
}
|
||||
|
||||
//受击回调
|
||||
@@ -85,7 +58,7 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
//添加受击回调
|
||||
addAttackCallback(fun:Function){this.attackCallbacks.push(fun)};
|
||||
|
||||
get():GRoleBase<T>{
|
||||
get():this{
|
||||
if(this.isDie) return null;
|
||||
return this;
|
||||
}
|
||||
@@ -99,41 +72,23 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
return;
|
||||
}
|
||||
|
||||
// this.spine.debugBones = true;
|
||||
|
||||
this.bind(this.role);
|
||||
|
||||
//创建角色状态机
|
||||
this.fsm = this.fsmCreate();
|
||||
//创建角色动画状态机
|
||||
this.fsmAnim = this.fsmAnimCreate();
|
||||
|
||||
//监听攻击
|
||||
this.fsmAnim.addEventListener(GRoleAnimEvent.Attack,this.onAttack.bind(this));
|
||||
//监听死亡击飞
|
||||
this.fsmAnim.addStartListener(GFSMBattleAminEnum.Fly,this.onFly.bind(this));
|
||||
|
||||
}
|
||||
|
||||
//设置角色
|
||||
bind(role:TableGRole){
|
||||
//初始化
|
||||
protected init(role:TableGRole){
|
||||
if(this.spine)
|
||||
this.spine.skeletonData = app.role.skData[role.id];
|
||||
|
||||
this.range = role.roleAttackRange; //设置攻击范围
|
||||
this.role = role; //设置角色
|
||||
|
||||
// 设置技能
|
||||
this.skills = role.roleSkillIds.map(skillId => {
|
||||
let info = TableGRoleSkill.getConfig(skillId);
|
||||
return (new GSkill[info.skillController]()).bind(this,info);
|
||||
})
|
||||
}
|
||||
|
||||
//创建一个状态机
|
||||
protected abstract fsmCreate():GFSMBattle;
|
||||
protected abstract fsmCreate():GFSMBase;
|
||||
//创建一个动画状态机
|
||||
protected abstract fsmAnimCreate():GFSMBattleAmin;
|
||||
protected abstract fsmAnimCreate():GFSMAnimBase;
|
||||
|
||||
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T){
|
||||
|
||||
@@ -141,9 +96,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
this.fsm && this.fsm.onUpdate(dt / 1000);
|
||||
this.fsmAnim && this.fsmAnim.onUpdate(dt / 1000);
|
||||
|
||||
//更新技能
|
||||
this.skills.forEach(skill => skill.onUpdate(dt));
|
||||
|
||||
}
|
||||
|
||||
//向目标点移动
|
||||
@@ -188,29 +140,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
}
|
||||
}
|
||||
|
||||
//攻击
|
||||
onAttack(){
|
||||
if(!this.fsm.enemy) return;
|
||||
//敌人扣血
|
||||
let info = TableGRoleAttack.getConfig(this.role.id);
|
||||
(new GAttack[info.attackWay]()).attack(this,info);
|
||||
this.attackCallbacks.forEach(fun => fun());
|
||||
}
|
||||
|
||||
//释放技能 每一次只能释放一次
|
||||
onSkill():boolean{
|
||||
|
||||
for (const item of this.skills) {
|
||||
if(item.isRelease()){
|
||||
//如果可以释放则释放
|
||||
item.release();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//受击
|
||||
onHit(){
|
||||
// return;
|
||||
@@ -236,66 +165,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
}
|
||||
}
|
||||
|
||||
//击飞
|
||||
onFly(){
|
||||
|
||||
if(this.nId == 1)
|
||||
console.log("onFly");
|
||||
let vWorld = this.node.worldPosition;
|
||||
let vEndWorld = this.getWorldBackLen(v2(1500,500));
|
||||
this.JTween(vWorld)
|
||||
.to({x:vEndWorld.x},1000)
|
||||
.onUpdate(pos => this.node.worldPosition = pos)
|
||||
.start();
|
||||
this.JTween(vWorld)
|
||||
.to({y:vEndWorld.y},1000)
|
||||
.easing(JEasing.Circular.Out)
|
||||
.onUpdate(pos => this.node.worldPosition = vWorld)
|
||||
.start();
|
||||
|
||||
}
|
||||
|
||||
//恢复阵容朝向
|
||||
onRecoverTacticalTowards(){
|
||||
this.setTowards(this.tactical.towards);
|
||||
}
|
||||
|
||||
//过滤敌人
|
||||
filterEnemy(roles:GRoleBase<{}>[] = []){
|
||||
return roles.filter(role => role.type != this.type);
|
||||
}
|
||||
|
||||
//判断是否可以释放技能
|
||||
isReleaseSkill():boolean{
|
||||
for (const skill of this.skills) {
|
||||
if(skill.isRelease()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//释放技能
|
||||
onReleaseSkill():boolean{
|
||||
for (const skill of this.skills) {
|
||||
if(skill.isRelease()){
|
||||
skill.release();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//是否正在释放技能
|
||||
isReleasingSkill():boolean {
|
||||
for (const skill of this.skills) {
|
||||
if(skill.state() == GSkillState.Releasing){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
200
JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts
Normal file
200
JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts
Normal file
@@ -0,0 +1,200 @@
|
||||
import { _decorator } from "cc";
|
||||
import GRoleBase, { GRoleAnimEvent } from "./GRoleBase";
|
||||
import { ProgressBar } from "cc";
|
||||
import { JNFrameInfo } from "../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
import { TableGRole } from "../../../../resources/config/ts/TableGRole";
|
||||
import { GFSMAnimBase, GFSMBattleAminEnum } from "../fsm/GFSMAnimBase";
|
||||
import { GFSMDefaultAnim } from "../fsm/Default/GFSMDefaultAnim";
|
||||
import GFSMDefault from "../fsm/Default/GFSMDefault";
|
||||
import { JEasing } from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/tween/JNFrameTween";
|
||||
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
|
||||
import { GAttack } from "../attack/GAttack";
|
||||
import { v2 } from "cc";
|
||||
import { GTactical } from "../../entity/GTactical";
|
||||
import { Vec2 } from "cc";
|
||||
import { GSkill, GSkillBase, GSkillState } from "../../skill/GSkill";
|
||||
import { TableGRoleSkill } from "../../../../resources/config/ts/TableGRoleSkill";
|
||||
const { property,ccclass } = _decorator;
|
||||
|
||||
//默认角色类
|
||||
@ccclass('GRoleDefault')
|
||||
export default class GRoleDefault extends GRoleBase<{}>{
|
||||
|
||||
@property(ProgressBar)
|
||||
bloodVolume:ProgressBar;
|
||||
|
||||
//能量条
|
||||
@property(ProgressBar)
|
||||
energyVolume:ProgressBar;
|
||||
|
||||
|
||||
//状态机
|
||||
fsm:GFSMDefault;
|
||||
|
||||
//动画状态机
|
||||
fsmAnim:GFSMDefaultAnim;
|
||||
|
||||
get isDie(){ return this._isDie}
|
||||
set isDie(value:boolean){
|
||||
this._isDie = value;
|
||||
//设置死亡状态
|
||||
this.fsmAnim.isDie = value;
|
||||
}
|
||||
|
||||
//角色类型
|
||||
type:number;
|
||||
|
||||
//在阵容中的下标
|
||||
tacticalIndex:number;
|
||||
|
||||
//阵容
|
||||
_tactical:GTactical;
|
||||
get tactical(){return this._tactical};
|
||||
set tactical(value:GTactical){
|
||||
this.setTowards(value.towards);
|
||||
this._tactical = value;
|
||||
}
|
||||
//阵容位置
|
||||
get tacticalPos(){ return this.tactical.getPosition(this.tacticalIndex)}
|
||||
|
||||
//角色技能
|
||||
skills:GSkillBase[] = [];
|
||||
|
||||
onSyncLoad(){
|
||||
super.onSyncLoad();
|
||||
|
||||
//监听攻击
|
||||
this.fsmAnim.addEventListener(GRoleAnimEvent.Attack,this.onAttack.bind(this));
|
||||
//监听死亡击飞
|
||||
this.fsmAnim.addStartListener(GFSMBattleAminEnum.Fly,this.onFly.bind(this));
|
||||
}
|
||||
|
||||
//初始化
|
||||
onInit(type:number,role:TableGRole,tactical:GTactical,tacticalIndex:number){
|
||||
super.init(role);
|
||||
this.type = type;
|
||||
|
||||
this.range = role.roleAttackRange; //设置攻击范围
|
||||
this.role = role; //设置角色
|
||||
|
||||
this.tactical = tactical;
|
||||
this.tacticalIndex = tacticalIndex;
|
||||
|
||||
// 设置技能
|
||||
this.skills = role.roleSkillIds.map(skillId => {
|
||||
let info = TableGRoleSkill.getConfig(skillId);
|
||||
return (new GSkill[info.skillController]()).bind(this,info);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: {}) {
|
||||
|
||||
super.onSyncUpdate(dt,frame,input);
|
||||
|
||||
//更新技能
|
||||
this.skills.forEach(skill => skill.onUpdate(dt));
|
||||
|
||||
//更新显示
|
||||
this.bloodVolume.progress = this.blood / this.fullBlood;
|
||||
//显示第一个技能进度条
|
||||
if(this.skills[0]){
|
||||
this.energyVolume.progress = this.skills[0].getProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected fsmCreate(): GFSMDefault {
|
||||
return new GFSMDefault(this);
|
||||
}
|
||||
protected fsmAnimCreate(): GFSMDefaultAnim {
|
||||
return new GFSMDefaultAnim(this.spine);
|
||||
}
|
||||
|
||||
//攻击
|
||||
onAttack(){
|
||||
if(!this.fsm.enemy) return;
|
||||
//敌人扣血
|
||||
let info = TableGRoleAttack.getConfig(this.role.id);
|
||||
(new GAttack[info.attackWay]()).attack(this,info);
|
||||
this.attackCallbacks.forEach(fun => fun());
|
||||
}
|
||||
|
||||
//击飞
|
||||
onFly(){
|
||||
|
||||
let vWorld = this.node.worldPosition;
|
||||
let vEndWorld = this.getWorldBackLen(v2(1500,500));
|
||||
this.JTween(vWorld)
|
||||
.to({x:vEndWorld.x},1000)
|
||||
.onUpdate(pos => this.node.worldPosition = pos)
|
||||
.start();
|
||||
this.JTween(vWorld)
|
||||
.to({y:vEndWorld.y},1000)
|
||||
.easing(JEasing.Circular.Out)
|
||||
.onUpdate(pos => this.node.worldPosition = vWorld)
|
||||
.start();
|
||||
|
||||
}
|
||||
|
||||
//过滤敌人
|
||||
filterEnemy(roles:GRoleDefault[] = []){
|
||||
return roles.filter(role => role.type != this.type);
|
||||
}
|
||||
|
||||
//恢复阵容朝向
|
||||
onRecoverTacticalTowards(){
|
||||
this.setTowards(this.tactical.towards);
|
||||
}
|
||||
|
||||
//释放技能 每一次只能释放一次
|
||||
onSkill():boolean{
|
||||
|
||||
for (const item of this.skills) {
|
||||
if(item.isRelease()){
|
||||
//如果可以释放则释放
|
||||
item.release();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//判断是否可以释放技能
|
||||
isReleaseSkill():boolean{
|
||||
for (const skill of this.skills) {
|
||||
if(skill.isRelease()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//释放技能
|
||||
onReleaseSkill():boolean{
|
||||
for (const skill of this.skills) {
|
||||
if(skill.isRelease()){
|
||||
skill.release();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//是否正在释放技能
|
||||
isReleasingSkill():boolean {
|
||||
for (const skill of this.skills) {
|
||||
if(skill.state() == GSkillState.Releasing){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
onQueryEunmy():GRoleDefault{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "27681ee3-9d09-4a06-be5e-71af045319b8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "34152d1b-ca03-4bb1-a970-692cd8995991",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
@@ -1,86 +0,0 @@
|
||||
import { _decorator } from "cc";
|
||||
import GRoleBase from "../GRoleBase";
|
||||
import GFSMPVP from "../../fsm/PVP/GFSMPVP";
|
||||
import GPVPMode, { GPVPModePlayerEnum } from "../../../modes/GPVPMode";
|
||||
import { GFSMBattleAmin } from "../../fsm/base/GFSMBattle/GFSMBattleAmin";
|
||||
import { JNFrameInfo } from "../../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
import { ProgressBar } from "cc";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export interface GDemoMessage{
|
||||
isAttack?:boolean;
|
||||
isRun?:boolean;
|
||||
}
|
||||
|
||||
//PVP 角色
|
||||
@ccclass('GRolePVPEntity')
|
||||
export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
|
||||
|
||||
//所属阵容
|
||||
_ones:GPVPModePlayerEnum;
|
||||
get ones():GPVPModePlayerEnum{
|
||||
return this._ones;
|
||||
}
|
||||
set ones(value:GPVPModePlayerEnum){
|
||||
this._ones = value;
|
||||
}
|
||||
|
||||
@property(ProgressBar)
|
||||
bloodVolume:ProgressBar;
|
||||
|
||||
//能量条
|
||||
@property(ProgressBar)
|
||||
energyVolume:ProgressBar;
|
||||
|
||||
onSyncLoad(){
|
||||
super.onSyncLoad();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//更新显示
|
||||
this.bloodVolume.progress = this.blood / this.fullBlood;
|
||||
//显示第一个技能进度条
|
||||
if(this.skills[0]){
|
||||
this.energyVolume.progress = this.skills[0].getProgress();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
get mode():GPVPMode{
|
||||
return super.mode as GPVPMode;
|
||||
}
|
||||
set mode(value:GPVPMode){
|
||||
this._mode = value;
|
||||
}
|
||||
|
||||
|
||||
protected fsmCreate(): GFSMPVP {
|
||||
return new GFSMPVP(this);
|
||||
}
|
||||
protected fsmAnimCreate(): GFSMBattleAmin {
|
||||
return new GFSMBattleAmin(this.spine);
|
||||
}
|
||||
|
||||
//添加死亡销毁
|
||||
onHit(){
|
||||
super.onHit();
|
||||
if(this.isDie){
|
||||
//销毁数据
|
||||
this.mode.killRole(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user