攻击距离设定
This commit is contained in:
@@ -64,6 +64,7 @@ export class HeroViewComp 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 HeroViewComp 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
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -182,11 +183,11 @@ export class HeroViewComp extends CCComp {
|
||||
if(this.stop_cd > 0){
|
||||
return
|
||||
}
|
||||
if (this.scale === 1 && this.node.position.x >= 120) {
|
||||
if (this.scale === 1 && this.node.position.x >= BoxSet.MONSTER_START) {
|
||||
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){
|
||||
|
||||
Reference in New Issue
Block a user