From 0d697c488d05b603339415b25c695afbfeb810fe Mon Sep 17 00:00:00 2001 From: panw Date: Thu, 24 Apr 2025 16:59:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0hp=20=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/hero/BuffComp.ts | 48 +++++++++++++++--------- assets/script/game/hero/HeroViewComp.ts | 46 +++++++++-------------- assets/script/game/map/MissionMonComp.ts | 2 +- 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/assets/script/game/hero/BuffComp.ts b/assets/script/game/hero/BuffComp.ts index 222376ee..4e68fd95 100644 --- a/assets/script/game/hero/BuffComp.ts +++ b/assets/script/game/hero/BuffComp.ts @@ -5,10 +5,12 @@ import { Tooltip } from '../skills/Tooltip'; import { timedCom } from '../skills/timedCom'; import { smc } from '../common/SingletonModuleComp'; import { BuffGet } from '../skills/BuffGet'; +import { HeroViewComp } from './HeroViewComp'; const { ccclass, property } = _decorator; @ccclass('BuffComp') export class BuffComp extends Component { + top_node:any=null; ap_node:any=null; cd_node:any=null; def_node:any=null; @@ -31,22 +33,21 @@ export class BuffComp extends Component { speek_time:number=0; start() { - // this.buff_get("dodge") - // this.node.getChildByName("top").getChildByName("buff").getChildByName("ap").active = false; - // this.node.getChildByName("top").getChildByName("buff").getChildByName("cd").active = false; - // this.node.getChildByName("top").getChildByName("buff").getChildByName("def").active = false; - // this.node.getChildByName("top").getChildByName("buff").getChildByName("hp").active = false; - let hp_node = this.node.getChildByName("top").getChildByName("hp"); - // hp_node.setPosition(hp_node.position.x,hp_node.position.y-140) + this.info_init() + } + + info_init(){ + this.top_node = this.node.getChildByName("top"); + this.top_node.getChildByName("ihp").getChildByName("num").getComponent(Label)!.string = this.node.getComponent(HeroViewComp).hp.toFixed(0) + this.top_node.getChildByName("iap").getChildByName("num").getComponent(Label)!.string = this.node.getComponent(HeroViewComp).ap.toFixed(0) } update(deltaTime: number) { if(smc.mission.pause) return - + this.hp_show() if(this.wind_cd > 0 ) this.wind_cd -= deltaTime; if(this.wind_cd <= 0 && this.node.getChildByName("wind").active){ this.node.getChildByName("wind").active = false; - } if(this.buff_cd > 0 ) this.buff_cd -= deltaTime; @@ -57,18 +58,31 @@ export class BuffComp extends Component { this.in_speek(deltaTime) } + hp_show(){ + let hp=this.node.getComponent(HeroViewComp).hp; + let hp_max=this.node.getComponent(HeroViewComp).hp_max; + let hp_progress= hp/hp_max; + this.top_node.getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress; + if(this.node.getComponent(HeroViewComp).is_boss) return + this.top_node.getChildByName("hp").active = (hp == hp_max) ? false : true; + } show_shield(val:boolean){ this.node.getChildByName("shielded").active=val } - buff_get(name:string){ - var path = "game/skills/buffget/buffget"; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - node.parent = this.node.getChildByName("top").getChildByName("buff"); - let comp=node.getComponent(BuffGet) - comp.init(name) + + update_info_hp(){ + let ihp_node = this.top_node.getChildByName("ihp"); + ihp_node.getChildByName("num").getComponent(Label)!.string = this.node.getComponent(HeroViewComp).hp.toFixed(0) + } - + + update_info_ap(){ + let iap_node = this.top_node.getChildByName("iap"); + iap_node.getChildByName("num").getComponent(Label)!.string = this.node.getComponent(HeroViewComp).ap.toFixed(0) + } + + + show_wind(t:number=1){ this.wind_cd = t; this.node.getChildByName("wind").active = true; diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 1f902f8c..5ac81863 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -86,6 +86,8 @@ export class HeroViewComp extends CCComp { }> = []; private isProcessingDamage: boolean = false; private damageInterval: number = 0.2; // 伤害数字显示间隔 + + private timer:Timer=new Timer(1); onLoad() { this.as = this.getComponent(HeroSpine); @@ -131,7 +133,10 @@ export class HeroViewComp extends CCComp { // this.ent.destroy(); // return // } - this.hp_show() + if(this.timer.update(dt)){ + this.add_ap(10) + this.add_hp_max(20) + }; if(this.ice_cd > 0){ this.ice_cd -=dt; return @@ -153,16 +158,7 @@ export class HeroViewComp extends CCComp { this.node.getChildByName("top").getChildByName("ihp").active = false; this.node.getChildByName("top").getChildByName("iap").active = false; } - hp_show(){ - let hp_progress= this.hp/this.hp_max; - this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress; - if(this.is_boss) return - this.node.getChildByName("top").getChildByName("hp").active = (this.hp == this.hp_max) ? false : true; - - } - //移动 - - //状态切换 + //状态切换 status_change(type:string){ this.status=type if(type == "idle"){ @@ -190,33 +186,25 @@ export class HeroViewComp extends CCComp { */ add_ap(ap: number){ this.ap += Math.floor(ap); - this.BUFFCOMP.buff_get("ap") + this.BUFFCOMP.update_info_ap() } + de_ap(ap: number){ this.ap -= Math.floor(ap); - this.BUFFCOMP.buff_get("deap") - } - /** - * 增加英雄的闪避率。 - * @param dodge 要增加的闪避率。 - */ - add_dodge(dodgeRate: number) { - this.dodge += Math.floor(dodgeRate); - this.BUFFCOMP.buff_get("dodge"); - } - de_dodge(dodgeRate: number) { - this.dodge += Math.floor(dodgeRate); - this.BUFFCOMP.buff_get("dedodge"); + this.BUFFCOMP.update_info_ap() } + add_hp_max(hprate: number=0){ - this.BUFFCOMP.buff_get("hp") - this.hp_max += Math.floor(hprate/100*this.hp_max) ; + this.hp_max += Math.floor(hprate) ; this.add_hp2(hprate) + this.BUFFCOMP.update_info_hp() } + de_hp_max(hprate: number=0){ - this.BUFFCOMP.buff_get("dehp") - this.hp_max -= Math.floor(hprate/100*this.hp_max) ; + this.hp_max -= Math.floor(hprate) ; + this.BUFFCOMP.update_info_hp() } + add_hp(hp: number = 0) { this.BUFFCOMP.heathed(); this.hp+=Math.floor(hp); diff --git a/assets/script/game/map/MissionMonComp.ts b/assets/script/game/map/MissionMonComp.ts index 2fc03e1b..eb47e089 100644 --- a/assets/script/game/map/MissionMonComp.ts +++ b/assets/script/game/map/MissionMonComp.ts @@ -15,7 +15,7 @@ const { ccclass, property } = _decorator; @ccclass('MissionMonCompComp') @ecs.register('MissionMonComp', false) export class MissionMonCompComp extends CCComp { - timer:Timer=new Timer(3) + timer:Timer=new Timer(10) // 添加刷怪队列 private monsterQueue: Array<{uuid: number, position: number, isBoss: boolean}> = []; private isSpawning: boolean = false;