碰撞体 基本完成,开始精灵技能释放优化

This commit is contained in:
2024-08-22 13:38:03 +08:00
parent a707bcca29
commit bdb96e61a1
35 changed files with 806 additions and 1809 deletions

View File

@@ -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) {