技能碰撞改回物理碰撞

This commit is contained in:
2025-03-30 16:59:40 +08:00
parent 67704725b2
commit 798a831227
85 changed files with 13428 additions and 7394 deletions

View File

@@ -33,9 +33,12 @@ export class MissionComp extends CCComp {
mission_buff_up_exp:number = 99999999
MSComp:MSkillComp=null
MMSComp:MSkillComp=null
heros_node:any=null
heros_node_pos:any=v3(0,0,0)
herosc_node:any=null
hero_args:any=null
onLoad(){
// this.on(GameEvent.UserHeroCard,this.show_herosc,this)
// this.MSComp=this.node.getChildByName("msk").getComponent(MSkillComp)
// this.MMSComp=this.node.getChildByName("mmsk").getComponent(MSkillComp)
// this.MSComp.group=BoxSet.HERO
@@ -44,6 +47,11 @@ export class MissionComp extends CCComp {
// this.MMSComp.s_uuid=smc.mission.mmskill
}
start() {
this.heros_node=this.node.getChildByName("heros")
this.herosc_node=this.node.getChildByName("herosc")
this.herosc_node.active=false
this.node.getChildByName('hbg').active=false
this.heros_node_pos=v3(this.heros_node.position.x,this.heros_node.position.y,this.heros_node.position.z)
// this.VictoryComp=this.node.getChildByName("victory").getComponent(VictoryComp)
}
@@ -51,19 +59,37 @@ export class MissionComp extends CCComp {
if(!smc.mission.play||smc.mission.pause){
return
}
if(this.fight_start){
this.check_mon_num()
}
this.count_hero_pos()
this.count_mon_pos()
// if (this.game_timer.update(dt)) {
// smc.vmdata.game.g_time += 1;
// }
// this.shuaxin(dt)
}
}
show_herosc(event: string, args: any){
this.node.getChildByName('hbg').active=true
const screenSize = this.node.getComponent(UITransform).contentSize;
const centerY = screenSize.height / 2;
tween(this.heros_node).to(0.1,{position:v3(this.heros_node.position.x,centerY,0)}, // 这里以node的位置信息坐标缓动的目标
{ // ITweenOption 的接口实现:
onComplete:()=>{
this.herosc_node.active=true
this.heros_node.active=false
this.hero_args=args
}
}).start()
}
call_hero(event: string, args: any){
console.log("call_hero",args)
oops.message.dispatchEvent(GameEvent.CallHero,{uuid:this.hero_args.uuid,pos:args})
this.herosc_node.active=false
this.heros_node.active=true
this.heros_node.position=this.heros_node_pos
this.hero_args=null
this.node.getChildByName('hbg').active=false
}
mission_start(){
/* todo 关卡设定完善*/
console.log("mission_start Missions mons:",Missions[smc.mission.lv])
console.log("战斗开始 Missions mons:",Missions[smc.mission.lv])
smc.mission.status=1
this.colose_victory()
this.mission_init()
@@ -109,71 +135,14 @@ export class MissionComp extends CCComp {
this.MSComp.init()
this.MMSComp.init()
}
check_mon_num(){
let mons:any = this.get_mons()
let heros:any= this.get_heros()
let h_alive=false
let m_alive=false
for (let i = 0; i < heros.length; i++) {
if ( !heros[i].HeroView.is_dead) {
h_alive=true
}
}
for (let i = 0; i < mons.length; i++) {
if ( !mons[i].HeroView.is_dead) {
m_alive=true
}
}
// if (!m_alive||!h_alive) this.mission_end()
}
get_mons(){
return ecs.query(ecs.allOf(MonModelComp));
}
get_heros(){
return ecs.query(ecs.allOf(HeroModelComp))
}
count_mon_pos(){
let right_x:number=360
let left_x:number=-360
let monsters:any= this.get_mons()
for(let i=0;i<monsters.length;i++){
if(monsters[i].HeroView == undefined) return
if(monsters[i].HeroView.node.position.x > 400) continue
let mon:any = monsters[i].HeroView.node.position
smc.enemy_pos[i]= mon
if(monsters[i].HeroView.node.position.x > left_x){
left_x = monsters[i].HeroView.node.position.x
}
if(monsters[i].HeroView.node.position.x < right_x){
right_x = monsters[i].HeroView.node.position.x
}
}
smc.mon_front_x=right_x
smc.mon_back_x=left_x
// console.log("count_mon_pos",smc.mon_pos,smc.mon_front_x,smc.mon_back_x)
}
count_hero_pos(){
let right_x:number=360
let left_x:number=-360
let heros:any= this.get_heros()
for(let i=0;i<heros.length;i++){
if(heros[i].HeroView == undefined) return
if(heros[i].HeroView.node.position.x < -400) continue
let ho:any = heros[i].HeroView.node.position
smc.hero_pos[i]= ho
if(heros[i].HeroView.node.position.x > left_x){
left_x = heros[i].HeroView.node.position.x
}
if(heros[i].HeroView.node.position.x < right_x){
right_x = heros[i].HeroView.node.position.x
}
}
smc.hero_front_x=left_x
smc.hero_back_x=right_x
// console.log("count_hero_pos",smc.hero_pos,smc.hero_front_x,smc.mon_front_x)
}
card_refresh(){
oops.message.dispatchEvent(GameEvent.CardRefresh)
}