奖励 加血 有问题

This commit is contained in:
2024-09-23 16:56:56 +08:00
parent 21c1dcfae3
commit f72cdb94aa
4 changed files with 57 additions and 20 deletions

View File

@@ -393,18 +393,44 @@ export class CardControllerComp extends CCComp {
this.node.getChildByName('rewards').active = true;
}
colse_reward(){
colse_reward(value:number){
this.node.getChildByName('rewards').active = false;
smc.vm_data.game_pause = false;
let reward=this.rewards[value]
console.log("reward:",this.rewards,value)
if(reward.type==1){
if(reward.atk > 0){
smc.vm_data.mission.hero.atk += reward.atk*100;
}
if(reward.atk_cd > 0){
smc.vm_data.mission.hero.atk_cd -= reward.atk_cd/100;
}
if(reward.hp > 0){
smc.vm_data.mission.hero.hp += reward.hp;
this.add_hero_hp_max(reward.hp)
}
}
}
do_reward_1(value:number=1){
this.colse_reward()
do_reward_1(){
this.colse_reward(1)
}
do_reward_2(value:number=2){
this.colse_reward()
do_reward_2(){
this.colse_reward(2)
}
do_reward_3(value:number=3){
this.colse_reward()
do_reward_3(){
this.colse_reward(3)
}
add_hero_hp_max(hp:number){
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
console.log("heros:",heros)
if (heros.length > 0) {
for (let i = 0; i < heros.length; i++) {
let hero = heros[i];
if(!hero.HeroView) continue
let add_hp=smc.heros[hero.HeroView.hero_uuid].hp*hp/100
hero.HeroView.add_hp_max(add_hp)
}
}
}
protected update(dt: number): void {
if(smc.vm_data.game_over||smc.vm_data.game_pause){