Files
pixelheros/assets/script/game/component/hero/HeroModel.ts
walkpan bffbb9077e dd
2025-02-01 00:14:25 +08:00

40 lines
1.0 KiB
TypeScript

import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { HeroConfig } from "../../config/HeroConfig";
@ecs.register('HeroModel')
export class HeroModel extends ecs.Comp {
/** 角色配置ID */
configId: number = 0;
/** 当前生命值 */
hp: number = 0;
/** 最大生命值 */
maxHp: number = 0;
/** 基础攻击力 */
attack: number = 0;
/** 防御力 */
defense: number = 0;
/** 暴击率 0-100 */
critRate: number = 5;
/** 闪避率 0-100 */
dodgeRate: number = 5;
init(config: HeroConfig) {
this.configId = config.id;
this.maxHp = config.hp;
this.hp = config.hp;
this.attack = config.attack;
this.defense = config.defense;
this.critRate = config.critRate || 5;
this.dodgeRate = config.dodgeRate || 5;
}
reset() {
this.configId = 0;
this.hp = 0;
this.maxHp = 0;
this.attack = 0;
this.defense = 0;
this.critRate = 5;
this.dodgeRate = 5;
}
}