关卡设置基本完成

This commit is contained in:
2024-11-21 17:41:10 +08:00
parent 76d7e6677c
commit 3d9469eb10
10 changed files with 380 additions and 453 deletions

View File

@@ -491,7 +491,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1700,
"width": 1730,
"height": 800
},
"_anchorPoint": {
@@ -531,7 +531,7 @@
"__uuid__": "d5853a03-897a-4f18-846f-f6282ae3625f@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
@@ -607,7 +607,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -1687.633,
"x": -1700,
"y": 444.859,
"z": 0
},
@@ -648,7 +648,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1700,
"width": 1730,
"height": 800
},
"_anchorPoint": {
@@ -688,7 +688,7 @@
"__uuid__": "d5853a03-897a-4f18-846f-f6282ae3625f@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_type": 3,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
@@ -697,7 +697,7 @@
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_fillRange": 0.99,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
@@ -898,7 +898,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 8.342,
"y": 203.495,
"y": 176.939,
"z": 0
},
"_lrot": {
@@ -938,8 +938,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1125,
"height": 387
"width": 899.4,
"height": 299.8
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -980,7 +980,7 @@
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,

File diff suppressed because it is too large Load Diff

View File

@@ -336,7 +336,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 220,
"width": 350,
"height": 50
},
"_anchorPoint": {
@@ -437,7 +437,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 110.74,
"x": 176.953,
"y": 25,
"z": 0
},
@@ -478,7 +478,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 170,
"width": 300,
"height": 39.8
},
"_anchorPoint": {
@@ -849,7 +849,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 225.086,
"x": 323.804,
"y": 25.663,
"z": 0
},
@@ -1211,7 +1211,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 260,
"x": 350,
"y": 70,
"z": 0
},
@@ -1543,7 +1543,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 123.051,
"x": 127.866,
"y": 25,
"z": 0
},
@@ -2246,7 +2246,7 @@
},
"_alignFlags": 12,
"_target": null,
"_left": 260,
"_left": 350,
"_right": 68.59100000000001,
"_top": 0,
"_bottom": 70,
@@ -2303,7 +2303,7 @@
"__id__": 135
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 147
@@ -2743,7 +2743,7 @@
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": true,
"_enableOutline": false,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,

View File

@@ -56,22 +56,8 @@ export class SingletonModuleComp extends ecs.Comp {
sk_info:any = []
monsters_dead:any = []
heros_dead:any = []
hero_pos:any=[
{x:-320,y:BoxSet.GAME_LINE},
{x:-320,y:BoxSet.GAME_LINE},
{x:-320,y:BoxSet.GAME_LINE},
{x:-320,y:BoxSet.GAME_LINE},
{x:-320,y:BoxSet.GAME_LINE},
{x:-320,y:BoxSet.GAME_LINE},
]
enemy_pos:any =[
{x:320,y:BoxSet.GAME_LINE},
{x:320,y:BoxSet.GAME_LINE},
{x:320,y:BoxSet.GAME_LINE},
{x:320,y:BoxSet.GAME_LINE},
{x:320,y:BoxSet.GAME_LINE},
{x:320,y:BoxSet.GAME_LINE},
]
hero_pos:any=[]
enemy_pos:any =[]
vm_data: any = {
name : "纸片精灵大乱斗",
game_over:false,
@@ -81,10 +67,9 @@ export class SingletonModuleComp extends ecs.Comp {
mission:{
play:false,
pause:false,
refresh_timer:3,
mission_lv:1,
boss_cd:10,
bboss_cd:10,
is_victory:false,
is_defeat:false,
lv:1,
victory:0,
once:6, //每波刷新怪物数量
total:1, //总怪物数
@@ -96,26 +81,7 @@ export class SingletonModuleComp extends ecs.Comp {
mb_exp:0, //敌方远程经验石
mc_exp:0, //敌方辅助经验石
md_exp:0, //敌方特殊经验石
m_less:0,
m_alive:120,
g_level:1,
g_time:0,
reward:20, //怪物死亡奖励数量
reward_num:0, //怪物死亡数
coin:200,
coin_add:1,
coin_reward_add:1,
normal_cost:10,
better_cost:20,
best_cost:30,
enhancement_cost:100,
normal_lv:1,
better_lv:1,
best_lv:1,
t_damge:0,
t_dps:0,
h_dps:0,
m_dps:0,
reward_gold:0,
reward_exp:0,
hero:{
@@ -130,6 +96,7 @@ export class SingletonModuleComp extends ecs.Comp {
}
},
role:{
fight_heros:[9001,9001],
gold:9999999,
gems:0,
energy:0,

View File

@@ -1,4 +1,4 @@
export const MissionNum = [1]
export const MonsetList = {
1:{
1:[9001],
@@ -11,46 +11,13 @@ export const BossList = {
}
}
export const MissionNum = 3 //对应关卡数MissionSet 的索引
export const MissionSet = [
[9001],
[9001],
[9001],
]
export const MissionSet = {
1:{
lv1_num:10,
lv2_num:10,
lv3_num:10,
lv4_num:10,
lv5_num:10,
lv1_skill_num:10,
lv2_skill_num:10,
lv3_skill_num:10,
lv4_skill_num:10,
lv5_skill_num:10,
},
2:{
lv1_num:10,
lv2_num:10,
lv3_num:10,
lv4_num:10,
lv5_num:10,
lv1_skill_num:10,
lv2_skill_num:10,
lv3_skill_num:10,
lv4_skill_num:10,
lv5_skill_num:10,
},
3:{
lv1_num:10,
lv2_num:10,
lv3_num:10,
lv4_num:10,
lv5_num:10,
lv1_skill_num:10,
lv2_skill_num:10,
lv3_skill_num:10,
lv4_skill_num:10,
lv5_skill_num:10,
}
}
export const MissionReward = {
1:[1001,1002,1003,1004,1005],

View File

@@ -2,7 +2,7 @@
export const HeroInfo = {
9001: {
uuid: 9001, path: "k1", type: 1, lv: 1,name: "白衣骑士", wp:1001,arm:2001,ring:3001,shoes:4001,
aep:1,uaep:1,dep:10,edep:1, ap: 20, ap_up:0.1, hp: 100, hp_up:0.1,def:10,def_up:0.1,dis: 100, a_cd: 1, pw: 0, pwm: 15,pws: 1,
aep:1,uaep:1,dep:10,edep:1, ap: 20, ap_up:0.1, hp: 200, hp_up:0.1,def:10,def_up:0.1,dis: 100, a_cd: 1, pw: 0, pwm: 15,pws: 1,
vun:0,crit:20,crit_add:0,dodge:0, sk1: 9001, sk2: 2002, sk3: 9003, sk4: 9004, sk5: 9005, sk6: 9006,
atktype: 1,akr:10,uar:10,dgr:10,crr:10,akc:1,uac:1,dgc:1,crc:1, speed: 100,
},
@@ -21,8 +21,8 @@ export const MonSet = {
}
export const HeroSet = {
StartPos:{
1: -200,
2: -250,
1: -300,
2: -300,
3: -300,
}

View File

@@ -42,7 +42,7 @@ export class Hero extends ecs.Entity {
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,index:number=-1,is_hero:boolean=true) {
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,is_hero:boolean=true) {
let box_group= 0
if (is_hero) {
@@ -63,11 +63,11 @@ export class Hero extends ecs.Entity {
node.parent = scene.entityLayer!.node!
node.setPosition(pos)
this.hero_init(uuid,node,index,scale,box_group)
this.hero_init(uuid,node,scale,box_group)
oops.message.dispatchEvent("hero_load",this)
}
hero_init(uuid:number=1001,node:Node,index:number=-1,scale:number=1,box_group=BoxSet.HERO){
hero_init(uuid:number=1001,node:Node,scale:number=1,box_group=BoxSet.HERO){
var hv = node.getComponent(HeroViewComp)!;
// console.log("hero_init",buff)
let HInf= smc.heros[uuid] // 角色数据

View File

@@ -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 ){
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()){
}
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;
}
}
// 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 != 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(!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) {
let pos =v3(this.scale*-9999,this.node.position.y,this.node.position.z)
this.node.setPosition(pos)
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();

View File

@@ -1,4 +1,4 @@
import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,UITransform,v3, Vec3 } from "cc";
import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,tween,UITransform,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 { smc } from "../common/SingletonModuleComp";
@@ -20,7 +20,7 @@ import { Hero } from "../hero/Hero";
import { HeroSet } from "../common/config/heroSet";
import { Boss } from "../Boss/Boss";
import { MonModelComp } from "../mon/MonModelComp";
import { BossList, MissionNum, MonsetList } from "../common/config/MissionSet";
import { BossList, MissionNum, MissionSet, MonsetList } from "../common/config/MissionSet";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { HCard } from "./HCard";
import { HCardComp } from "./HCardComp";
@@ -32,32 +32,14 @@ const { ccclass, property } = _decorator;
@ccclass('MissionComp')
@ecs.register('Mission', false)
export class MissionComp extends CCComp {
max_count: number = 99 ; //最大波次
cur_count: number = 1; //波次
boss_count: number = 10; //boss波次间隔
monster_level:number = 1; //怪物池等级
max_monster_level:number = 4; //最高怪物次等级
min_monster_num:number = 1; ///最小每次刷新怪物数量
max_monster_num:number = 1; //最大每次刷新怪物数量
refresh_timer: Timer = new Timer(5); // 刷新怪物定时器
refresh_cd: Timer = new Timer(0.5);
mission_up_timer: Timer = new Timer(30); //波次增加
boss_timer: Timer = new Timer(10);
boss_num:number = 1;
cur_mission:number = 1; //当前关卡方案
mission_list:any = []
boss_list:any = []
setp_timer: Timer = new Timer(0.3);
mon_list:any = []
call_hero_timer: Timer = new Timer(0.3);
target_timer: Timer = new Timer(0.1);
setp_num:number = smc.vm_data.mission.once;
total:number = 0;
hero_total:number = 0;
reward:number = 0;
reward_num:number = 0;
game_over:boolean = false;
start_ys:any[] = [0,70,-70];
mon_index:number = 0
fight_start:boolean = false;
msk:any={
on :false,
uuid:1001,
@@ -81,26 +63,10 @@ export class MissionComp extends CCComp {
if(!smc.vm_data.mission.play||smc.vm_data.pause){
return
}
if(this.setp_timer.update(dt)){
if(this.total<=0) return
this.monster_refresh()
}
if(this.call_hero_timer.update(dt)){
if(this.hero_total <= 0) return
this.heros_call()
}
if(this.boss_timer.update(dt)){
if(this.boss_num <=0 ) return
// this.load_boss()
}
this.is_reward()
if (this.refresh_timer.update(dt)) {
this.setp_num=smc.vm_data.mission.once
}
if (this.mission_up_timer.update(dt)) {
// 刷新怪物定时器
this.cur_count += 1;
if(this.fight_start){
this.check_mon_num()
}
this.do_reward()
this.count_hero_pos()
this.count_mon_pos()
this.check_exp()
@@ -112,23 +78,19 @@ export class MissionComp extends CCComp {
}
mission_start(){
/* todo 关卡设定完善*/
this.total=smc.vm_data.mission.m_less=smc.vm_data.mission.m_alive=smc.vm_data.mission.total;
this.hero_total=2
let num =RandomManager.instance.getRandomByObjectList(MissionNum,1)
this.cur_mission = num[0]
this.mission_list = MonsetList[this.cur_mission]
this.boss_list = BossList[this.cur_mission]
// console.log("当前关卡方案",this.cur_mission,this.mission_list)
this.refresh_timer= new Timer(smc.vm_data.mission.refresh_timer);
this.boss_num=1
this.boss_timer = new Timer(smc.vm_data.mission.boss_cd)
let mon_set=RandomManager.instance.getRandomByObjectList(MissionSet,1)
this.mon_list=mon_set[0]
console.log("mission_start:",this.mon_list)
//局内数据初始化
smc.vm_data.mission.a_exp=0 //近战经验石
smc.vm_data.mission.b_exp=0 //远程经验石
smc.vm_data.mission.c_exp=0 //辅助经验石
smc.vm_data.mission.ma_exp=0 //敌方近战经验
smc.vm_data.mission.mb_exp=0 //敌方远程经验
smc.vm_data.mission.mc_exp=0 //敌方辅助经验
this.fight_start=false
smc.vm_data.mission.is_victory=false
smc.vm_data.mission.is_defeat=false
smc.vm_data.mission.a_exp=0 //近战经验
smc.vm_data.mission.b_exp=0 //远程经验
smc.vm_data.mission.c_exp=0 //辅助经验
smc.vm_data.mission.ma_exp=0 //敌方近战经验
smc.vm_data.mission.mb_exp=0 //敌方远程经验
smc.vm_data.mission.mc_exp=0 //敌方辅助经验
this.msk={ on :false, uuid:1001,type:1,lv: 1}
this.mmsk={ on :false, uuid:1001,type:1,lv: 1}
this.node.getChildByName("exp").getChildByName("a_exp").active = true
@@ -137,7 +99,54 @@ export class MissionComp extends CCComp {
this.node.getChildByName("mexp").getChildByName("a_exp").active = true
this.node.getChildByName("mexp").getChildByName("b_exp").active = true
this.node.getChildByName("mexp").getChildByName("c_exp").active = true
this.mon_refresh()
this.heros_call()
}
mission_end(){
smc.vm_data.mission.play=false
let heros:any= this.get_heros();;
let monsters:any= this.get_mons();
let hcards:any= ecs.query(ecs.allOf(HCardComp));
let mska:any= ecs.query(ecs.allOf(MSkillComp));
for(let i=0;i<mska.length;i++){
mska[i].MSkillComp.reset()
mska[i].MSkillComp.ent.destroy()
}
// let hcns=this.node.getChildByName("hcards")
// for(let i=0;i<hcns.children.length;i++){
// hcns.children[i].destroy()
// }
for(let i=0;i<heros.length;i++){
heros[i].HeroView.reset()
heros[i].HeroView.ent.destroy()
}
for(let i=0;i<hcards.length;i++){
hcards[i].HCardComp.reset()
hcards[i].HCardComp.ent.destroy()
}
for(let i=0;i<monsters.length;i++){
monsters[i].HeroView.reset()
monsters[i].HeroView.ent.destroy()
}
}
exp_move(ap: number,bp: number,cp: number){
let a_pos=v3(ap,this.node.getChildByName("exp").getChildByName("a_exp").position.y)
let b_pos=v3(bp,this.node.getChildByName("exp").getChildByName("b_exp").position.y)
let c_pos=v3(cp,this.node.getChildByName("exp").getChildByName("c_exp").position.y)
tween(this.node.getChildByName("exp").getChildByName("a_exp")).to(0.5,{position:a_pos}).start()
tween(this.node.getChildByName("exp").getChildByName("b_exp")).to(0.5,{position:b_pos}).start()
tween(this.node.getChildByName("exp").getChildByName("c_exp")).to(0.5,{position:c_pos}).start()
}
mexp_move(ap: number,bp: number,cp: number){
let a_pos=v3(ap,this.node.getChildByName("mexp").getChildByName("a_exp").position.y)
let b_pos=v3(bp,this.node.getChildByName("mexp").getChildByName("b_exp").position.y)
let c_pos=v3(cp,this.node.getChildByName("mexp").getChildByName("c_exp").position.y)
tween(this.node.getChildByName("mexp").getChildByName("a_exp")).to(0.5,{position:a_pos}).start()
tween(this.node.getChildByName("mexp").getChildByName("b_exp")).to(0.5,{position:b_pos}).start()
tween(this.node.getChildByName("mexp").getChildByName("c_exp")).to(0.5,{position:c_pos}).start()
}
check_exp(){
if(!this.msk.on){
@@ -145,22 +154,19 @@ export class MissionComp extends CCComp {
this.msk.type = 1
this.msk.on = true
this.select_msk(1)
this.node.getChildByName("exp").getChildByName("b_exp").active = false
this.node.getChildByName("exp").getChildByName("c_exp").active = false
this.exp_move(30,-100,-100)
}
if(smc.vm_data.mission.b_exp >= MSkillset.confirm_exp){
this.msk.type = 2
this.msk.on = true
this.select_msk(2)
this.node.getChildByName("exp").getChildByName("a_exp").active = false
this.node.getChildByName("exp").getChildByName("c_exp").active = false
this.exp_move(-100,30,-100)
}
if(smc.vm_data.mission.c_exp >= MSkillset.confirm_exp){
this.msk.type = 3
this.msk.on = true
this.select_msk(3)
this.node.getChildByName("exp").getChildByName("a_exp").active = false
this.node.getChildByName("exp").getChildByName("b_exp").active = false
this.exp_move(-100,-100,30)
}
}else{
switch (this.msk.type){
@@ -184,7 +190,6 @@ export class MissionComp extends CCComp {
break;
}
}
}
check_m_exp(){
if(!this.mmsk.on){
@@ -192,22 +197,19 @@ export class MissionComp extends CCComp {
this.mmsk.type = 1
this.mmsk.on = true
this.select_mmsk(1)
this.node.getChildByName("mexp").getChildByName("b_exp").active = false
this.node.getChildByName("mexp").getChildByName("c_exp").active = false
this.mexp_move(-30,100,100)
}
if(smc.vm_data.mission.mb_exp >= MSkillset.confirm_exp){
this.mmsk.type = 2
this.mmsk.on = true
this.select_mmsk(2)
this.node.getChildByName("mexp").getChildByName("a_exp").active = false
this.node.getChildByName("mexp").getChildByName("c_exp").active = false
this.mexp_move(100,-30,100)
}
if(smc.vm_data.mission.mc_exp >= MSkillset.confirm_exp){
this.mmsk.type = 3
this.mmsk.on = true
this.select_mmsk(3)
this.node.getChildByName("mexp").getChildByName("a_exp").active = false
this.node.getChildByName("mexp").getChildByName("b_exp").active = false
this.mexp_move(100,100,-30)
}
}else{
switch (this.mmsk.type){
@@ -249,129 +251,94 @@ export class MissionComp extends CCComp {
let sk:any=RandomManager.instance.getRandomByObjectList(MSlist[type],1)
this.mmsk.uuid=sk[0]
let mskill=ecs.getEntity<MSkill>(MSkill)
mskill.load(BoxSet.MONSTER,this.msk.uuid)
}
mission_end(){
smc.vm_data.mission.play=false
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
let monsters:any= ecs.query(ecs.allOf(MonModelComp));
let hcards:any= ecs.query(ecs.allOf(HCardComp));
let mska:any= ecs.query(ecs.allOf(MSkillComp));
for(let i=0;i<mska.length;i++){
mska[i].MSkillComp.reset()
mska[i].MSkillComp.ent.destroy()
}
// let hcns=this.node.getChildByName("hcards")
// for(let i=0;i<hcns.children.length;i++){
// hcns.children[i].destroy()
// }
for(let i=0;i<heros.length;i++){
heros[i].HeroView.reset()
heros[i].HeroView.ent.destroy()
}
for(let i=0;i<hcards.length;i++){
hcards[i].HCardComp.reset()
hcards[i].HCardComp.ent.destroy()
}
for(let i=0;i<monsters.length;i++){
monsters[i].HeroView.reset()
monsters[i].HeroView.ent.destroy()
}
}
monster_refresh(){
if (this.setp_num <= 0){
return
}
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
this.addMonster(m[0])
this.mon_index += 1
if(this.mon_index>2){
this.mon_index = 0
}
smc.vm_data.mission.m_less=this.total -= 1
// this.setp_num -= 1
}
is_reward(){
if(smc.vm_data.mission.reward_num < smc.vm_data.mission.reward) return
// this.do_reward()
smc.vm_data.mission.reward_num = 0
mskill.load(BoxSet.MONSTER,this.mmsk.uuid)
}
do_reward(){
console.log("do_reward")
oops.message.dispatchEvent("do_reward");
}
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) smc.vm_data.mission.is_victory = true
if (!h_alive) smc.vm_data.mission.is_defeat = true
console.log("check_end m_alive: "+m_alive+" h_alive:"+h_alive+" victory:"+smc.vm_data.mission.is_victory+" defeat:"+smc.vm_data.mission.is_defeat)
}
get_mons(){
return ecs.query(ecs.allOf(MonModelComp));
}
get_heros(){
return ecs.query(ecs.allOf(HeroModelComp))
}
count_mon_pos(){
let monsters:any= ecs.query(ecs.allOf(MonModelComp));
let monsters:any= this.get_mons()
for(let i=0;i<monsters.length;i++){
if(monsters[i].HeroView == undefined) return
let mon:any = monsters[i].HeroView.node.position
smc.enemy_pos[i].x= mon.x
smc.enemy_pos[i]= mon
}
}
count_hero_pos(){
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
let heros:any= this.get_heros()
for(let i=0;i<heros.length;i++){
if(heros[i].HeroView == undefined) return
let ho:any = heros[i].HeroView.node.position
smc.hero_pos[i].x= ho.x
smc.hero_pos[i]= ho
}
}
mon_refresh(){
let mons=this.mon_list
for(let i=0;i<mons.length;i++){
this.addMonster(mons[i],i)
}
}
heros_call(){
let hero:any =RandomManager.instance.getRandomByObjectList(smc.cards, 1);
this.addHero(hero[0].uuid)
this.hero_total -= 1
if(this.hero_total <= 0){
console.log("heros_call")
this.hcard_call()
let heros=smc.vm_data.role.fight_heros
for(let i=0;i<heros.length;i++){
this.addHero(heros[i],i)
}
this.hcard_call()
}
hcard_call(){
let node =this.node.getChildByName("hcards")
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
let heros:any= this.get_heros();
for(let i=0;i<heros.length;i++){
let hcard = ecs.getEntity<HCard>(HCard)
console.log("hcard:",hcard)
// console.log("hcard:",hcard)
hcard.load(1001,i,node)
}
this.fight_start= true
}
/** 添加玩家 */
private addHero(uuid:number=1001) {
private addHero(uuid:number=1001,i:number=0) {
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
let pos:Vec3 = v3(HeroSet.StartPos[smc.heros[uuid].type],BoxSet.GAME_LINE);
console.log("addHero:",pos)
let pos:Vec3 = v3(HeroSet.StartPos[smc.heros[uuid].type]-i*15,BoxSet.GAME_LINE);
// console.log("addHero:",pos)
hero.load(pos,scale,uuid);
}
private addMonster(uuid:number=1001) {
private addMonster(uuid:number=1001,i:number=0) {
let monster = ecs.getEntity<Hero>(Hero);
let scale = -1
let index = -1
let pos:Vec3 = v3(-1*HeroSet.StartPos[smc.heros[uuid].type],BoxSet.GAME_LINE);
let pos:Vec3 = v3(-1*HeroSet.StartPos[smc.heros[uuid].type]+i*15,BoxSet.GAME_LINE);
console.log("addMonster:",pos)
monster.load(pos,scale,uuid,index,false);
monster.load(pos,scale,uuid,false);
}
load_boss(){
let bs:any = RandomManager.instance.getRandomByObjectList(this.boss_list[this.monster_level],1)
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(260,BoxSet.GAME_LINE)
let layer = scene.entityLayer!.node!
let b = ecs.getEntity<Boss>(Boss);
let scale = -1
b.load(pos,scale,bs[0],layer);
this.boss_num -= 1
}
/** 视图层逻辑代码分离演示 */

View File

@@ -28,8 +28,10 @@ export class MSkillComp extends CCComp {
console.log("MSkillComp start");
}
protected update(dt: number): void {
if(!smc.vm_data.mission.play||smc.vm_data.pause||smc.vm_data.mission.is_victory||smc.vm_data.mission.is_defeat){
return
}
this.check_cd(dt)
}
check_cd(dt:number){
this.cdt-=dt