加hp 有问题
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user