关卡设置基本完成
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user