技能碰撞改回物理碰撞
This commit is contained in:
@@ -46,6 +46,10 @@ export class CardComp extends CCComp {
|
||||
show.getChildByName("name").getComponent(Label).string=HeroInfo[uuid].name
|
||||
show.getChildByName("ap").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].ap.toString()
|
||||
show.getChildByName("hp").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].hp.toString()
|
||||
show.getChildByName("type").getChildByName("war").active=HeroInfo[uuid].type==0
|
||||
show.getChildByName("type").getChildByName("bow").active=HeroInfo[uuid].type==1
|
||||
show.getChildByName("type").getChildByName("mag").active=HeroInfo[uuid].type==2
|
||||
show.getChildByName("lv").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].lv.toString()
|
||||
var icon_path = "game/heros/herois"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("icon").getComponent(Sprite);
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ import { _decorator, v3, Vec3 } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { HeroInfo, HeroList, HeroSet } from "../common/config/heroSet";
|
||||
import { HeroInfo, HeroList, HeroPos, HeroSet } from "../common/config/heroSet";
|
||||
import { Hero } from "../hero/Hero";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -16,6 +18,11 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('MissionHeroComp', false)
|
||||
export class MissionHeroCompComp extends CCComp {
|
||||
timer:Timer=new Timer(2)
|
||||
start_pos:any={
|
||||
0:{pos:v3(-140,130,0),has:false},
|
||||
1:{pos:v3(-220,130,0),has:false},
|
||||
2:{pos:v3(-300,130,0),has:false},
|
||||
}
|
||||
onLoad(){
|
||||
this.on(GameEvent.UserHeroCard,this.call_hero,this)
|
||||
}
|
||||
@@ -27,7 +34,9 @@ export class MissionHeroCompComp extends CCComp {
|
||||
|
||||
}
|
||||
init(){
|
||||
|
||||
this.start_pos[0].has=false
|
||||
this.start_pos[1].has=false
|
||||
this.start_pos[2].has=false
|
||||
}
|
||||
test_call(){
|
||||
this.addHero(5010)
|
||||
@@ -41,12 +50,30 @@ export class MissionHeroCompComp extends CCComp {
|
||||
this.addHero(uuid)
|
||||
}
|
||||
/** 添加玩家 */
|
||||
private addHero(uuid:number=1001,i:number=0) {
|
||||
private addHero(uuid:number=1001) {
|
||||
console.log("call_hero addHero",uuid)
|
||||
let info:any={ap:0,hp:0}
|
||||
if(this.start_pos[HeroInfo[uuid].type].has){
|
||||
info=this.remove_hero(HeroInfo[uuid].type)
|
||||
}
|
||||
let hero = ecs.getEntity<Hero>(Hero);
|
||||
let scale = 1
|
||||
let y=RandomManager.instance.getRandomInt(0,HeroSet.Start_y.length,1)
|
||||
let pos:Vec3 = v3(HeroSet.Start_x[HeroInfo[uuid].type],HeroSet.Start_y[y]);
|
||||
hero.load(pos,scale,uuid);
|
||||
let pos:Vec3 = v3(HeroPos[HeroInfo[uuid].type].pos);
|
||||
hero.load(pos,scale,uuid,info);
|
||||
this.start_pos[HeroInfo[uuid].type].has=true
|
||||
}
|
||||
remove_hero(i:number){
|
||||
let info:any={ap:0,hp:0}
|
||||
let heros=ecs.query(ecs.allOf(HeroModelComp))
|
||||
for(let hero of heros){
|
||||
if(hero.get(HeroViewComp).node.position.x==HeroPos[i].pos.x){
|
||||
info.ap=hero.get(HeroViewComp).ap*(100+hero.get(HeroViewComp).r_up)/100
|
||||
info.hp=hero.get(HeroViewComp).hp*(100+hero.get(HeroViewComp).r_up)/100
|
||||
hero.destroy()
|
||||
return info
|
||||
}
|
||||
}
|
||||
return info
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
|
||||
@@ -15,7 +15,7 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('MissionMonCompComp')
|
||||
@ecs.register('MissionMonComp', false)
|
||||
export class MissionMonCompComp extends CCComp {
|
||||
timer:Timer=new Timer(5)
|
||||
timer:Timer=new Timer(3)
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
@@ -42,39 +42,23 @@ export class MissionMonCompComp extends CCComp {
|
||||
let tc=1
|
||||
let yc=2
|
||||
let bc=1
|
||||
for(let i=0;i<tc;i++){
|
||||
let x=RandomManager.instance.getRandomInt(0,t_num,1)
|
||||
this.addMonster(Missions[0][x],i)
|
||||
console.log("Missions t:"+x,Missions[0][x])
|
||||
}
|
||||
for(let i=0;i<yc;i++){
|
||||
let x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[1][x],i)
|
||||
console.log("Missions y:"+x,Missions[1][x])
|
||||
}
|
||||
for(let i=0;i<bc;i++){
|
||||
let x=RandomManager.instance.getRandomInt(0,b_num,1)
|
||||
console.log("Missions b:"+x,Missions[2][x])
|
||||
x=RandomManager.instance.getRandomInt(0,b_num,1)
|
||||
console.log("Missions b:"+x,Missions[2][x])
|
||||
x=RandomManager.instance.getRandomInt(0,b_num,1)
|
||||
console.log("Missions b:"+x,Missions[2][x])
|
||||
x=RandomManager.instance.getRandomInt(0,b_num,1)
|
||||
console.log("Missions b:"+x,Missions[2][x])
|
||||
x=RandomManager.instance.getRandomInt(0,b_num,1)
|
||||
console.log("Missions b:"+x,Missions[2][x])
|
||||
x=RandomManager.instance.getRandomInt(0,b_num,1)
|
||||
console.log("Missions b:"+x,Missions[2][x])
|
||||
this.addMonster(Missions[2][x],i,true)
|
||||
}
|
||||
let x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[0][x],0)
|
||||
x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[0][x],1)
|
||||
x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[0][x],2)
|
||||
x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[0][x],3)
|
||||
|
||||
console.log("Missions t:"+x,Missions[0][x])
|
||||
|
||||
}
|
||||
|
||||
private addMonster(uuid:number=1001,i:number=0,is_boss:boolean=false) {
|
||||
let mon = ecs.getEntity<Monster>(Monster);
|
||||
let scale = -1
|
||||
let x=RandomManager.instance.getRandomInt(0,MonSet.Start_x.length,1)
|
||||
let y=RandomManager.instance.getRandomInt(0,MonSet.Start_y.length,1)
|
||||
let pos:Vec3 = v3(MonSet.Start_x[2],MonSet.Start_y[y]);
|
||||
let pos:Vec3 = v3(MonSet[i].pos);
|
||||
mon.load(pos,scale,uuid,is_boss);
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
Reference in New Issue
Block a user