碰撞体 基本完成,开始精灵技能释放优化
This commit is contained in:
@@ -44,10 +44,11 @@ export class Skill extends ecs.Entity {
|
||||
sv.atk = atk;
|
||||
sv.angle = angle;
|
||||
sv.t_pos = t_pos;
|
||||
sv.box_tag= BoxSet.SKILL_TAG;
|
||||
if(scale == 1){
|
||||
sv.box_group=BoxSet.HERO_SKILL
|
||||
sv.box_group=BoxSet.HERO
|
||||
}else{
|
||||
sv.box_group=BoxSet.MONSTER_SKILL
|
||||
sv.box_group=BoxSet.MONSTER
|
||||
}
|
||||
this.add(sv);
|
||||
}
|
||||
|
||||
@@ -25,14 +25,17 @@ export class SkillCom extends CCComp {
|
||||
t_pos:Vec3 = null;
|
||||
is_destroy:boolean = false;
|
||||
box_group:number = 0;
|
||||
box_tag:number=0;
|
||||
start() {
|
||||
this.node.active=true
|
||||
this.node.angle = this.angle;
|
||||
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = this.box_group;
|
||||
collider.tag = this.box_tag;
|
||||
collider.sensor = true;
|
||||
if (collider) {
|
||||
// collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||
}
|
||||
if(this.t_pos){
|
||||
@@ -57,41 +60,45 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
switch (selfCollider.group) {
|
||||
|
||||
case BoxSet.HERO_SKILL:
|
||||
switch (otherCollider.group){
|
||||
case BoxSet.MONSTER:
|
||||
case BoxSet.DEFAULT:
|
||||
setTimeout(() => {
|
||||
this.toDestroy()
|
||||
}, 10);
|
||||
break
|
||||
}
|
||||
break;
|
||||
case BoxSet.MONSTER_SKILL:
|
||||
switch (otherCollider.group){
|
||||
case BoxSet.PLAYER:
|
||||
case BoxSet.HERO:
|
||||
case BoxSet.DEFAULT:
|
||||
setTimeout(() => {
|
||||
this.toDestroy()
|
||||
}, 10);
|
||||
break
|
||||
}
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(otherCollider.group != selfCollider.group){
|
||||
console.log("skill end contact")
|
||||
setTimeout(() => {
|
||||
this.toDestroy()
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
// console.log("skill post contact")
|
||||
// switch (selfCollider.group) {
|
||||
|
||||
// case BoxSet.HERO:
|
||||
// switch (otherCollider.group){
|
||||
// case BoxSet.MONSTER:
|
||||
// case BoxSet.DEFAULT:
|
||||
// setTimeout(() => {
|
||||
// this.toDestroy()
|
||||
// }, 10);
|
||||
// break
|
||||
// }
|
||||
// break;
|
||||
// case BoxSet.MONSTER:
|
||||
// switch (otherCollider.group){
|
||||
// case BoxSet.PLAYER:
|
||||
// case BoxSet.HERO:
|
||||
// case BoxSet.DEFAULT:
|
||||
// setTimeout(() => {
|
||||
// this.toDestroy()
|
||||
// }, 10);
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
update(deltaTime: number) {
|
||||
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||
this.move(deltaTime)
|
||||
// if(Math.abs(this.node.position.x) > this.dis)
|
||||
// {
|
||||
// this.toDestroy()
|
||||
|
||||
// }
|
||||
// this.move(deltaTime)
|
||||
|
||||
|
||||
}
|
||||
move(dt: number) {
|
||||
|
||||
Reference in New Issue
Block a user