mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
update
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
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 { GFSMBattleAmin, GFSMBattleAminEnum } from "../fsm/base/GFSMBattle/GFSMBattleAmin";
|
||||
import { Vec2 } from "cc";
|
||||
import { v2 } 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";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export enum GRoleAnimEvent{
|
||||
@@ -26,9 +26,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
//动画状态机
|
||||
fsmAnim:GFSMBattleAmin;
|
||||
|
||||
//玩家是否镜像
|
||||
_isMirror:boolean = false;
|
||||
|
||||
//玩家攻击范围
|
||||
range:number = 100;
|
||||
|
||||
@@ -48,16 +45,18 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
blood:number = 100;
|
||||
fullBlood:number = 100;
|
||||
|
||||
get isMirror(){
|
||||
return this._isMirror;
|
||||
//是否死亡
|
||||
_isDie:boolean = false;
|
||||
get isDie(){ return this._isDie}
|
||||
set isDie(value:boolean){
|
||||
this._isDie = value;
|
||||
//设置死亡状态
|
||||
this.fsmAnim.isDie = value;
|
||||
}
|
||||
set isMirror(value:boolean){
|
||||
if(value){
|
||||
GObject.SetMirror(this);
|
||||
}else{
|
||||
GObject.SetMirror(this,false);
|
||||
}
|
||||
this._isMirror = value;
|
||||
|
||||
get():GRoleBase<T>{
|
||||
if(this.isDie) return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
onSyncLoad(){
|
||||
@@ -76,21 +75,11 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
//监听攻击
|
||||
this.fsmAnim.addEventListener(GRoleAnimEvent.Attack,this.onAttack.bind(this));
|
||||
//监听死亡击飞
|
||||
this.fsmAnim.addStartListener(GFSMBattleAminEnum.Fly,this.onFly.bind(this));
|
||||
|
||||
}
|
||||
|
||||
//攻击
|
||||
onAttack(){
|
||||
//敌人扣血
|
||||
this.fsm.enemy.onHit();
|
||||
}
|
||||
|
||||
//受击
|
||||
onHit(){
|
||||
this.blood--;
|
||||
}
|
||||
|
||||
|
||||
//创建一个状态机
|
||||
protected abstract fsmCreate():GFSMBattle;
|
||||
//创建一个动画状态机
|
||||
@@ -120,5 +109,42 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
}
|
||||
|
||||
//攻击
|
||||
onAttack(){
|
||||
//敌人扣血
|
||||
this.fsm.enemy.onHit();
|
||||
}
|
||||
|
||||
//受击
|
||||
onHit(){
|
||||
this.blood-=50;
|
||||
//检测是否死亡
|
||||
if(this.blood <= 0){
|
||||
//关闭状态机
|
||||
this.fsm.close();
|
||||
//设置死亡
|
||||
this.isDie = true;
|
||||
}
|
||||
}
|
||||
|
||||
//击飞
|
||||
onFly(){
|
||||
|
||||
console.log("onFly");
|
||||
let vWorld = this.node.worldPosition;
|
||||
let vEndWorld = this.getWorldBackLen(v2(800,500));
|
||||
JTween(vWorld)
|
||||
.to({x:vEndWorld.x},500)
|
||||
.onUpdate(pos => this.node.worldPosition = vWorld)
|
||||
.start();
|
||||
JTween(vWorld)
|
||||
.to({y:vEndWorld.y},500)
|
||||
.easing(JEasing.Circular.Out)
|
||||
.onUpdate(pos => this.node.worldPosition = vWorld)
|
||||
.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -67,12 +67,21 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
|
||||
}
|
||||
|
||||
protected fsmCreate(): GFSMPVP {
|
||||
// return null;
|
||||
return new GFSMPVP(this);
|
||||
}
|
||||
protected fsmAnimCreate(): GFSMBattleAmin {
|
||||
return new GFSMBattleAmin(this.spine);
|
||||
}
|
||||
|
||||
//添加死亡销毁
|
||||
onHit(){
|
||||
super.onHit();
|
||||
if(this.isDie){
|
||||
//销毁数据
|
||||
this.mode.killRole(this);
|
||||
this.node.removeFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user