战斗暴击 闪避 基本完成
This commit is contained in:
@@ -79,8 +79,8 @@ export class HeroViewComp extends CCComp {
|
||||
def: number = 0; //防御
|
||||
vun: number = 0; //易伤
|
||||
|
||||
crit: number = 1.5; //暴击伤害比率
|
||||
crit_rate: number = 0;//暴击伤害加成
|
||||
crit: number = 0; //暴击率
|
||||
crit_add: number = 0;//暴击伤害加成
|
||||
dodge: number = 10; //闪避率
|
||||
|
||||
shield:number = 0; //护盾,免伤1次减1
|
||||
@@ -153,17 +153,15 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
return
|
||||
}
|
||||
let dodge = RandomManager.instance.getRandomInt(0,100,3)
|
||||
if(dodge < this.dodge){
|
||||
//todo 闪避跳字
|
||||
console.log("闪避了",dodge,this.dodge);
|
||||
return
|
||||
if(this.check_dodge()) return
|
||||
let l_hp=(skill.ap-this.def)*-1
|
||||
if(skill.is_crit){
|
||||
l_hp = l_hp * (150+skill.crit_add)/100
|
||||
}
|
||||
let l_hp=(skill.atk-this.def)*-1
|
||||
if(l_hp >= 0){
|
||||
l_hp=-1 //最低1点伤害
|
||||
}
|
||||
this.hp_change(l_hp);
|
||||
this.hp_change(l_hp,skill.is_crit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,20 +330,41 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
return {pos,t_pos}
|
||||
}
|
||||
//暴击判断
|
||||
check_crit(){
|
||||
let i = RandomManager.instance.getRandomInt(0,100,3)
|
||||
if(i < this.crit){
|
||||
console.log("攻击会暴击",i,this.crit);
|
||||
return true
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
}
|
||||
//闪避判断
|
||||
check_dodge(){
|
||||
let i = RandomManager.instance.getRandomInt(0,100,3)
|
||||
if(i < this.dodge){
|
||||
this.tooltip(5,"闪避");
|
||||
console.log("闪避了",i,this.dodge);
|
||||
return true
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
}
|
||||
check_atk_counts(){
|
||||
if(this.atk_count >= 1){
|
||||
this.atk_count = 0
|
||||
console.log("atk_count 清零:"+this.atk_count);
|
||||
// let i = RandomManager.instance.getRandomInt(0,100,3)
|
||||
// console.log("大招判断: i="+i+":skr="+this.skr[this.lv]);
|
||||
// if(i < this.skr[this.lv]){
|
||||
// console.log("大招触发: i="+i+":skr="+this.skr[this.lv]);
|
||||
// this.node.getChildByName("max").active=true
|
||||
// this.scheduleOnce(()=>{
|
||||
// this.node.getChildByName("max").active=false
|
||||
// },0.8)
|
||||
// this.handle_skill(this.sk2)
|
||||
// }
|
||||
let i = RandomManager.instance.getRandomInt(0,100,3)
|
||||
console.log("大招判断: i="+i+":skr="+this.skr[this.lv]);
|
||||
if(i < this.skr[this.lv]){
|
||||
console.log("大招触发: i="+i+":skr="+this.skr[this.lv]);
|
||||
this.node.getChildByName("max").active=true
|
||||
this.scheduleOnce(()=>{
|
||||
this.node.getChildByName("max").active=false
|
||||
},0.8)
|
||||
this.handle_skill(this.sk2)
|
||||
}
|
||||
}
|
||||
if(this.atked_count >= 1){
|
||||
this.atked_count = 0
|
||||
@@ -400,31 +419,30 @@ export class HeroViewComp extends CCComp {
|
||||
shoot_enemy(sk1:number,y:number=0,x:number=0){
|
||||
// console.log("mon shoot_enemy");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let increase_atk=Math.floor(this.ap*smc.vm_data.mission.hero.atk)
|
||||
let atk = smc.skills[sk1].atk+this.ap_buff+increase_atk;
|
||||
let increase_ap=Math.floor(this.ap*smc.vm_data.mission.hero.ap)
|
||||
let ap = smc.skills[sk1].ap+this.ap_buff+increase_ap;
|
||||
let {pos,t_pos}=this.get_enemy_pos()
|
||||
|
||||
pos.y=pos.y + y
|
||||
pos.x=pos.x + x
|
||||
skill.load(pos,this.box_group,this.node,sk1,atk,t_pos);
|
||||
let is_crit=this.check_crit()
|
||||
skill.load(pos,this.box_group,this.node,sk1,ap,t_pos,is_crit,this.crit_add);
|
||||
console.log(this.scale+this.hero_name+"使用技能:"+sk1);
|
||||
// this.tooltip(3,smc.skills[sk1].name,this.sk1);
|
||||
}
|
||||
to_add_buff(hero:any,s_uuid:number){
|
||||
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let atk = smc.skills[s_uuid].atk+this.ap;
|
||||
let ap = smc.skills[s_uuid].ap+this.ap;
|
||||
let {pos,t_pos}=this.get_hero_pos(hero)
|
||||
console.log("to_add_buff:"+hero.hero_name+" "+s_uuid);
|
||||
skill.load(pos,this.box_group,this.node,this.sk2,atk,t_pos);
|
||||
|
||||
let is_crit=this.check_crit()
|
||||
skill.load(pos,this.box_group,this.node,this.sk2,ap,t_pos,is_crit,this.crit_add);
|
||||
if(smc.skills[s_uuid].hp > 0){ //buff加血
|
||||
let increase_hp=Math.floor(smc.skills[s_uuid].hp*this.ap)
|
||||
hero.add_hp(increase_hp)
|
||||
}
|
||||
if(smc.skills[s_uuid].atk > 0){ //buff加攻击
|
||||
let increase_atk=Math.floor(smc.skills[s_uuid].atk*this.ap)
|
||||
hero.add_atk(increase_atk,smc.skills[s_uuid].bsd)
|
||||
if(smc.skills[s_uuid].ap > 0){ //buff加攻击
|
||||
let increase_atk=Math.floor(smc.skills[s_uuid].ap*this.ap)
|
||||
hero.add_ap(increase_atk,smc.skills[s_uuid].bsd)
|
||||
}
|
||||
|
||||
if(smc.skills[s_uuid].shield > 0){ //buff护盾
|
||||
@@ -513,13 +531,19 @@ export class HeroViewComp extends CCComp {
|
||||
let hp_progress= this.hp/this.hp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
}
|
||||
hp_change(hp: number){
|
||||
hp_change(hp: number,is_crit:boolean=false){
|
||||
if(this.is_dead){
|
||||
return;
|
||||
}
|
||||
|
||||
this.hp += hp;
|
||||
this.tooltip(1,hp.toString(),250);
|
||||
|
||||
if(is_crit){
|
||||
this.tooltip(4,hp.toString(),250);
|
||||
}else{
|
||||
this.tooltip(1,hp.toString(),250);
|
||||
}
|
||||
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
}
|
||||
@@ -533,25 +557,15 @@ export class HeroViewComp extends CCComp {
|
||||
// }, 15);
|
||||
}
|
||||
}
|
||||
add_atk(atk: number,time:number=0){
|
||||
if(time > 0){
|
||||
this.ap_buff=0
|
||||
let buff={atk:atk,time:time}
|
||||
this.ap_buffs.push(buff);
|
||||
this.ap_buffs.forEach((element: { atk: number; }) => {
|
||||
this.ap_buff += element.atk
|
||||
});
|
||||
}else{
|
||||
this.ap += atk;
|
||||
}
|
||||
// console.log(this.ap_buffs)
|
||||
add_ap(ap: number,time:number=0){
|
||||
this.ap += ap;
|
||||
}
|
||||
check_atk_buffs(dt: number){
|
||||
for(let i=0;i<this.ap_buffs.length;i++){
|
||||
let buff=this.ap_buffs[i];
|
||||
buff.time -= dt;
|
||||
if(buff.time <= 0){
|
||||
this.ap_buff -= buff.atk
|
||||
this.ap_buff -= buff.ap
|
||||
this.ap_buffs.splice(i,1);
|
||||
}
|
||||
}
|
||||
@@ -573,13 +587,12 @@ export class HeroViewComp extends CCComp {
|
||||
this.node.getChildByName("shielded").active=true
|
||||
}
|
||||
}
|
||||
tooltip(type:number=1,value:string="",s_uuid:number=1001,y:number=60){
|
||||
tooltip(type:number=1,value:string="",s_uuid:number=1001,y:number=90){
|
||||
// console.log("tooltip",type);
|
||||
let tip =ecs.getEntity<Tooltip>(Tooltip);
|
||||
let pos = this.node.getPosition();
|
||||
let node =this.node.parent
|
||||
let pos = v3(0,0);
|
||||
pos.y=pos.y+y;
|
||||
tip.load(pos,type,value,s_uuid,node);
|
||||
tip.load(pos,type,value,s_uuid,this.node);
|
||||
}
|
||||
|
||||
/** 静止时间 */
|
||||
|
||||
Reference in New Issue
Block a user