From 919ff09351f6dd528d483eeb4711b80abce2a2c1 Mon Sep 17 00:00:00 2001 From: panfudan Date: Mon, 11 Aug 2025 22:33:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=8E=BB=E9=99=A4=20smchp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/hero/Hero.ts | 36 +++++--------------- assets/script/game/hero/HeroViewComp.ts | 22 +++--------- assets/script/game/hero/Mon.ts | 10 ++++-- assets/script/game/hero/SkillConComp.ts | 45 +++++++------------------ assets/script/game/map/MissionComp.ts | 3 -- 5 files changed, 33 insertions(+), 83 deletions(-) diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 29edf8fa..8a02e6a0 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -20,7 +20,6 @@ export class Hero extends ecs.Entity { HeroModel!: HeroModelComp; HeroView!: HeroViewComp; BattleMove!: BattleMoveComp; - vmHero:any={} protected init() { this.addComponents( BattleMoveComp, @@ -40,34 +39,14 @@ export class Hero extends ecs.Entity { super.destroy(); } - /** - * 获取所有英雄槽位 - * @returns 英雄槽位数组 - */ - private getHeroSlots(): any[] { - return [smc.vmdata.hero1, smc.vmdata.hero2, smc.vmdata.hero3] - } - /** - * 查找可用的英雄槽位 - * @returns 可用的英雄槽位对象,如果没有可用槽位则返回null - */ - private findAvailableHeroSlot(): any { - return this.getHeroSlots().find(slot => slot.uuid === 0) || null - } /** 加载角色 */ load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false},fight_pos:number=1) { // console.log("英雄加载:",uuid,pos,scale,info) scale = 1 // 查找空闲英雄槽位 - this.vmHero = this.findAvailableHeroSlot() - if (!this.vmHero) { - console.log("[Hero] 英雄已满") - return - } - this.vmHero.uuid=uuid - this.vmHero.count=1 + var path = "game/heros/"+HeroInfo[uuid].path; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); @@ -92,8 +71,6 @@ export class Hero extends ecs.Entity { 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)!; let hero= HeroInfo[uuid] // 共用英雄数据 - hv.vmHero=this.vmHero - this.vmHero.name=hero.name hv.scale = 1; hv.is_master=true; hv.lv=1 @@ -106,7 +83,7 @@ export class Hero extends ecs.Entity { hv.speed =hv.ospeed = hero.speed; hv.dis = hero.dis; hv.cd = hv.cd_base = hero.cd - this.vmHero.hp=this.vmHero.hp_max= hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp + hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp hv.ap = hv.ap_base=hero.ap+info.ap; hero.buff.forEach((buff:any)=>{ switch(buff.buff_type){ @@ -161,8 +138,13 @@ export class Hero extends ecs.Entity { } }) hv.atk_skill=hero.skills[0] - hv.skills=hero.skills - this.vmHero.cd_max=SkillSet[hv.skills[1]].cd + for(let i=0;i{ this.applyBuffToMonster(hv, buff); diff --git a/assets/script/game/hero/SkillConComp.ts b/assets/script/game/hero/SkillConComp.ts index a9705087..12e925b7 100644 --- a/assets/script/game/hero/SkillConComp.ts +++ b/assets/script/game/hero/SkillConComp.ts @@ -19,6 +19,7 @@ const { ccclass, property } = _decorator; export class SkillConComp extends CCComp { HeroView:any=null; HeroEntity:any=null; + skill_cd=0 private _timers: { [key: string]: number } = {}; private _damageQueue: Array<{ timer: number; callback: () => void }> = []; @@ -48,26 +49,18 @@ export class SkillConComp extends CCComp { update(dt: number) { if(!smc.mission.play||smc.mission.pause) return if(this.HeroView.DEBUFF_STUN <= 0&&this.HeroView.DEBUFF_FROST <= 0) { - this.HeroView.at += dt; - this.HeroView.vmHero.cd += dt - } - if(this.HeroView.vmHero.cd > this.HeroView.vmHero.cd_max){ - - let sc=SkillSet[this.HeroView.skills[1]] - if(!sc) return - if(sc.SType==SType.damage&&!this.HeroView.is_atking) return - this.castSkill(sc,false,0) - this.HeroView.vmHero.cd = 0 - } - let cd = this.count_cd(this.HeroView.cd,this.HeroView) - if (this.HeroView.is_atking &&(this.HeroView.at > cd)) { - if(this.HeroView.is_dead) return - const config = SkillSet[this.HeroView.atk_skill]; - if (!config) return; - this.castSkill(config,this.check_wfuny()); - this.HeroView.count_atk_count() - this.HeroView.at = 0; + for(let i=0;i this.HeroView.skills[i].cd_max){ + let sc=SkillSet[this.HeroView.skills[i].uuid] + if(!sc) return + if(sc.SType==SType.damage&&!this.HeroView.is_atking) return + this.castSkill(sc,false,0) + this.HeroView.skills[i].cd = 0 + } + } } + if (this.aoe_queues.length > 0) { //console.log("[FightConComp]:aoe_queues:",this.aoe_queues) @@ -294,21 +287,7 @@ export class SkillConComp extends CCComp { Object.values(this._timers).forEach(clearTimeout); } - count_cd(cd:number,view:HeroViewComp){ - // 汇总DEBUFF_DECD,不再按次数减少,改为按时间减少 - let decd = 0; - for (let i = view.DEBUFF_DECDS.length - 1; i >= 0; i--) { - decd += view.DEBUFF_DECDS[i].value; - // 不再在这里减少duration,改为在update中按时间减少 - } - let bcd=0 - for (let i = view.BUFF_CDS.length - 1; i >= 0; i--) { - bcd += view.BUFF_CDS[i].value; - // 不再在这里减少duration,改为在update中按时间减少 - } - return cd/((bcd+decd)/100+1) - } get_count(count:number,view:HeroViewComp){ let re=count+view.wfuny if(re<1) re=1 diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index 0e11dcce..0e26f928 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -131,9 +131,6 @@ export class MissionComp extends CCComp { } private cleanComponents() { - smc.vmdata.hero1=JSON.parse(JSON.stringify(HeroUI)) - smc.vmdata.hero2=JSON.parse(JSON.stringify(HeroUI)) - smc.vmdata.hero3=JSON.parse(JSON.stringify(HeroUI)) ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()}); }