This commit is contained in:
2024-08-16 08:45:09 +08:00
parent c67a149620
commit dc12cea962
20 changed files with 1256 additions and 558 deletions

View File

@@ -27,6 +27,7 @@ const { ccclass, property } = _decorator;
export class MonsterViewComp extends CCComp {
/** 角色动画 */
as: MonsterSpine = null!;
hero_uuid:number = 1001;
hero_name : string = "hero";
level:number =1;
camp: number = 1; /** 角色阵营 1hero -1 :monster */
@@ -75,6 +76,7 @@ export class MonsterViewComp extends CCComp {
// collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
}
console.log(' hero_uuid:',this.hero_uuid);
}
@@ -176,6 +178,10 @@ export class MonsterViewComp extends CCComp {
move(dt: number){
this.node.setPosition(this.node.position.x+dt*this.speed*this.camp, this.node.position.y, this.node.position.z);
if(Math.abs(this.node.position.x) >= BoxSet.END_POINT){
this.node.setPosition(v3(this.camp*-BoxSet.END_POINT,BoxSet.GAME_LINE,this.node.position.z))
// console.log("speed:"+this.speed+" | stop_cd:"+this.stop_cd);
}
}
power_change(power: number){
this.power += power;
@@ -224,18 +230,18 @@ export class MonsterViewComp extends CCComp {
}
}
in_destroy(){
switch (this.camp) {
case -1:
if(this.node.position.x < BoxSet.LETF_END){
this.toDestroy();
}
break;
case 1:
if(this.node.position.x > BoxSet.RIGHT_END){
this.toDestroy();
}
break;
}
// switch (this.camp) {
// case -1:
// if(this.node.position.x < BoxSet.LETF_END){
// this.toDestroy();
// }
// break;
// case 1:
// if(this.node.position.x > BoxSet.RIGHT_END){
// this.toDestroy();
// }
// break;
// }
}
update_pos(){
smc.monsters_in.forEach((element,index) => {
@@ -247,7 +253,7 @@ export class MonsterViewComp extends CCComp {
load_skill(skill_name){
// console.log("load_skill");
let skill = ecs.getEntity<Skill>(Skill);
let pos = v3(0,30)
let pos = v3(0,0)
let speed =150
let scale = this.camp
let range = 80
@@ -257,7 +263,7 @@ export class MonsterViewComp extends CCComp {
var path = "game/skills/atked";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
let pos = v3(0,0)
let pos = v3(0,30)
node.setPosition(pos)
node.parent = this.node;
}
@@ -265,7 +271,7 @@ export class MonsterViewComp extends CCComp {
var path = "game/skills/dead";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.setPosition(this.node.position)
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z);
node.parent = this.node.parent;
}
toDestroy(){