关卡设置基本完成

This commit is contained in:
walkpan
2024-11-21 17:41:10 +08:00
parent 76d7e6677c
commit 3d9469eb10
10 changed files with 380 additions and 453 deletions

View File

@@ -42,7 +42,7 @@ export class Hero extends ecs.Entity {
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,index:number=-1,is_hero:boolean=true) {
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,is_hero:boolean=true) {
let box_group= 0
if (is_hero) {
@@ -63,11 +63,11 @@ export class Hero extends ecs.Entity {
node.parent = scene.entityLayer!.node!
node.setPosition(pos)
this.hero_init(uuid,node,index,scale,box_group)
this.hero_init(uuid,node,scale,box_group)
oops.message.dispatchEvent("hero_load",this)
}
hero_init(uuid:number=1001,node:Node,index:number=-1,scale:number=1,box_group=BoxSet.HERO){
hero_init(uuid:number=1001,node:Node,scale:number=1,box_group=BoxSet.HERO){
var hv = node.getComponent(HeroViewComp)!;
// console.log("hero_init",buff)
let HInf= smc.heros[uuid] // 角色数据

View File

@@ -116,7 +116,6 @@ export class HeroViewComp extends CCComp {
} /** 视图层逻辑代码分离演示 */
start () {
console.log(this.node.parent)
this.as.idle()
/** 方向 */
this.node.setScale(this.scale,1);
@@ -188,17 +187,17 @@ export class HeroViewComp extends CCComp {
let self_x = selfCollider.node.position.x;
let other_x = otherCollider.node.position.x;
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 15 ){
this.stop_cd = 0.1;
if(selfCollider.group==BoxSet.HERO){
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 8 ){
this.stop_cd = 0.1;
}
}
// if(selfCollider.node.position.y < otherCollider.node.position.y){
// if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
// selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
// // console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
// }
// }
if(selfCollider.group==BoxSet.MONSTER){
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x > other_x && Math.abs(other_x-self_x) < 8 ){
this.stop_cd = 0.1;
}
}
}
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.stop_cd = 0.1;
@@ -208,14 +207,9 @@ export class HeroViewComp extends CCComp {
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
}
update(dt: number){
if(!smc.vm_data.mission.play||smc.vm_data.pause){
let pos =v3(this.scale*-9999,this.node.position.y,this.node.position.z)
this.node.setPosition(pos)
return
}
if(this.is_dead){
let pos =v3(this.scale*-9999,this.node.position.y,this.node.position.z)
this.node.setPosition(pos)
if(!smc.vm_data.mission.play||smc.vm_data.pause||smc.vm_data.mission.is_victory||smc.vm_data.mission.is_defeat) return
if(this.is_dead) {
if(!this.in_grave()) this.to_grave()
return
}
@@ -265,6 +259,16 @@ export class HeroViewComp extends CCComp {
this.is_atking=false
}
}
to_grave(){
let pos =v3(-999,this.node.position.y)
if(this.box_group == BoxSet.MONSTER){
pos =v3(999,this.node.position.y)
}
this.node.setPosition(pos)
}
in_grave(){
return this.node.position.x < -900 || this.node.position.x > 900;
}
status_change(type:string){
this.status=type
if(type == "idle"){
@@ -281,10 +285,10 @@ export class HeroViewComp extends CCComp {
this.status_change("idle")
return
}
if (this.node.position.x >= 360 && this.scale==1) {
if (this.node.position.x >= 300 && this.scale==1) {
return;
}
if(this.scale===-1&&this.node.position.x <= -360){
if(this.scale===-1&&this.node.position.x <= -300){
return;
}
this.status_change("move")
@@ -603,6 +607,7 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp <= 0){
this.dead();
this.to_grave()
this.is_dead = true;
// setTimeout(() => {
// this.ent.destroy();