防御还是百分比减免
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "caba3955-8e72-4e90-8666-0d0ee57797d9",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -109,7 +109,7 @@ export enum BuffAttr {
|
|||||||
WFUNY = 2, // 风怒
|
WFUNY = 2, // 风怒
|
||||||
ATK_CD = 3, // 攻击速度
|
ATK_CD = 3, // 攻击速度
|
||||||
HP = 4, // 生命值比例
|
HP = 4, // 生命值比例
|
||||||
DEF = 5, // 免伤
|
DEF = 5, // 防御
|
||||||
SKILL_DMG = 6, // 技能效果
|
SKILL_DMG = 6, // 技能效果
|
||||||
SKILL_CD = 7, // 技能冷却缩减
|
SKILL_CD = 7, // 技能冷却缩减
|
||||||
CARD_EFFECT = 8, // 卡牌效果
|
CARD_EFFECT = 8, // 卡牌效果
|
||||||
@@ -136,6 +136,8 @@ export enum BuffAttr {
|
|||||||
HP_MAX = 28, //最大生命值数值
|
HP_MAX = 28, //最大生命值数值
|
||||||
POWER_UP = 29, //能量增加
|
POWER_UP = 29, //能量增加
|
||||||
LIFESTEAL = 30, //吸血
|
LIFESTEAL = 30, //吸血
|
||||||
|
DMG_RED = 31, //免伤
|
||||||
|
INVINCIBLE = 32, //无敌
|
||||||
}
|
}
|
||||||
|
|
||||||
export const geDebuffNum=()=>{
|
export const geDebuffNum=()=>{
|
||||||
@@ -189,6 +191,8 @@ export const getBuffNum=()=>{
|
|||||||
HP_MAX:0,//最大生命值数值
|
HP_MAX:0,//最大生命值数值
|
||||||
POWER_UP:0,//能量增加
|
POWER_UP:0,//能量增加
|
||||||
LIFESTEAL:0,//吸血
|
LIFESTEAL:0,//吸血
|
||||||
|
DMG_RED:0,//免伤
|
||||||
|
INVINCIBLE:0,//无敌
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,51 +24,15 @@ const { ccclass, property } = _decorator;
|
|||||||
@ecs.register('HeroView', false) // 定义为 ECS 组件
|
@ecs.register('HeroView', false) // 定义为 ECS 组件
|
||||||
export class HeroViewComp extends CCComp {
|
export class HeroViewComp extends CCComp {
|
||||||
BUFFCOMP:BuffComp=null!
|
BUFFCOMP:BuffComp=null!
|
||||||
atk_heart:boolean=false;
|
|
||||||
as: HeroSpine = null!
|
as: HeroSpine = null!
|
||||||
status:String = "idle"
|
status:String = "idle"
|
||||||
hero_uuid:number = 1001;
|
hero_uuid:number = 1001;
|
||||||
hero_name : string = "hero";
|
hero_name : string = "hero";
|
||||||
fight_pos:number=0;
|
|
||||||
lv:number =1;
|
lv:number =1;
|
||||||
exp:number = 0;
|
|
||||||
next_exp:number = 100;
|
|
||||||
scale: number = 1; /** 角色阵营 1:hero -1 :mon */
|
scale: number = 1; /** 角色阵营 1:hero -1 :mon */
|
||||||
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
|
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
|
||||||
fac:number=0; //阵营 0:hero 1:monster
|
fac:number=0; //阵营 0:hero 1:monster
|
||||||
skill_cd:number=0;
|
|
||||||
skill_cd_max:number=1.3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前血量 - 根据阵营选择正确的变量
|
|
||||||
*/
|
|
||||||
get currentHp(): number {
|
|
||||||
return this.hp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置当前血量 - 根据阵营选择正确的变量
|
|
||||||
*/
|
|
||||||
set currentHp(value: number) {
|
|
||||||
this.hp = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取最大血量 - 根据阵营选择正确的变量
|
|
||||||
*/
|
|
||||||
get currentHpMax(): number {
|
|
||||||
return this.hp_max;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置最大血量 - 根据阵营选择正确的变量
|
|
||||||
*/
|
|
||||||
set currentHpMax(value: number) {
|
|
||||||
this.hp_max = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
box_group:number = BoxSet.HERO;
|
box_group:number = BoxSet.HERO;
|
||||||
|
|
||||||
is_dead:boolean = false; //是否摧毁
|
is_dead:boolean = false; //是否摧毁
|
||||||
is_count_dead:boolean = false; //是否计数死亡
|
is_count_dead:boolean = false; //是否计数死亡
|
||||||
is_stop:boolean = false;
|
is_stop:boolean = false;
|
||||||
@@ -85,7 +49,6 @@ export class HeroViewComp extends CCComp {
|
|||||||
hp_buff:number=0;
|
hp_buff:number=0;
|
||||||
hp_base:number=0;
|
hp_base:number=0;
|
||||||
|
|
||||||
pwt:Timer = new Timer(1); //计时器
|
|
||||||
ap: number = 10; /**攻击力 */
|
ap: number = 10; /**攻击力 */
|
||||||
ap_buff:number=0;
|
ap_buff:number=0;
|
||||||
ap_base:number=0;
|
ap_base:number=0;
|
||||||
@@ -97,10 +60,9 @@ export class HeroViewComp extends CCComp {
|
|||||||
skills:any[]=[]
|
skills:any[]=[]
|
||||||
puncture:number=0; //穿刺敌人伤害后方敌人个数
|
puncture:number=0; //穿刺敌人伤害后方敌人个数
|
||||||
puncture_damage:number=0; //后伤害加成
|
puncture_damage:number=0; //后伤害加成
|
||||||
def: number = 0; //免伤
|
def: number = 0; //防御
|
||||||
vun: number = 0; //易伤
|
dmg_red:number=0//免伤
|
||||||
burn_count:number=0; //易伤次数
|
burn: number = 0; //易伤 伤害加成
|
||||||
burn_value:number=0; //易伤值
|
|
||||||
stun_time:number=0; //眩晕加成
|
stun_time:number=0; //眩晕加成
|
||||||
stun_ratto:number=0; //攻击眩晕概率加成
|
stun_ratto:number=0; //攻击眩晕概率加成
|
||||||
stun_no:boolean=false; //眩晕免疫
|
stun_no:boolean=false; //眩晕免疫
|
||||||
@@ -120,18 +82,14 @@ export class HeroViewComp extends CCComp {
|
|||||||
ospeed: number = 100; /** 角色初始速度 */
|
ospeed: number = 100; /** 角色初始速度 */
|
||||||
reflect:number=0; //反射伤害比率
|
reflect:number=0; //反射伤害比率
|
||||||
lifesteal:number=0; //吸血比率
|
lifesteal:number=0; //吸血比率
|
||||||
|
skill_dmg:number=0
|
||||||
|
|
||||||
atk_count: number = 0;
|
atk_count: number = 0;
|
||||||
atked_count: number = 0;
|
atked_count: number = 0;
|
||||||
atk_add_count:number=0;
|
|
||||||
stop_cd: number = 0; /*停止倒计时*/
|
stop_cd: number = 0; /*停止倒计时*/
|
||||||
speek_time:number = 0;
|
speek_time:number = 0;
|
||||||
is_stop_temp:boolean = false
|
debuff_down_ratto:number=0
|
||||||
double_atked:boolean=false
|
|
||||||
atk_add_master_atk:number=0
|
|
||||||
atk_add_master_hp:number=0
|
|
||||||
buff_debuff_down:number=0
|
|
||||||
skill_dmg:number=0
|
|
||||||
|
|
||||||
BUFF_DEFS: Array<{value: number, duration: number}> = [] //防御提升
|
BUFF_DEFS: Array<{value: number, duration: number}> = [] //防御提升
|
||||||
BUFF_ATKS: Array<{value: number, duration: number}> = [] //攻击提升
|
BUFF_ATKS: Array<{value: number, duration: number}> = [] //攻击提升
|
||||||
@@ -216,8 +174,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
hp_show(){
|
hp_show(){
|
||||||
// if(this.node.getComponent(HeroViewComp).fac == 0) return
|
// if(this.node.getComponent(HeroViewComp).fac == 0) return
|
||||||
let hp=this.currentHp;
|
let hp=this.hp;
|
||||||
let hp_max=this.currentHpMax;
|
let hp_max=this.hp_max;
|
||||||
let hp_progress= hp/hp_max;
|
let hp_progress= hp/hp_max;
|
||||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar).progress = hp_progress;
|
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar).progress = hp_progress;
|
||||||
// this.node.getChildByName("top").getChildByName("hp").active = (hp == hp_max) ? false : true;
|
// this.node.getChildByName("top").getChildByName("hp").active = (hp == hp_max) ? false : true;
|
||||||
@@ -340,9 +298,9 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.cd=this.check_atrr(BuffAttr.ATK_CD)
|
this.cd=this.check_atrr(BuffAttr.ATK_CD)
|
||||||
break
|
break
|
||||||
case BuffAttr.HP:
|
case BuffAttr.HP:
|
||||||
let diff=this.check_atrr(BuffAttr.HP)-this.currentHpMax
|
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
|
||||||
this.currentHpMax=this.check_atrr(BuffAttr.HP)
|
this.hp_max=this.check_atrr(BuffAttr.HP)
|
||||||
this.currentHp+=diff
|
this.hp+=diff
|
||||||
this.hp_show()
|
this.hp_show()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -380,8 +338,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
add_hp(hp: number = 0,is_num:boolean=true) {
|
add_hp(hp: number = 0,is_num:boolean=true) {
|
||||||
this.BUFFCOMP.heathed();
|
this.BUFFCOMP.heathed();
|
||||||
let real_hp=0
|
let real_hp=0
|
||||||
let hp_max=Math.floor(this.currentHpMax*(100+this.hp_buff)/100)
|
let hp_max=Math.floor(this.hp_max*(100+this.hp_buff)/100)
|
||||||
let lost_hp=hp_max-this.currentHp
|
let lost_hp=hp_max-this.hp
|
||||||
if(is_num){
|
if(is_num){
|
||||||
if(lost_hp > hp){
|
if(lost_hp > hp){
|
||||||
real_hp=Math.floor(hp);
|
real_hp=Math.floor(hp);
|
||||||
@@ -396,7 +354,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(real_hp > 0){
|
if(real_hp > 0){
|
||||||
this.currentHp+=real_hp;
|
this.hp+=real_hp;
|
||||||
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
|
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
|
||||||
}
|
}
|
||||||
this.hp_show()
|
this.hp_show()
|
||||||
@@ -454,7 +412,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
DEBUFF_DOWN+=this.BUFF_DEDOWN[i].value
|
DEBUFF_DOWN+=this.BUFF_DEDOWN[i].value
|
||||||
// 不再在这里减少duration,改为在update中按时间减少
|
// 不再在这里减少duration,改为在update中按时间减少
|
||||||
}
|
}
|
||||||
let n_deR=deR-DEBUFF_DOWN-this.buff_debuff_down // 触发概率
|
let n_deR=deR-DEBUFF_DOWN-this.debuff_down_ratto // 触发概率
|
||||||
let r=RandomManager.instance.getRandomInt(0,100) // 随机数
|
let r=RandomManager.instance.getRandomInt(0,100) // 随机数
|
||||||
//console.log("[HeroViewComp]:类型,值,次数,技能概率,实际概率,随机数",type,deV,deC,deR,n_deR,r)
|
//console.log("[HeroViewComp]:类型,值,次数,技能概率,实际概率,随机数",type,deV,deC,deR,n_deR,r)
|
||||||
if(r < n_deR) {
|
if(r < n_deR) {
|
||||||
@@ -484,8 +442,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
// this.is_stop=true
|
// this.is_stop=true
|
||||||
break
|
break
|
||||||
case DebuffAttr.DEHP:
|
case DebuffAttr.DEHP:
|
||||||
this.currentHpMax-=deV/100*this.currentHpMax
|
this.hp_max-=deV/100*this.hp_max
|
||||||
if(this.currentHp-this.currentHpMax>0) this.currentHp=this.currentHpMax
|
if(this.hp-this.hp_max>0) this.hp=this.hp_max
|
||||||
break
|
break
|
||||||
case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
|
case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
|
||||||
if(deC == 99){
|
if(deC == 99){
|
||||||
@@ -607,13 +565,10 @@ export class HeroViewComp extends CCComp {
|
|||||||
let damage = this.count_damage(remainingDamage)
|
let damage = this.count_damage(remainingDamage)
|
||||||
if(is_crit) {
|
if(is_crit) {
|
||||||
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE+crit_d)/100))
|
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE+crit_d)/100))
|
||||||
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.CRIT_TO_POWER //暴击涨能量 怪物被暴击,因为只有一个英雄 直接处理
|
|
||||||
}
|
}
|
||||||
this.currentHp -= damage;
|
this.hp -= damage;
|
||||||
if(this.fac==FacSet.HERO) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.ATKED_TO_POWER //被攻击涨能量
|
|
||||||
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.ATK_TO_POWER //攻击命中涨能量 因为是只有1个英雄 直接处理
|
|
||||||
|
|
||||||
if(this.currentHp <= 0) {
|
if(this.hp <= 0) {
|
||||||
if(this == null) return;
|
if(this == null) return;
|
||||||
this.is_dead=true
|
this.is_dead=true
|
||||||
if(this.BUFFCOMP){
|
if(this.BUFFCOMP){
|
||||||
@@ -651,31 +606,12 @@ export class HeroViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
//伤害计算 debuff 易伤
|
//伤害计算 debuff 易伤
|
||||||
count_damage(remainingDamage:number){
|
count_damage(remainingDamage:number){
|
||||||
let damage = 0;
|
let min =remainingDamage*0.2
|
||||||
let Burn = 0;
|
let damage=(remainingDamage-this.dmg_red)*(100-this.def+this.burn)/100
|
||||||
let def = 0;
|
|
||||||
for(let i=0;i<this.DEBUFF_BURNS.length;i++){
|
|
||||||
Burn+=this.DEBUFF_BURNS[i].value
|
|
||||||
// 不再在这里减少duration,改为在update中按时间减少
|
|
||||||
}
|
|
||||||
for(let i=0;i<this.BUFF_DEFS.length;i++){
|
|
||||||
def+=this.BUFF_DEFS[i].value
|
|
||||||
// 不再在这里减少duration,改为在update中按时间减少
|
|
||||||
}
|
|
||||||
// buff 防御 即免伤
|
|
||||||
|
|
||||||
damage=remainingDamage*(100-def-this.def+Burn)/100
|
|
||||||
////console.log("[HeroViewComp]:最终伤害,敌人伤害值,免伤,防御,易伤",damage,remainingDamage,buff_def,def,Burn)
|
////console.log("[HeroViewComp]:最终伤害,敌人伤害值,免伤,防御,易伤",damage,remainingDamage,buff_def,def,Burn)
|
||||||
return Math.floor(damage)
|
return Math.floor(Math.max(damage,min))
|
||||||
}
|
|
||||||
count_debuff(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count_buff(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
check_shield(){
|
check_shield(){
|
||||||
if(this.shield>0){
|
if(this.shield>0){
|
||||||
this.shield -= 1
|
this.shield -= 1
|
||||||
@@ -702,7 +638,6 @@ export class HeroViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_crit(crit:number=0){
|
check_crit(crit:number=0){
|
||||||
|
|
||||||
if(this.crit_no) return false
|
if(this.crit_no) return false
|
||||||
if(crit > 0){
|
if(crit > 0){
|
||||||
let random = Math.random()*100
|
let random = Math.random()*100
|
||||||
@@ -719,20 +654,12 @@ export class HeroViewComp extends CCComp {
|
|||||||
// this.to_drop()
|
// this.to_drop()
|
||||||
|
|
||||||
// }
|
// }
|
||||||
do_dead_trigger(){ //双倍死亡设定
|
do_dead_trigger(){ //死亡特殊处理
|
||||||
if(this.is_dead||this.fac==FacSet.MON) return
|
if(this.is_dead||this.fac==FacSet.MON) return
|
||||||
let count = 1
|
|
||||||
for(let i=0;i<count;i++){
|
|
||||||
//console.log("[HeroViewComp]:dead"+i+"次")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
do_atked_trigger(){ //双倍攻击设定
|
do_atked_trigger(){ //受伤特殊处理
|
||||||
if(this.is_dead||this.fac==FacSet.MON) return
|
if(this.is_dead||this.fac==FacSet.MON) return
|
||||||
let count = 1
|
|
||||||
if(this.double_atked) {
|
|
||||||
//console.log("[HeroViewComp]:double_atked")
|
|
||||||
count =2
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "d8d095e8-6cd9-4fe1-a9cc-bffcf04e0346",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"dd03bf84-3e0b-43c3-b952-bbf57c82ac92","files":[],"subMetas":{},"userData":{}}
|
|
||||||
Reference in New Issue
Block a user