This commit is contained in:
2024-12-27 08:14:39 +08:00
parent 8805666492
commit 79bda9f0db
3 changed files with 31 additions and 7 deletions

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18
*/
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,RigidBody2D ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp} from "cc";
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,RigidBody2D ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp, Game} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroSpine } from "./HeroSpine";
@@ -354,7 +354,7 @@ export class HeroViewComp extends CCComp {
this.in_atked();
let d=this.def/skill.ap
if(d > 1) d = 1
let l_hp=skill.ap*(1-d*0.5)
let l_hp=skill.ap*(1-d*GameSet.DEF_RATE) //防御最高减免伤害比率计算
if(skill.is_crit){
l_hp = l_hp * (150+skill.crit_add)/100
}
@@ -376,7 +376,15 @@ export class HeroViewComp extends CCComp {
}
}
//暴击判断
check_crit(){
/**
* 检查是否触发暴击,并执行相应的暴击效果。
* @returns {boolean} 如果触发暴击则返回 true否则返回 false。
* 该方法首先通过 RandomManager 获取一个随机数如果该随机数小于当前暴击最大值crit_max
* 则触发暴击效果,包括显示暴击提示、增加暴击计数、增加暴击经验以及增加暴击威力。
* 如果未触发暴击,则直接返回 false。
*/
check_crit():boolean
{
let i = RandomManager.instance.getRandomInt(0,100,3)
if(i < this.crit_max){
this.tooltip(5,"*会心一击*");
@@ -389,7 +397,13 @@ export class HeroViewComp extends CCComp {
}
}
//闪避判断
check_dodge(){
/**
* 检查并处理角色的闪避逻辑。
* 生成一个随机数,如果小于角色的最大闪避值,则触发闪避效果,增加经验、能量,并更新闪避计数。
* @returns {boolean} 如果触发闪避则返回true否则返回false。
*/
check_dodge():boolean
{
let i = RandomManager.instance.getRandomInt(0,100,3)
if(i < this.dodge_max){
// console.log("闪避触发: i="+i+":dodge="+dodge);
@@ -402,8 +416,14 @@ export class HeroViewComp extends CCComp {
return false
}
}
check_atk_counts(){
if(this.atk_count >= this.akc){
/**
* 检查并处理角色的攻击、闪避、暴击和受伤计数。
* 当计数达到一定值时,会触发相应的技能效果,并重置计数。
* 触发效果包括激活名为"max"的节点并在0.8秒后关闭。
* 使用handle_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)
@@ -634,7 +654,7 @@ export class HeroViewComp extends CCComp {
if(this.hp > this.rhp_max){
this.hp = this.rhp_max;
}
if(this.hp <= 0){
this.dead();
this.to_grave()