攻击距离设定

This commit is contained in:
2024-09-11 10:19:35 +08:00
parent 0f7f2ad49b
commit f5a8cb20de
31 changed files with 114 additions and 191 deletions

View File

@@ -63,9 +63,9 @@ export class BoxRangComp extends CCComp {
this.MonViewComp.enemy = otherCollider.node;
}
}
if(Math.abs(other_pos.x-self_pos.x) < this.atk_range){
if(Math.abs(other_pos.x-self_pos.x) < this.MonViewComp.atk_dis){
this.MonViewComp.is_atking = true;
// this.MonViewComp.stop_cd = 0.1
this.MonViewComp.stop_cd = 0.1
}
}

View File

@@ -83,6 +83,7 @@ export class Mon extends ecs.Entity {
mv.level = smc.monsters[uuid].level;
mv.atk = smc.monsters[uuid].atk;
mv.atk_cd = smc.monsters[uuid].atk_cd;
mv.atk_dis = smc.monsters[uuid].atk_dis;
mv.power = smc.monsters[uuid].power;
mv.type = smc.monsters[uuid].type;
mv.skill_uuid = 9001;

View File

@@ -64,6 +64,7 @@ export class MonViewComp extends CCComp {
atk: number = 10; /**攻击力 */
// atk_speed: number = 1;
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
atk_dis: number = 80;
atk_time: number = 0; /** 冷却时间 */
speed: number = 100; /** 角色移动速度 */
@@ -138,29 +139,29 @@ export class MonViewComp extends CCComp {
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.is_atking = true;
this.stop_cd = 0.1;
}
// if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
// this.is_atking = true;
// this.stop_cd = 0.1;
// }
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group == otherCollider.group&&otherCollider.tag == 0&&selfCollider.tag == 0){
let self_pos=selfCollider.node.getPosition();
let other_pos=otherCollider.node.getPosition();
// console.log('mon view group 相同');
switch (selfCollider.group) {
case BoxSet.HERO:
if(self_pos.x < other_pos.x){
// this.stop_cd=0.1
}
break;
case BoxSet.MONSTER:
if(self_pos.x > other_pos.x){
// this.stop_cd=0.1
}
break
}
}
// if(selfCollider.group == otherCollider.group&&otherCollider.tag == 0&&selfCollider.tag == 0){
// let self_pos=selfCollider.node.getPosition();
// let other_pos=otherCollider.node.getPosition();
// // console.log('mon view group 相同');
// switch (selfCollider.group) {
// case BoxSet.HERO:
// if(self_pos.x < other_pos.x){
// // this.stop_cd=0.1
// }
// break;
// case BoxSet.MONSTER:
// if(self_pos.x > other_pos.x){
// // this.stop_cd=0.1
// }
// break
// }
// }
}
@@ -186,7 +187,7 @@ export class MonViewComp extends CCComp {
return;
}
if(this.scale===-1&&this.node.position.x <= BoxSet.HERO_START){
if(this.scale===-1&&this.node.position.x <= BoxSet.HERO_START+this.atk_cd){
return;
}
// if(this.enemy){