mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
基础的数值计算
This commit is contained in:
@@ -8,6 +8,8 @@ import { GFSMAnimBase } from "../fsm/GFSMAnimBase";
|
||||
import GFSMBase from "../fsm/GFSMBase";
|
||||
import { app } from "../../../App";
|
||||
import { TB } from "../../../../resources/config/data/schema";
|
||||
import GRoleValues, { GRoleAttackType } from "../values/GRoleValues";
|
||||
import GAttributeBase from "../values/attribute/GAttributeBase";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export enum GRoleAnimEvent{
|
||||
@@ -19,8 +21,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
@property(JNSkeleton)
|
||||
spine:JNSkeleton;
|
||||
// @property(sp.Skeleton)
|
||||
// spine:sp.Skeleton;
|
||||
|
||||
//角色
|
||||
role:TB.TbGRole;
|
||||
@@ -63,6 +63,9 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
//添加攻击回调
|
||||
addAttackCallback(fun:Function){this.attackCallbacks.push(fun)};
|
||||
|
||||
//角色数值类
|
||||
values:GRoleValues;
|
||||
|
||||
get():this{
|
||||
if(this.isDie) return null;
|
||||
return this;
|
||||
@@ -82,6 +85,9 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
//创建角色动画状态机
|
||||
this.fsmAnim = this.fsmAnimCreate();
|
||||
|
||||
//创建数值类
|
||||
this.values = new GRoleValues();
|
||||
|
||||
}
|
||||
|
||||
//初始化
|
||||
@@ -145,11 +151,12 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
}
|
||||
}
|
||||
|
||||
//受击
|
||||
onHit(){
|
||||
//受击 伤害类型 伤害
|
||||
onHit(type:GRoleAttackType,harm:number,enemy:GRoleBase<{}>){
|
||||
// return;
|
||||
this.blood -= 10;
|
||||
this.hitCallbacks.forEach(fun => fun(this,10));
|
||||
harm = this.values.onUnderAttack(type,harm)
|
||||
this.blood -= harm;
|
||||
this.hitCallbacks.forEach(fun => fun(this,harm));
|
||||
//检测是否死亡
|
||||
if(this.blood <= 0){
|
||||
//关闭状态机
|
||||
@@ -170,6 +177,20 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
}
|
||||
}
|
||||
|
||||
//生效数值
|
||||
onEffectiveValue(...values:GAttributeBase[]){
|
||||
|
||||
this.values.reset();
|
||||
values.forEach(value => {
|
||||
this.values.add(value);
|
||||
})
|
||||
this.values.update();
|
||||
|
||||
//赋值血量
|
||||
this.blood = this.fullBlood = this.values.onBlood();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -9,9 +9,7 @@ import { JEasing } from "../../../../../extensions/ngame/assets/ngame/sync/frame
|
||||
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 JNFrameTime from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/time/JNFrameTime";
|
||||
import { TB } from "../../../../resources/config/data/schema";
|
||||
import { TD } from "../../../App";
|
||||
const { property,ccclass } = _decorator;
|
||||
|
Reference in New Issue
Block a user