技能cd 完善

This commit is contained in:
2025-08-11 23:13:16 +08:00
parent 919ff09351
commit 13d0a6d190
8 changed files with 22 additions and 894 deletions

View File

@@ -37,8 +37,7 @@ export class SkillConComp extends CCComp {
onLoad(){
this.HeroView=this.node.getComponent(HeroViewComp)
// //console.log(this.HeroView.uid+"=>"+this.HeroView.hero_name+"=> SkillConComp onLoad")
this.on(GameEvent.CastHeroSkill,this.cast_master_skill,this)
this.on(GameEvent.MaxSkill,this.use_max_skill,this)
}
start() {
@@ -51,11 +50,11 @@ export class SkillConComp extends CCComp {
if(this.HeroView.DEBUFF_STUN <= 0&&this.HeroView.DEBUFF_FROST <= 0) {
for(let i=0;i<this.HeroView.skills.length;i++){
this.HeroView.skills[i].cd += dt;
if(this.HeroView.skills[i].cd > this.HeroView.skills[i].cd_max){
if(this.HeroView.skills[i].cd > (i==0?this.count_cd(this.HeroView.skills[i].cd_max,this.HeroView):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.castSkill(sc)
this.HeroView.skills[i].cd = 0
}
}
@@ -91,35 +90,29 @@ export class SkillConComp extends CCComp {
}
}
cast_master_skill(e:string,uuid:any){
if(!this.HeroView) return
if(this.HeroView.fac==FacSet.MON) return
//console.log("hart cast_skill",uuid ,e)
const config = SkillSet[uuid];
this.castSkill(config,false,this.HeroView.skill_dmg)
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)
}
/** 施放技能 */
castSkill(config: typeof SkillSet[keyof typeof SkillSet],is_wfuny:boolean=false,dmg:number=0) {
castSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
// //console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid);
this.doSkill(config,is_wfuny,dmg);
let wfuny=this.check_wfuny()
let dmg=0
this.doSkill(config,wfuny,dmg);
}
use_max_skill(e:GameEvent,data:any){
if(!this.HeroView) return
if(this.HeroView.fac==FacSet.MON) return
//console.log("[SkillConComp]:use_max_skill:",data)
this.skill_id_counter++;
this.aoe_queues.push({
id: this.skill_id_counter,
s_uuid:data.uuid,
count:SkillSet[data.uuid].maxC,
damage:0})
// 初始化该技能的计时器
this.aoe_timers.set(this.skill_id_counter, 0);
}
private doSkill(config: typeof SkillSet[keyof typeof SkillSet],is_wfuny:boolean=false,dmg:number=0) {
// 添加节点有效性检查