加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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user