import GRoleBase from "../role/GRoleBase"; import GFSMBase, { GFSMProcessInfo } from "./GFSMBase"; export default abstract class GFSMBattle extends GFSMBase{ //流程图 process: { [key: number]: GFSMProcessInfo; } = { 0:{ title:"寻找敌人", execute: this.onSeekEnemyProcess.bind(this), to:[1] }, 1:{ title:"攻击敌人", execute: this.onAttackProcess.bind(this), } } //锁定的敌人 enemy:GRoleBase; abstract onSeekEnemy():GRoleBase; //寻敌流程 onSeekEnemyProcess():number{ if(this.enemy){ //如果有敌人 直接 攻击 return 1; } if(this.enemy = this.onSeekEnemy()){ //如果有敌人 直接 攻击 return 1; } //负责继续寻敌 return 0; } abstract onAttack(); //攻击敌人 onAttackProcess(){ this.onAttack(); return 0; } }