添加2个游戏层,敌方精灵随机出现在3个层内

This commit is contained in:
2024-08-22 22:59:43 +08:00
parent 6e9faca1a3
commit 2917c12f14
65 changed files with 394 additions and 2540 deletions

View File

@@ -3,6 +3,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
const { ccclass, property } = _decorator;
@@ -26,6 +27,7 @@ export class SkillCom extends CCComp {
is_destroy:boolean = false;
box_group:number = 0;
box_tag:number=0;
time:Timer = new Timer(0.01);
start() {
this.node.active=true
this.node.angle = this.angle;
@@ -45,12 +47,10 @@ export class SkillCom extends CCComp {
tween(this.node).to( 1,{ angle:this.angle,position: this.t_pos},
{
onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
if(target.y <= 200 ){
this.toDestroy()
} // 将缓动系统计算出的结果赋予 node 的位置
// 将缓动系统计算出的结果赋予 node 的位置
},
onComplete: (target?: object) => {
this.toDestroy()
this.is_destroy=true
},
}
).start();
@@ -59,7 +59,7 @@ export class SkillCom extends CCComp {
{ position: new Vec3(this.node.position.x+this.scale*this.dis,this.node.position.y) },
{
onComplete: (target?: object) => {
this.toDestroy()
this.is_destroy=true
},
}
).start();
@@ -68,10 +68,8 @@ export class SkillCom extends CCComp {
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(otherCollider.group != selfCollider.group){
console.log("skill end contact",selfCollider.group,otherCollider.group)
setTimeout(() => {
this.toDestroy()
}, 10);
// console.log("skill end contact",selfCollider.group,otherCollider.group)
this.is_destroy=true
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
@@ -104,24 +102,18 @@ export class SkillCom extends CCComp {
update(deltaTime: number) {
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
// this.move(deltaTime)
this.toDestroy()
}
move(dt: number) {
// this.node.setPosition(v3(this.node.position.x+dt*this.x_speed*this.scale,this.node.position.y+this.y_speed,this.node.position.z))
}
check_to_destroy(){
if(!this.is_destroy){
this.is_destroy = true;
this.toDestroy();
}
}
toDestroy() {
if(!this.is_destroy){
this.is_destroy = true;
if(this.is_destroy){
if(this.node.isValid) this.ent.destroy()
}
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.is_destroy=false