This commit is contained in:
2024-11-13 17:20:45 +08:00
parent 4e08ad13d1
commit 9d0ee7e7b5
7 changed files with 98 additions and 296 deletions

View File

@@ -79,34 +79,30 @@ export class HeroViewComp extends CCComp {
atk_buffs:any = [];
// atk_speed: number = 1;
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
atk_dis: number = 80;
dis: number = 80;
atk_time: number = 0; /** 冷却时间 */
st_boncus: number = 1; //技能持续时间加成
s_boncus: number = 1; //技能效果加成
def: number = 0; //防御
vun: number = 0; //易伤
crit: number = 1.5; //暴击伤害比率
crit_rate: number = 0;//暴击伤害加成
dodge: number = 10; //闪避率
shield:number = 0; //护盾,免伤1次减1
speed: number = 100; /** 角色移动速度 */
ospeed: number = 100; /** 角色初始速度 */
Tpos: Vec3 = v3(0,-60,0);
stop_cd: number = 0.5; /*停止倒计时*/
//暴击
crit: number = 1.5;
crit_rate: number = 0;
//免伤
dodge_rate: number = 0;
shield:number = 0; //护盾量
shield_max:number = 200;
shield_time:number = 0; //护盾持续时间
buff_shields:any=[];
dir_y:number = 0;
speek_time:number = 0;
role_heros_index:number = -1;
onLoad() {
this.as = this.getComponent(HeroSpine);
@@ -162,8 +158,21 @@ export class HeroViewComp extends CCComp {
if(this.hp <= 0 ){
return
}
let loss_hp=skill.atk*(100-this.dodge_rate)/100
this.hp_change(loss_hp);
if(this.shield > 0){
this.shield -= 1
return
}
let dodge = RandomManager.instance.getRandomInt(0,100,3)
if(dodge < this.dodge){
//todo 闪避跳字
console.log("闪避了",dodge,this.dodge);
return
}
let l_hp=(skill.atk-this.def)*-1
if(l_hp >= 0){
l_hp=-1 //最低1点伤害
}
this.hp_change(l_hp);
}
}
@@ -206,7 +215,7 @@ export class HeroViewComp extends CCComp {
}
update(dt: number){
if(!smc.vm_data.mission.play||smc.vm_data.pause){
if(!smc.vm_data.mission.play||smc.vm_data.pause||this.is_dead){
return
}
if (this.timer.update(dt)) {
@@ -215,9 +224,7 @@ export class HeroViewComp extends CCComp {
// if(this.anm_timer.update(dt)) {
// this.change_anm()
// }
this.in_destroy();
this.check_atk_buffs(dt)
this.in_shield(dt);
this.in_stop(dt);
this.atk_time += dt;
this.check_enemy_alive()
@@ -274,9 +281,9 @@ export class HeroViewComp extends CCComp {
}
}
}
if(dir < this.atk_dis){
if(dir < this.dis){
this.is_atking=true
this.stop_cd = 0.1
}else{
@@ -378,16 +385,15 @@ export class HeroViewComp extends CCComp {
let {pos,t_pos}=this.get_hero_pos(hero)
skill.load(pos,this.box_group,this.node,this.sk2,atk,t_pos);
if(smc.skills[s_uuid].hp > 0){ //buff加血
let increase_hp=Math.floor(smc.skills[s_uuid].hp*this.atk*this.s_boncus*smc.vm_data.mission.hero.atk)
let increase_hp=Math.floor(smc.skills[s_uuid].hp*this.atk)
hero.add_hp(increase_hp)
}
if(smc.skills[s_uuid].atk > 0){ //buff加攻击
let increase_atk=Math.floor(smc.skills[s_uuid].atk*this.atk*this.s_boncus*smc.vm_data.mission.hero.atk)
hero.add_atk(increase_atk,smc.skills[s_uuid].bsd*this.st_boncus)
let increase_atk=Math.floor(smc.skills[s_uuid].atk*this.atk)
hero.add_atk(increase_atk,smc.skills[s_uuid].bsd)
}
if(smc.skills[s_uuid].shield > 0){ //buff护盾
let increase_shield=Math.floor(smc.skills[s_uuid].shield*this.atk*this.s_boncus*smc.vm_data.mission.hero.atk)
hero.add_shield(increase_shield,smc.skills[s_uuid].bsd*this.st_boncus)
hero.add_shield(smc.skills[s_uuid].shield)
}
}
@@ -516,12 +522,9 @@ export class HeroViewComp extends CCComp {
if(this.is_dead){
return;
}
let lhp=this.shield_change(hp);
if(lhp == 0){
return;
}
this.hp += lhp;
// this.tooltip(1,hp.toString());
this.hp += hp;
this.tooltip(1,hp.toString(),250);
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
@@ -575,43 +578,10 @@ export class HeroViewComp extends CCComp {
add_shield(shield: number,time:number=0){
this.shield =this.shield_max=shield
this.shield_time = time;
}
shield_change(hp: number){
let ls=this.shield - hp;
if(ls <= 0){
this.shield = 0;
return ls;
}else{
this.shield = ls;
return 0;
}
}
in_shield(dt: number){
if(this.shield <= 0){
this.shield_time=0
this.node.getChildByName("shielded").active=false
}else{
this.node.getChildByName("shielded").active=true
}
if(this.shield_time <= 0){
this.shield = this.shield_max=0;
this.node.getChildByName("shielded").active=false
return
}
if(this.shield_time > 0){
this.shield_time -= dt;
if(this.shield_time <= 0){
this.shield_time = 0;
this.shield = this.shield_max=0;
// this.node.getChildByName("top").getChildByName("shield").active=false
}
// let shield_progress= this.shield/this.shield_max;
// this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
}
add_shield(shield:number){
this.shield =shield
}
tooltip(type:number=1,value:string="",s_uuid:number=1001,y:number=60){
// console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip);
@@ -631,10 +601,7 @@ export class HeroViewComp extends CCComp {
}
}
}
in_destroy(){
}
in_atked() {
// var path = "game/skills/atked";
// var prefab: Prefab = oops.res.get(path, Prefab)!;