解决 技能系统计数器造成的问题,todo:去掉局内成长设定

This commit is contained in:
2025-02-03 23:50:27 +08:00
parent 2521af3a55
commit 4dcb732148
4 changed files with 43 additions and 268 deletions

View File

@@ -14,7 +14,6 @@ import { BuffComp } from "./BuffComp";
import { MonModelComp } from "./MonModelComp";
import { getMonsterDrops, MonsterType } from "../common/config/RewardSet";
import { HeroSkillsComp } from "../skill/heroSkillsComp";
import { DamageResult } from "../damage/DamageComp";
const { ccclass, property } = _decorator;
@@ -136,7 +135,6 @@ export class HeroViewComp extends CCComp {
if (this.pwt.update(dt)) {
this.pw+=this.pws
}
this.check_atk_counts()
this.hp_show()
if(this.ice_cd > 0){
this.ice_cd -=dt;
@@ -166,7 +164,6 @@ export class HeroViewComp extends CCComp {
}
//移动
//状态切换
status_change(type:string){
this.status=type
@@ -180,209 +177,6 @@ export class HeroViewComp extends CCComp {
}
}
//受伤判断
check_uatk(damage:number,is_crit:boolean){
if(this.check_dodge()) return
this.in_atked();
let l_hp=damage
// this.check_debuff(skill,l_hp)
if(this.shield > 0){
this.shield -= damage
if(this.shield <= 0) {
l_hp = -this.shield
this.shield = 0
this.BUFFCOMP.show_shield(false)
}
}
this.hp_less(l_hp,is_crit);
}
hp_less(hp: number,is_crit:boolean=false,delay:number=0){
if(this.is_dead) return
hp=Math.floor(hp)
this.hp -= hp
if(is_crit){
this.BUFFCOMP.tooltip(4,hp.toFixed(0),250);
}else{
this.BUFFCOMP.tooltip(1,hp.toFixed(0),250);
}
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
if(this.hp <= 0){
this.dead();
this.to_grave()
this.is_dead = true;
}
}
/**
* 检查并处理英雄受到的减益效果debuff
* 根据技能的不同减益类型,执行相应的逻辑,如冰冻、燃烧等。
*
* @param skill - 包含减益效果信息的技能对象
* @param l_hp - 可选参数表示英雄的当前生命值默认为0
*/
check_debuff(skill:any,l_hp:number=0){
// // console.log(this.hero_name+this.uuid+": skillname: "+skill.s_name+" :check_debuff "+skill.debuff);
// if(skill.debuff == 0) return
// let num=RandomManager.instance.getRandomInt(0,100)
// switch (skill.debuff){
// case 1:
// // console.log(this.hero_name+":"+this.uuid+"冰冻触判断: i="+num+":rate="+skill.rate);
// if(num > skill.depb) return
// // console.log(this.hero_name+":"+this.uuid+"冰冻触成功: i="+num+":debtime="+skill.debtime);
// this.ice_cd = skill.debtime
// this.BUFFCOMP.in_iced(skill.debtime)
// break;
// case 2:
// if(num > skill.depb) return
// // console.log(this.hero_name+":"+this.uuid+"debuff触发成功 i="+num+":debtime="+skill.debtime+":l_hp="+l_hp);
// this.BUFFCOMP.in_fired(skill.debtime,l_hp*skill.derate/100)
// break;
// case 3:
// if(num > skill.depb) return
// this.yun_cd = skill.debtime
// this.BUFFCOMP.in_yun(skill.debtime)
// break;
// case 4:
// if(num > skill.depb) return
// this.BUFFCOMP.buff_get("deap")
// this.ap = this.ap-Math.floor(l_hp*skill.derate/100)
// break;
// case 5:
// if(num > skill.depb) return
// break;
// case 6:
// if(num > skill.depb) return
// break;
// case 7:
// if(num > skill.depb) return
// break;
// case 8:
// if(num > skill.depb) return
// if(this.node.position.x > 300||this.node.position.x < -300) return
// tween(this.node).to( 0.1,
// { position: new Vec3(this.node.position.x-this.scale*50,this.node.position.y) },
// { }
// ).start();
// break;
// }
}
//暴击判断
/**
* 检查是否触发暴击,并执行相应的暴击效果。
* @returns {boolean} 如果触发暴击则返回 true否则返回 false。
* 该方法首先通过 RandomManager 获取一个随机数如果该随机数小于当前暴击最大值crit
* 则触发暴击效果,包括显示暴击提示、增加暴击计数、增加暴击经验以及增加暴击威力。
* 如果未触发暴击,则直接返回 false。
*/
check_crit():boolean
{
let i = RandomManager.instance.getRandomInt(0,100,3)
if(i < this.crit){
// this.BUFFCOMP.tooltip(5,"*会心一击*");
this.crit_count += 1
this.exp_add(this.cexp) // 暴击经验
this.power_add(this.cpw)
return true
}else{
return false
}
}
//闪避判断
/**
* 检查并处理角色的闪避逻辑。
* 生成一个随机数,如果小于角色的最大闪避值,则触发闪避效果,增加经验、能量,并更新闪避计数。
* @returns {boolean} 如果触发闪避则返回true否则返回false。
*/
check_dodge():boolean
{
let i = RandomManager.instance.getRandomInt(0,100,3)
if(this.dodge > GameSet.DODGE_MAX) this.dodge = GameSet.DODGE_MAX
if(i < this.dodge){
// console.log("闪避触发: i="+i+":dodge="+dodge);
this.BUFFCOMP.tooltip(5,"闪避");
this.exp_add(this.doexp) // 闪避经验
this.power_add(this.dopw)
this.dodge_count += 1
return true
}else{
return false
}
}
/**
* 检查并处理角色的攻击、闪避、暴击和受伤计数。
* 当计数达到一定值时,会触发相应的技能效果,并重置计数。
* 触发效果包括激活名为"max"的节点并在0.8秒后关闭。
* 使用do_skill方法处理触发的技能。
*/
check_atk_counts() {
// if (this.atk_count >= this.akc) {
// this.atk_count = 0
// // console.log("atk_count 清零:"+this.atk_count);
// let i = RandomManager.instance.getRandomInt(0,100,3)
// // console.log("攻击判断: i="+i+":akr="+this.akr);
// if(i < this.akr){
// // console.log("攻击触发: i="+i+":akr="+this.akr);
// // this.BUFFCOMP.max_show()
// this.do_skill(this.sk3)
// }
// }
// if(this.dodge_count >= this.dgc){
// this.dodge_count = 0
// // console.log("dodge_count 清零:"+this.dodge_count);
// let i = RandomManager.instance.getRandomInt(0,100,3)
// // console.log("闪避判断: i="+i+":dgr="+this.dgr);
// if(i < this.dgr){
// // console.log("闪避触发: i="+i+":dgr="+this.dgr);
// // this.BUFFCOMP.max_show()
// this.do_skill(this.sk3)
// }
// }
// if(this.crit_count >= this.crc){
// this.crit_count = 0
// // console.log("crit_count 清零:"+this.crit_count);
// let i = RandomManager.instance.getRandomInt(0,100,3)
// // console.log("暴击判断: i="+i+":crr="+this.crr);
// if(i < this.crr){
// // console.log("暴击触发: i="+i+":crr="+this.crr);
// // this.BUFFCOMP.max_show()
// this.do_skill(this.sk3)
// }
// }
// if(this.atked_count >= this.uac){
// this.atked_count = 0
// let i = RandomManager.instance.getRandomInt(0,100,3)
// // console.log("受伤判断i="+i+":akr="+this.uar);
// if(i < this.uar){
// // console.log("受伤触发: i="+i+":uar="+this.uar);
// // this.BUFFCOMP.max_show()
// this.do_skill(this.sk3)
// }
// }
}
//使用max_skill
do_skill(skill:number){
// this.at = 0; //共享普攻攻击cd
this.BUFFCOMP.tooltip(3,SkillSet[skill].name,skill);
if(SkillSet[skill].flash){
this.as.max()
this.scheduleOnce(()=>{
this.BUFFCOMP.show_do_buff(SkillSet[skill].fname)
},0.1)
}
}
shoot_enemy(sk:number,y:number=0,x:number=0){
// console.log("mon shoot_enemy");
}
exp_add(exp:number=0){
if(this.box_group==BoxSet.HERO){
@@ -482,13 +276,6 @@ export class HeroViewComp extends CCComp {
}
}
in_atked() {
this.BUFFCOMP.in_atked()
// this.as.atked();
this.atked_count++;
this.exp_add(this.uaexp)
this.power_add(this.uapw)
}
dead(){
this.BUFFCOMP.dead()
this.exp_add(this.dexp)
@@ -524,7 +311,8 @@ export class HeroViewComp extends CCComp {
}
//进入墓地
to_grave(){
let pos =v3(0,-1000,this.node.position.z)
let pos =v3(-1000,this.node.position.y,this.node.position.z)
if(this.fac==1) pos.x=1000
this.node.setPosition(pos)
}
//是否在墓地
@@ -565,15 +353,15 @@ export class HeroViewComp extends CCComp {
const skills = this.ent.get(HeroSkillsComp);
skills.resetAllCooldowns();
}
applyDamage(result:DamageResult){
}
/** 显示伤害数字 */
showDamage(damage: number, isCrit: boolean) {
if(!this.BUFFCOMP.isValid){
return;
}
this.BUFFCOMP.in_atked()
// this.as.atked();
this.atked_count++;
this.exp_add(this.uaexp)
this.power_add(this.uapw)
if(isCrit){
this.BUFFCOMP.tooltip(4,damage.toFixed(0),damage)
console.log("暴击伤害:"+damage)