英雄和敌人 全死亡后,判定解决

This commit is contained in:
2025-08-12 20:20:05 +08:00
parent b77f023548
commit d464491172
18 changed files with 1731 additions and 2685 deletions

View File

@@ -67,6 +67,7 @@ export class Hero extends ecs.Entity {
if(HeroInfo[uuid].type==HType.mage){
move.targetX = -200; // 右边界'
}
smc.vmdata.mission_data.hero_num++
}
hero_init(uuid:number=1001,node:Node,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false}) {
var hv = node.getComponent(HeroViewComp)!;

View File

@@ -48,5 +48,8 @@ export default class HeroAnmComp extends Component{
this.anmcon.play("idle")
this.default_anim='idle'
}
buff(){
if(this.anmcon.getState("buff").isPlaying) return
this.anmcon.play("buff")
}
}

View File

@@ -66,7 +66,9 @@ export class HeroSpine extends Component {
break
}
}
do_buff(){
this.anm.buff()
}
move(){
// console.log("change to move",this.status);
if(this.status=="move") return

View File

@@ -122,6 +122,7 @@ export class HeroViewComp extends CCComp {
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
this.on(GameEvent.EXPUP,this.exp_up,this)
this.on(GameEvent.HeroLvUp,this.to_update_lv,this)
this.on(GameEvent.FightEnd,this.do_fight_end,this)
const collider = this.node.getComponent(BoxCollider2D);
this.scheduleOnce(()=>{
if (collider) collider.enabled = true; // 先禁用
@@ -142,7 +143,6 @@ export class HeroViewComp extends CCComp {
}
/* 显示角色血量 */
this.node.getChildByName("top").getChildByName("hp").active = true;
}
update(dt: number){
@@ -151,7 +151,6 @@ export class HeroViewComp extends CCComp {
// this.ent.destroy();
// return
// }
if(this.DEBUFF_FROST > 0){
this.DEBUFF_FROST -=dt;
@@ -175,8 +174,10 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar).progress = hp_progress;
// this.node.getChildByName("top").getChildByName("hp").active = (hp == hp_max) ? false : true;
}
do_fight_end(){
this.as.do_buff()
}
get isActive() {
return this.ent.has(HeroViewComp) && this.node?.isValid;
}
@@ -255,14 +256,15 @@ export class HeroViewComp extends CCComp {
do_dead(){
this.do_dead_trigger()
//console.log("[HeroViewComp]:角色死亡",this.hero_uuid)
if(this.is_count_dead) return
this.is_count_dead=true
if(this.fac==FacSet.MON){
if(this.is_count_dead) return
this.is_count_dead=true
this.scheduleOnce(()=>{
oops.message.dispatchEvent(GameEvent.MonDead)
},0.1)
},0.1)
}
if(this.fac==FacSet.HERO){
oops.message.dispatchEvent(GameEvent.HeroDead)
}
if(this.fac==FacSet.HERO){
@@ -479,7 +481,6 @@ export class HeroViewComp extends CCComp {
}
check_dodge(){
if(this.fac==FacSet.HERO) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.DODGE_TO_POWER //闪避涨能量
if(this.dod > 0){
let random = Math.random()*100
if(random < this.dod) {
@@ -567,15 +568,7 @@ export class HeroViewComp extends CCComp {
}
exp_up(e:any,data:any){
if(this.fac==FacSet.MON) return
// console.log("[HeroViewComp]:经验提高",data.exp)
smc.vmdata.hero.exp+=data.exp
// smc.vmdata.hero.next_exp=getUpExp(this.lv)
if(smc.vmdata.hero.exp >= smc.vmdata.hero.next_exp){
// console.log("[HeroViewComp]:升级")
this.to_update_lv("seft",data)
oops.message.dispatchEvent(GameEvent.CanUpdateLv)
}
}

View File

@@ -52,6 +52,8 @@ export class Monster extends ecs.Entity {
const move = this.get(BattleMoveComp);
move.direction = -1; // 向左移动
move.targetX = -800; // 左边界
smc.vmdata.mission_data.mon_num++
console.log("[Mon] mission_data.mon_num:",smc.vmdata.mission_data.mon_num)
}
brith_light(pos:Vec3,scene:any){
var path = "game/skills/map_birth";