基础的数值计算

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-11-30 02:20:57 +08:00
parent 6cd69ca9e3
commit 8dcf92a302
33 changed files with 363 additions and 36 deletions

View File

@@ -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();
}
}

View File

@@ -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;