排序问题解决,优化小兵线路

This commit is contained in:
2024-09-13 00:51:23 +08:00
parent f80115e251
commit 221d91a795
43 changed files with 11085 additions and 28930 deletions

View File

@@ -77,7 +77,7 @@ export class SingletonModuleComp extends ecs.Comp {
g_time:0,
},
role:{
hp:30000,
hp:300,
atk:10,
lv:1,
exp:0,

View File

@@ -1,52 +1,92 @@
export const HeroSet={
9001:{uuid:9001,path:"k3",type:1,level:1,name:"战士",atk:4,hp: 350,atk_dis:40,atk_cd:2,power:0,power_max: 10,speed: 30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1,},
9011:{uuid:9004,path:"m1",type:1,level:1,name:"冰法",atk:4,hp: 15,atk_dis:200,atk_cd:2,power:0,power_max: 10,speed: 30,
max_skill: "寒冰箭",skill_uuid:9002,max_skill_uuid:1002,word: "守护",info: "自身护盾",atktype:1,},
9021:{uuid:9006,path:"m3",type:3,level:1,name:"火法",atk:6,hp: 15,atk_dis:200,atk_cd:2,power:0,power_max: 10,speed: 30,
max_skill: "火球术",skill_uuid:9002,max_skill_uuid:1001,word: "守护",info: "自身护盾", atktype:2},
9031:{uuid:9005,path:"m2",type:3,level:1,name:"牧师",atk:3,hp: 20,atk_dis:200,atk_cd:2,power:0,power_max: 10,speed: 30,
max_skill: "治愈术",skill_uuid:9002,max_skill_uuid:9002,word: "守护",info: "自身护盾", atktype:2},
export const HeroSet = {
9001: {
uuid: 9001, path: "k3", type: 1, level: 1, name: "战士", atk: 4, hp: 35, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1,
},
9041:{uuid:9009,path:"arc1",type:3,level:1,name:"弓箭手",atk:3,hp: 15,atk_dis:300,atk_cd:1,power:0,power_max: 10,speed: 30,
max_skill: "精准射击",skill_uuid:9003,max_skill_uuid:9003,word: "狂暴",info: "全体攻击", atktype:2},
9011: {
uuid: 9004, path: "m1", type: 1, level: 1, name: "冰法", atk: 4, hp: 15, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "寒冰箭", skill_uuid: 9002, max_skill_uuid: 1002, word: "守护", info: "自身护盾", atktype: 1,
},
9021: {
uuid: 9006, path: "m3", type: 3, level: 1, name: "火法", atk: 6, hp: 15, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "火球术", skill_uuid: 9002, max_skill_uuid: 1001, word: "守护", info: "自身护盾", atktype: 2
},
9031: {
uuid: 9005, path: "m2", type: 3, level: 1, name: "牧师", atk: 3, hp: 20, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "治愈术", skill_uuid: 9002, max_skill_uuid: 9002, word: "守护", info: "自身护盾", atktype: 2
},
9041: {
uuid: 9009, path: "arc1", type: 3, level: 1, name: "弓箭手", atk: 3, hp: 15, atk_dis: 300, atk_cd: 1, power: 0, power_max: 10, speed: 30,
max_skill: "精准射击", skill_uuid: 9003, max_skill_uuid: 9003, word: "狂暴", info: "全体攻击", atktype: 2
},
}
export const MonSet={
1001:{uuid:1001,path:"ge1",type:1,level:1,name:"战斗哥",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1002:{uuid:1002,path:"ge2",type:1,level:1,name:"墨西哥",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1003:{uuid:1003,path:"ge3",type:1,level:1,name:"铁头哥",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1011:{uuid:1011,path:"orc1",type:1,level:1,name:"森林兽人",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1012:{uuid:1012,path:"orc2",type:1,level:1,name:"荒野兽人",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1013:{uuid:1013,path:"orc3",type:1,level:1,name:"兽人战士",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1021:{uuid:1021,path:"gou1",type:1,level:1,name:"黄皮豺狼",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1022:{uuid:1022,path:"gou2",type:1,level:1,name:"白皮豺狼",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1023:{uuid:1023,path:"gou3",type:1,level:1,name:"灰皮豺狼",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1031:{uuid:1031,path:"gou1",type:1,level:1,name:"独眼巨人",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1032:{uuid:1032,path:"gou2",type:1,level:1,name:"狂暴独眼",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1033:{uuid:1033,path:"gou3",type:1,level:1,name:"独眼首领",atk:4,hp: 30,atk_dis:40,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "精准打击",skill_uuid:9001,max_skill_uuid:9001,word: "守护",info: "自身护盾", atktype:1},
1041:{uuid:1041,path:"ys1",type:1,level:1,name:"火元素",atk:4,hp: 30,atk_dis:200,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "火球术",skill_uuid:9002,max_skill_uuid:1001,word: "守护",info: "自身护盾", atktype:2},
1042:{uuid:1042,path:"ys2",type:1,level:1,name:"冰元素",atk:4,hp: 30,atk_dis:200,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "寒冰箭",skill_uuid:9002,max_skill_uuid:1002,word: "守护",info: "自身护盾", atktype:2},
1043:{uuid:1043,path:"ys3",type:1,level:1,name:"气元素",atk:4,hp: 30,atk_dis:200,atk_cd:2,power:0,power_max:10,speed:30,
max_skill: "魔法球",skill_uuid:9002,max_skill_uuid:9002,word: "守护",info: "自身护盾", atktype:2},
export const MonSet = {
1001: {
uuid: 1001, path: "ge1", type: 1, level: 1, name: "战斗哥", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1002: {
uuid: 1002, path: "ge2", type: 1, level: 1, name: "墨西哥", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1003: {
uuid: 1003, path: "ge3", type: 1, level: 1, name: "铁头哥", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1011: {
uuid: 1011, path: "orc1", type: 1, level: 1, name: "森林兽人", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1012: {
uuid: 1012, path: "orc2", type: 1, level: 1, name: "荒野兽人", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1013: {
uuid: 1013, path: "orc3", type: 1, level: 1, name: "兽人战士", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1021: {
uuid: 1021, path: "gou1", type: 1, level: 1, name: "黄皮豺狼", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1022: {
uuid: 1022, path: "gou2", type: 1, level: 1, name: "白皮豺狼", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1023: {
uuid: 1023, path: "gou3", type: 1, level: 1, name: "灰皮豺狼", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1031: {
uuid: 1031, path: "gou1", type: 1, level: 1, name: "独眼巨人", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1032: {
uuid: 1032, path: "gou2", type: 1, level: 1, name: "狂暴独眼", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1033: {
uuid: 1033, path: "gou3", type: 1, level: 1, name: "独眼首领", atk: 4, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 9001, word: "守护", info: "自身护盾", atktype: 1
},
1041: {
uuid: 1041, path: "ys1", type: 1, level: 1, name: "火元素", atk: 4, hp: 30, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "火球术", skill_uuid: 9002, max_skill_uuid: 1001, word: "守护", info: "自身护盾", atktype: 2
},
1042: {
uuid: 1042, path: "ys2", type: 1, level: 1, name: "冰元素", atk: 4, hp: 30, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "寒冰箭", skill_uuid: 9002, max_skill_uuid: 1002, word: "守护", info: "自身护盾", atktype: 2
},
1043: {
uuid: 1043, path: "ys3", type: 1, level: 1, name: "气元素", atk: 4, hp: 30, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "魔法球", skill_uuid: 9002, max_skill_uuid: 9002, word: "守护", info: "自身护盾", atktype: 2
},
}

View File

@@ -41,9 +41,10 @@ export class BoxRangComp extends CCComp {
// this.HeroViewComp.stop_cd = 0.1
// }
// }
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0 ){
// console.log(this.node.name+"onEndContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
this.HeroViewComp.is_atking = false;
@@ -53,6 +54,7 @@ export class BoxRangComp extends CCComp {
}
}
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
let scene =smc.map.MapView.scene.mapLayer!.node!
let other_pos = otherCollider.node.getWorldPosition() ;

View File

@@ -61,6 +61,7 @@ export class HeroViewComp extends CCComp {
skill_uuid:number = 9001;
max_skill_uuid:number = 1001;
atk: number = 10; /**攻击力 */
buff_atk: number = 0;
// atk_speed: number = 1;
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
atk_dis: number = 80;
@@ -86,7 +87,7 @@ export class HeroViewComp extends CCComp {
buff_shields:any=[];
buff_atks:any = [];
dir_y:number = 0;
speek_time:number = 0;
onLoad() {
this.as = this.getComponent(HeroSpine);
// this.BoxRang = this.node.getChildByName("range_box");
@@ -137,9 +138,24 @@ export class HeroViewComp extends CCComp {
this.hp_change(skill.atk);
}
}
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) {
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
console.log("onBeginContact tag "+selfCollider.tag+otherCollider.tag)
if(selfCollider.node.position.y < otherCollider.node.position.y){
if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
console.log("onPreSolve",selfCollider.node,otherCollider.node)
console.log("onPreSolve f:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+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());
}
}
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
}
@@ -154,6 +170,7 @@ export class HeroViewComp extends CCComp {
this.in_shield(dt);
this.in_stop(dt);
this.in_atk(dt);
this.in_speek(dt);
this.move(dt);
// if(this.m_timer.update(dt)){
// this.move_to()
@@ -221,6 +238,7 @@ export class HeroViewComp extends CCComp {
this.power += power;
if(this.power >= this.power_max&&this.check_enemy_alive()){
this.as.atk()
this.to_speek(smc.skills[this.max_skill_uuid].name)
this.scheduleOnce(()=>{
this.do_max_skill();
},0.5)
@@ -257,7 +275,22 @@ export class HeroViewComp extends CCComp {
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk,angle,t_pos);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
to_speek(words:string,time:number=0.5){
this.speek_time=0.5
this.node.getChildByName("tooltip").active=true
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = words
}
in_speek(dt: number){
if(this.speek_time <= 0){
return;
}
this.speek_time -= dt;
if(this.speek_time <= 0){
this.speek_time = 0;
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = "";
this.node.getChildByName("tooltip").active=false;
}
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
@@ -320,21 +353,13 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp <= 0){
this.dead();
this.remove_smc_data()
this.is_dead = true;
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
remove_smc_data(){
if(smc.t_monster.eid == this.ent.eid){
smc.t_monster = {eid:0,pos:v3(0,0,0)}
}
if(smc.t_hero.eid == this.ent.eid){
smc.t_hero = {eid:0,pos:v3(0,0,0)}
}
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.hp+=hp;
@@ -349,6 +374,9 @@ export class HeroViewComp extends CCComp {
if(time > 0){
let buff={atk:atk,time:time}
this.buff_atks.push(buff);
this.buff_atks.forEach((element: { atk: number; }) => {
this.buff_atk += element.atk
});
}else{
this.atk += atk;
}
@@ -358,10 +386,20 @@ export class HeroViewComp extends CCComp {
let buff=this.buff_atks[i];
buff.time -= dt;
if(buff.time <= 0){
if(buff.atk > 0)this.atk -= buff.atk;
this.buff_atks.splice(i,1);
}else{
this.buff_atk += buff.atk
}
}
if(this.buff_atks.length <= 0){
this.buff_atk = 0
this.buff_icon_change("atk",false)
}else{
this.buff_icon_change("atk",true)
}
}
buff_icon_change(icon:string,value:boolean){
this.node.getChildByName("top").getChildByName("buff").getChildByName(icon).active=value
}
add_shield(shield: number,time:number=0){
this.shield =this.shield_max=shield
@@ -406,7 +444,7 @@ export class HeroViewComp extends CCComp {
pos.y=pos.y+y;
tip.load(pos,type,value,s_uuid,node);
}
/** 静止时间 */
in_stop (dt: number) {
if(this.stop_cd > 0){

View File

@@ -32,7 +32,7 @@ export class MapMonsterComp extends CCComp {
mission_up_timer: Timer = new Timer(30); //波次增加
cur_mission:number = 1; //当前关卡方案
mission_list:any = []
setp_timer: Timer = new Timer(0.5);
setp_timer: Timer = new Timer(0.3);
target_timer: Timer = new Timer(0.1);
setp_num:number = 1;
game_over:boolean = false;
@@ -40,8 +40,6 @@ export class MapMonsterComp extends CCComp {
// 监听全局事件
oops.message.on("other_add_monster", this.on_other_add_monster, this);
oops.message.on("do_add_hero", this.on_do_add_hero, this);
}
start() {
// this.scene = this.getComponent(MapViewScene);
@@ -70,55 +68,17 @@ export class MapMonsterComp extends CCComp {
// 刷新怪物定时器
this.cur_count += 1;
}
// if(this.target_timer.update(dt)){
// this.target_update()
// }
// if (this.game_timer.update(dt)) {
// smc.vm_data.game.g_time += 1;
// }
// this.shuaxin(dt)
}
target_update(){
console.log("map ",smc.t_hero,smc.t_monster)
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
let monsters:any =ecs.query(ecs.allOf(MonModelComp));
let h_x=-1000
let m_x=1000
let thi=9999
let tmi=9999
for (let i = 0; i < heros.length; i++) {
const hero = heros[i];
if(hero.MonsterView.node.position.x > h_x){
h_x = hero.MonsterView.node.position.x
thi = i
if(smc.t_hero.eid == hero.MonsterView.eid){
break
}
}
}
for (let i = 0; i < monsters.length; i++) {
const monster = monsters[i];
if(monster.MonsterView.node.position.x < m_x){
m_x = monster.MonsterView.node.position.x
tmi = i
if(smc.t_monster.eid == monster.MonsterView.eid){
break
}
}
}
if(thi==9999){
smc.t_hero={eid:0,pos:v3(0,0,0)}
}else{
smc.t_hero = {eid:heros[thi].MonsterView.eid,pos:v3(heros[thi].MonsterView.node.position,heros[thi].MonsterView.node.position.y)}
}
if(tmi==9999){
smc.t_monster={eid:0,pos:v3(0,0,0)}
}else{
smc.t_monster ={eid:monsters[tmi].MonsterView.eid,pos:v3(monsters[tmi].MonsterView.node.position,monsters[tmi].MonsterView.node.position.y)}
}
check_mon_count(){
let count = 0;
let list = ecs.query(ecs.allOf(MonModelComp));
count = list.length
return count;
}
load_role(){
let role = ecs.getEntity<Role>(Role);
@@ -134,7 +94,6 @@ export class MapMonsterComp extends CCComp {
private addHero(uuid:number=1001) {
let hero = ecs.getEntity<Hero>(Hero);
let {pos,monster_layer}=this.set_layer(BoxSet.HERO_START)
let scale = 1
hero.load(pos,scale,uuid,monster_layer);
}
@@ -149,16 +108,18 @@ export class MapMonsterComp extends CCComp {
let m2:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
// console.log("刷怪",m)
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+RandomManager.instance.getRandomInt(-40,40, 1))
let pos1:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+RandomManager.instance.getRandomInt(40,130, 1))
let pos2:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE-RandomManager.instance.getRandomInt(40,130, 1))
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+RandomManager.instance.getRandomInt(80,130, 1))
let pos1:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+RandomManager.instance.getRandomInt(10,60, 1))
let pos2:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE-RandomManager.instance.getRandomInt(10,60, 1))
let pos3:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE-RandomManager.instance.getRandomInt(80,130, 1))
let monster_layer = scene.entityLayer!.node!
let monster_layer1 = scene.entityLayer1!.node!;
let monster_layer2 = scene.entityLayer2!.node!;
// let monster_layer1 = scene.entityLayer1!.node!;
// let monster_layer2 = scene.entityLayer2!.node!;
this.addMonster(m[0],monster_layer,pos)
this.addMonster(m1[0],monster_layer1,pos1)
this.addMonster(m2[0],monster_layer2,pos2)
this.addMonster(m1[0],monster_layer,pos1)
this.addMonster(m2[0],monster_layer,pos2)
this.addMonster(m2[0],monster_layer,pos3)
this.setp_num -= 1
}
private addMonster(uuid:number=1001,layer:any,pos:Vec3=v3(0,0,0)) {
@@ -168,20 +129,8 @@ export class MapMonsterComp extends CCComp {
}
set_layer(start:number=0){
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(start,BoxSet.GAME_LINE+RandomManager.instance.getRandomInt(-40,40, 1));
let x = RandomManager.instance.getRandomInt(0,2, 2);
let pos:Vec3 = v3(start,BoxSet.GAME_LINE+RandomManager.instance.getRandomInt(-130,130, 1));
let monster_layer = scene.entityLayer!.node!
switch (x) {
case 1:
monster_layer = scene.entityLayer1!.node!;
pos.y=pos.y+RandomManager.instance.getRandomInt(40,130, 1);
break;
case 2:
monster_layer= scene.entityLayer2!.node!;
pos.y=pos.y-RandomManager.instance.getRandomInt(40,130, 1);
break;
}
return {pos,monster_layer}
}
private on_other_add_monster(event: string, args: any) {

View File

@@ -53,6 +53,11 @@ export class BoxRangComp extends CCComp {
}
}
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
// if(selfCollider.node.parent.position.y < otherCollider.node.parent.position.y){
// console.log("onPreSolve f:"+selfCollider.node.parent.getSiblingIndex()+"/"+otherCollider.node.parent.getSiblingIndex());
// selfCollider.node.parent.setSiblingIndex(otherCollider.node.parent.getSiblingIndex()+1)
// console.log("onPreSolve b:"+selfCollider.node.parent.getSiblingIndex()+"/"+otherCollider.node.parent.getSiblingIndex());
// }
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
let scene =smc.map.MapView.scene.mapLayer!.node!
let other_pos = otherCollider.node.getWorldPosition() ;

View File

@@ -84,6 +84,8 @@ export class MonViewComp extends CCComp {
buff_shields:any=[];
buff_atks:any = [];
dir_y:number = 0;
speek_time:number = 0;
onLoad() {
this.as = this.getComponent(MonSpine);
// this.BoxRang = this.node.getChildByName("range_box");
@@ -168,6 +170,7 @@ export class MonViewComp extends CCComp {
this.power_change(this.power_speed)
}
this.in_destroy();
this.in_speek(dt);
this.in_shield(dt);
this.in_stop(dt);
this.in_atk(dt);
@@ -237,6 +240,7 @@ export class MonViewComp extends CCComp {
this.power += power;
if(this.power >= this.power_max&&this.check_enemy_alive()){
this.as.atk()
this.to_speek(smc.skills[this.max_skill_uuid].name)
this.scheduleOnce(()=>{
this.do_max_skill();
},0.5)
@@ -258,6 +262,7 @@ export class MonViewComp extends CCComp {
}
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
@@ -265,7 +270,22 @@ export class MonViewComp extends CCComp {
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk,angle,t_pos);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
to_speek(words:string,time:number=0.5){
this.speek_time=0.5
this.node.getChildByName("tooltip").active=true
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = words
}
in_speek(dt: number){
if(this.speek_time <= 0){
return;
}
this.speek_time -= dt;
if(this.speek_time <= 0){
this.speek_time = 0;
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = "";
this.node.getChildByName("tooltip").active=false;
}
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
@@ -328,21 +348,13 @@ export class MonViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp <= 0){
this.dead();
this.remove_smc_data()
this.is_dead = true;
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
remove_smc_data(){
if(smc.t_monster.eid == this.ent.eid){
smc.t_monster = {eid:0,pos:v3(0,0,0)}
}
if(smc.t_hero.eid == this.ent.eid){
smc.t_hero = {eid:0,pos:v3(0,0,0)}
}
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.hp+=hp;
@@ -414,7 +426,8 @@ export class MonViewComp extends CCComp {
pos.y=pos.y+60;
tip.load(pos,type,value,s_uuid,node);
}
/** 静止时间 */
in_stop (dt: number) {
if(this.stop_cd > 0){