血量更新 修改
This commit is contained in:
@@ -53,6 +53,7 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
hp: number = 100; /** 血量 */
|
||||
hp_max: number = 100; /** 最大血量 */
|
||||
rhp_max: number = 100;
|
||||
hp_speed: number = 0; //每秒回复量
|
||||
|
||||
pw: number = 0; /**能量**/
|
||||
@@ -178,13 +179,16 @@ export class HeroViewComp extends CCComp {
|
||||
let self_x = selfCollider.node.position.x;
|
||||
let other_x = otherCollider.node.position.x;
|
||||
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
|
||||
|
||||
if(selfCollider.group==BoxSet.HERO){
|
||||
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 8 ){
|
||||
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 20 ){
|
||||
// this.node.setSiblingIndex(otherCollider.node.getSiblingIndex()-10)
|
||||
this.stop_cd = 0.1;
|
||||
}
|
||||
}
|
||||
if(selfCollider.group==BoxSet.MONSTER){
|
||||
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x > other_x && Math.abs(other_x-self_x) < 8 ){
|
||||
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x > other_x && Math.abs(other_x-self_x) < 20 ){
|
||||
// this.node.setSiblingIndex(otherCollider.node.getSiblingIndex()-10)
|
||||
this.stop_cd = 0.1;
|
||||
}
|
||||
}
|
||||
@@ -214,7 +218,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.at += dt;
|
||||
this.check_enemy_alive()
|
||||
this.in_atk(dt);
|
||||
// this.hp_show()
|
||||
this.hp_show()
|
||||
this.move(dt);
|
||||
this.check_mission_buf()
|
||||
}
|
||||
@@ -223,41 +227,35 @@ export class HeroViewComp extends CCComp {
|
||||
this.crit_max=(100+smc.vmdata.mission.crit)/100*this.crit
|
||||
this.def_max=(100+smc.vmdata.mission.def)/100*this.def
|
||||
this.dodge_max=(100+smc.vmdata.mission.dodge)/100*this.dodge
|
||||
this.rhp_max=(100+smc.vmdata.mission.hp)/100*this.hp_max
|
||||
if(this.box_group == BoxSet.MONSTER){
|
||||
this.ap_max=(100+smc.vmdata.mission.map)/100*this.ap
|
||||
this.crit_max=(100+smc.vmdata.mission.mcrit)/100*this.crit
|
||||
this.def_max=(100+smc.vmdata.mission.mdef)/100*this.def
|
||||
this.dodge_max=(100+smc.vmdata.mission.mdodge)/100*this.dodge
|
||||
this.rhp_max=(100+smc.vmdata.mission.mhp)/100*this.hp_max
|
||||
}
|
||||
}
|
||||
check_enemy_alive(){
|
||||
let dir = 320
|
||||
let enemys=smc.enemy_pos
|
||||
this.enemy = v3(720,this.node.position.y)
|
||||
if(this.box_group == BoxSet.MONSTER){
|
||||
for (let i = 0; i < smc.hero_pos.length; i++) {
|
||||
let ho:any = smc.hero_pos[i];
|
||||
let x=Math.abs(ho.x-this.node.position.x)
|
||||
if(x < dir){
|
||||
dir = x
|
||||
this.enemy = ho
|
||||
}
|
||||
}
|
||||
enemys=smc.hero_pos
|
||||
this.enemy=v3(-720,this.node.position.y)
|
||||
}
|
||||
if(this.box_group == BoxSet.HERO){
|
||||
for (let i = 0; i < smc.enemy_pos.length; i++) {
|
||||
let mon:any = smc.enemy_pos[i];
|
||||
let x=Math.abs(mon.x-this.node.position.x)
|
||||
if(x < dir){
|
||||
dir = x
|
||||
this.enemy = mon
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < enemys.length; i++) {
|
||||
let ho:any = enemys[i];
|
||||
let x=Math.abs(ho.x-this.node.position.x)
|
||||
if(x < dir){
|
||||
dir = x
|
||||
this.enemy = ho
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(dir < this.dis){
|
||||
this.is_atking=true
|
||||
if(this.dis-dir > 45 ) this.stop_cd = 0.1
|
||||
if(this.dis-dir > 80 &&this.type > 0 ) this.stop_cd = 0.1
|
||||
}else{
|
||||
this.is_atking=false
|
||||
}
|
||||
@@ -312,7 +310,9 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
hp_show(){
|
||||
if(this.hp == this.hp_max){
|
||||
let hp_progress= this.hp/this.rhp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
if(this.hp == this.rhp_max){
|
||||
this.node.getChildByName("top").getChildByName("hp").active = false;
|
||||
} else{
|
||||
this.node.getChildByName("top").getChildByName("hp").active = true;
|
||||
@@ -563,8 +563,8 @@ export class HeroViewComp extends CCComp {
|
||||
if(!heros[i].HeroView) continue
|
||||
let hero = heros[i].HeroView;
|
||||
if(SkillSet[skill].type==91){ //血量最少单体
|
||||
if((hero.hp_max-hero.hp) > least_hp){
|
||||
least_hp = (hero.hp_max-hero.hp)
|
||||
if((hero.rhp_max-hero.hp) > least_hp){
|
||||
least_hp = (hero.rhp_max-hero.hp)
|
||||
t_hero = hero
|
||||
}
|
||||
}else{ //群体
|
||||
@@ -609,19 +609,14 @@ export class HeroViewComp extends CCComp {
|
||||
add_hp(hp: number=0){
|
||||
this.heathed();
|
||||
this.hp+=hp;
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
if(this.hp > this.rhp_max){
|
||||
this.hp = this.rhp_max;
|
||||
}
|
||||
this.tooltip(2,hp.toFixed(0));
|
||||
let hp_progress= this.hp/this.hp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
}
|
||||
add_hp_max(hp: number=0){
|
||||
this.hp_max_add()
|
||||
this.hp += hp;
|
||||
this.hp_max += hp;
|
||||
let hp_progress= this.hp/this.hp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
this.hp += hp/100*this.hp_max;
|
||||
}
|
||||
hp_change(hp: number,is_crit:boolean=false){
|
||||
if(this.is_dead){
|
||||
@@ -636,11 +631,10 @@ export class HeroViewComp extends CCComp {
|
||||
this.tooltip(1,hp.toFixed(0),250);
|
||||
}
|
||||
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
if(this.hp > this.rhp_max){
|
||||
this.hp = this.rhp_max;
|
||||
}
|
||||
let hp_progress= this.hp/this.hp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
|
||||
if(this.hp <= 0){
|
||||
this.dead();
|
||||
this.to_grave()
|
||||
|
||||
Reference in New Issue
Block a user