feat(英雄系统): 添加怒气值属性及相关功能
top 血条样式调整 - 在HeroAttrsComp中添加pow属性表示当前怒气值 - 在HeroAttrs枚举中添加POW_MAX和POW_REGEN属性 - 修改HeroViewComp根据英雄类型显示不同资源条 - 调整boss血条位置偏移量 - 注释掉物理系统调试绘制代码
This commit is contained in:
@@ -12,7 +12,7 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('Main')
|
||||
export class Main extends Root {
|
||||
start() {
|
||||
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
||||
// PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
||||
// |EPhysics2DDrawFlags.Pair
|
||||
// |EPhysics2DDrawFlags.CenterOfMass
|
||||
// |EPhysics2DDrawFlags.Joint
|
||||
|
||||
@@ -43,6 +43,8 @@ export enum Attrs {
|
||||
HP_REGEN = 3, // 生命回复
|
||||
MP_REGEN = 4, // 魔法回复
|
||||
HEAL_EFFECT = 5, // 治疗效果
|
||||
POW_MAX = 6, // 最大怒气值
|
||||
POW_REGEN = 7, // 怒气值回复
|
||||
|
||||
// ========== 攻击属性 (10-19) ==========
|
||||
AP = 10, // 攻击力
|
||||
@@ -152,6 +154,8 @@ export const AttrsType: Record<Attrs, BType> = {
|
||||
[Attrs.SHIELD_MAX]: BType.VALUE, // 最大护盾值 - 数值型
|
||||
[Attrs.HP_REGEN]: BType.VALUE, // 生命回复 - 数值型
|
||||
[Attrs.MP_REGEN]: BType.VALUE, // 魔法回复 - 数值型
|
||||
[Attrs.POW_MAX]: BType.VALUE, // 最大怒气值 - 数值型
|
||||
[Attrs.POW_REGEN]: BType.VALUE, // 怒气值回复 - 数值型
|
||||
[Attrs.HEAL_EFFECT]: BType.RATIO, // 治疗效果 - 百分比型
|
||||
|
||||
// ========== 攻击属性(数值型) ==========
|
||||
|
||||
@@ -28,6 +28,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
// ==================== 动态属性值 ====================
|
||||
hp: number = 100; // 当前血量
|
||||
mp: number = 100; // 当前魔法值
|
||||
pow: number = 0; // 当前怒气值
|
||||
shield: number = 0; // 当前护盾
|
||||
Attrs: any = []; // 最终属性数组(经过Buff计算后)
|
||||
NeAttrs: any = []; // 负面状态数组
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Attrs, } from "../common/config/HeroAttrs";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
import { Tooltip } from "../skill/Tooltip";
|
||||
import { timedCom } from "../skill/timedCom";
|
||||
import { HeroInfo, HType } from "../common/config/heroSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -28,6 +29,8 @@ export class HeroViewComp extends CCComp {
|
||||
status:String = "idle"
|
||||
scale: number = 1; // 显示方向
|
||||
box_group:number = BoxSet.HERO; // 碰撞组
|
||||
usePower:boolean = false;
|
||||
useMp:boolean = false;
|
||||
// ==================== UI 节点引用 ====================
|
||||
private top_node: Node = null!;
|
||||
|
||||
@@ -66,11 +69,14 @@ export class HeroViewComp extends CCComp {
|
||||
this.node.setScale(this.scale,1);
|
||||
this.top_node.setScale(this.scale,1);
|
||||
if(this.model && this.model.is_boss){
|
||||
this.top_node.position=v3(this.node.position.x,this.node.position.y+100,0)
|
||||
this.top_node.position=v3(this.node.position.x,this.node.position.y+70,0)
|
||||
}
|
||||
/* 显示角色血*/
|
||||
this.top_node.getChildByName("hp").active = true;
|
||||
this.top_node.getChildByName("pow").active = true;
|
||||
this.usePower=HeroInfo[this.model.hero_uuid].type==HType.warrior||HeroInfo[this.model.hero_uuid].type==HType.assassin;
|
||||
this.useMp=HeroInfo[this.model.hero_uuid].type==HType.mage||HeroInfo[this.model.hero_uuid].type==HType.remote||HeroInfo[this.model.hero_uuid].type==HType.support;
|
||||
this.top_node.getChildByName("pow").active = this.usePower;
|
||||
this.top_node.getChildByName("mp").active = this.useMp;
|
||||
}
|
||||
|
||||
/** 初始化 UI 节点引用 */
|
||||
@@ -98,7 +104,8 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
// ✅ 更新 UI 显示(数据由 HeroAttrSystem 更新)
|
||||
this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]);
|
||||
this.mp_show(this.model.mp, this.model.Attrs[Attrs.MP_MAX]);
|
||||
if(this.useMp) this.mp_show(this.model.mp, this.model.Attrs[Attrs.MP_MAX]);
|
||||
if(this.usePower) this.pow_show(this.model.pow, this.model.Attrs[Attrs.POW_MAX]);
|
||||
this.show_shield(this.model.shield, this.model.Attrs[Attrs.SHIELD_MAX]);
|
||||
}
|
||||
|
||||
@@ -125,12 +132,17 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
/** 显示魔法值 */
|
||||
private mp_show(mp: number, mp_max: number) {
|
||||
this.top_node.getChildByName("pow").getComponent(ProgressBar).progress = mp / mp_max;
|
||||
this.top_node.getChildByName("mp").getComponent(ProgressBar).progress = mp / mp_max;
|
||||
this.scheduleOnce(() => {
|
||||
this.top_node.getChildByName("pow").getChildByName("mpb").getComponent(ProgressBar).progress = mp / mp_max;
|
||||
this.top_node.getChildByName("mp").getChildByName("mpb").getComponent(ProgressBar).progress = mp / mp_max;
|
||||
}, 0.15);
|
||||
}
|
||||
private pow_show(pow: number, pow_max: number) {
|
||||
this.top_node.getChildByName("pow").getComponent(ProgressBar).progress = pow / pow_max;
|
||||
this.scheduleOnce(() => {
|
||||
this.top_node.getChildByName("pow").getChildByName("mpb").getComponent(ProgressBar).progress = pow / pow_max;
|
||||
}, 0.15);
|
||||
}
|
||||
|
||||
/** 升级特效 */
|
||||
private lv_up() {
|
||||
var path = "game/skill/buff/buff_lvup";
|
||||
|
||||
Reference in New Issue
Block a user