dd
This commit is contained in:
@@ -6,6 +6,7 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
import { RewardSet } from "../common/config/RewardSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -27,7 +28,17 @@ export class CardControllerComp extends CCComp {
|
||||
5:{uuid:1105,type:1,lv:0,cost:0,alive:false},
|
||||
6:{uuid:1106,type:1,lv:0,cost:0,alive:false},
|
||||
}
|
||||
rewards:any = {
|
||||
1:{uuid: 5001,path: "5001",type: 1,lv: 1,name: "",info:"",atk:0,hp:0,atk_cd:0,},
|
||||
2:{uuid: 5001,path: "5001",type: 1,lv: 1,name: "",info:"",atk:0,hp:0,atk_cd:0,},
|
||||
3:{uuid: 5001,path: "5001",type: 1,lv: 1,name: "",info:"",atk:0,hp:0,atk_cd:0,},
|
||||
}
|
||||
rewards_set:any = []
|
||||
reward_lv = 0;
|
||||
|
||||
protected onLoad(): void {
|
||||
oops.message.on("do_reward", this.do_reward, this);
|
||||
|
||||
let card1 = this.node.getChildByName("cards").getChildByName("card1");
|
||||
let card2 = this.node.getChildByName("cards").getChildByName("card2");
|
||||
let card3 = this.node.getChildByName("cards").getChildByName("card3");
|
||||
@@ -337,14 +348,83 @@ export class CardControllerComp extends CCComp {
|
||||
// }
|
||||
this.remove_card(index)
|
||||
}
|
||||
|
||||
do_reward(){
|
||||
smc.vm_data.game_pause = true;
|
||||
this.reward_lv+=1
|
||||
this.rewards_set=RewardSet[this.reward_lv]
|
||||
let i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 1)
|
||||
console.log("rewards:",i)
|
||||
this.rewards[1]=this.rewards_set[i]
|
||||
this.rewards_set.splice(i,1)
|
||||
i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 1)
|
||||
console.log("rewards:",i)
|
||||
this.rewards[2]=this.rewards_set[i]
|
||||
this.rewards_set.splice(i,1)
|
||||
i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 1)
|
||||
console.log("rewards:",i)
|
||||
this.rewards[3]=this.rewards_set[i]
|
||||
this.rewards_set=[]
|
||||
console.log("rewards:",this.rewards)
|
||||
let re1=this.node.getChildByName('rewards').getChildByName('reward1')
|
||||
let re2=this.node.getChildByName('rewards').getChildByName('reward2')
|
||||
let re3=this.node.getChildByName('rewards').getChildByName('reward3')
|
||||
|
||||
re1.getChildByName('name').getComponent(Label).string=this.rewards[1].name
|
||||
re2.getChildByName('name').getComponent(Label).string=this.rewards[2].name
|
||||
re3.getChildByName('name').getComponent(Label).string=this.rewards[3].name
|
||||
|
||||
re1.getChildByName('info').getComponent(Label).string=this.rewards[1].info
|
||||
re2.getChildByName('info').getComponent(Label).string=this.rewards[2].info
|
||||
re3.getChildByName('info').getComponent(Label).string=this.rewards[3].info
|
||||
|
||||
resources.load("gui/rewards", SpriteAtlas, (err: any, atlas) => {
|
||||
let pathName: string = this.rewards[1].path;
|
||||
let node=re1.getChildByName('icon')
|
||||
node.getComponent(Sprite).spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
pathName=this.rewards[2].path;
|
||||
node=re2.getChildByName('icon')
|
||||
node.getComponent(Sprite).spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
pathName=this.rewards[3].path;
|
||||
node=re3.getChildByName('icon')
|
||||
node.getComponent(Sprite).spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
})
|
||||
|
||||
|
||||
this.node.getChildByName('rewards').active = true;
|
||||
}
|
||||
colse_reward(){
|
||||
this.node.getChildByName('rewards').active = false;
|
||||
smc.vm_data.game_pause = false;
|
||||
}
|
||||
do_reward_1(value:number=1){
|
||||
this.colse_reward()
|
||||
}
|
||||
do_reward_2(value:number=2){
|
||||
this.colse_reward()
|
||||
}
|
||||
do_reward_3(value:number=3){
|
||||
this.colse_reward()
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(smc.vm_data.game_over||smc.vm_data.game_pause){
|
||||
return
|
||||
}
|
||||
this.shuaxin(dt)
|
||||
// this.gold_add(dt)
|
||||
|
||||
if(this.in_touch){
|
||||
this.touch_time+=dt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gold_add(dt: number) {
|
||||
smc.vm_data.gold.time += dt;
|
||||
if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) {
|
||||
smc.vm_data.gold.min += 1;
|
||||
smc.vm_data.gold.time = 0;
|
||||
}
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
@@ -14,6 +14,7 @@ import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
import { Mon } from "../mon/Mon";
|
||||
import { MonModelComp } from "../mon/MonModelComp";
|
||||
import { Boss} from "../Boss/Boss";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -28,21 +29,23 @@ export class MapMonsterComp extends CCComp {
|
||||
max_monster_level:number = 4; //最高怪物次等级
|
||||
min_monster_num:number = 1; ///最小每次刷新怪物数量
|
||||
max_monster_num:number = 1; //最大每次刷新怪物数量
|
||||
refresh_timer: Timer = new Timer(10); // 刷新怪物定时器
|
||||
refresh_timer: Timer = new Timer(5); // 刷新怪物定时器
|
||||
refresh_cd: Timer = new Timer(0.5);
|
||||
mission_up_timer: Timer = new Timer(30); //波次增加
|
||||
cur_mission:number = 1; //当前关卡方案
|
||||
mission_list:any = []
|
||||
boss_list:any = []
|
||||
setp_timer: Timer = new Timer(0.3);
|
||||
setp_timer: Timer = new Timer(0.2);
|
||||
target_timer: Timer = new Timer(0.1);
|
||||
setp_num:number = 6;
|
||||
setp_num:number = smc.vm_data.mission.once;
|
||||
total:number = smc.vm_data.mission.total;
|
||||
reward:number = 0;
|
||||
reward_num:number = 0;
|
||||
game_over:boolean = false;
|
||||
start_ys:any[] = [70,0,-70];
|
||||
hero_start_ys:any[] = [35,-35];
|
||||
mon_index:number = 0
|
||||
hero_index:number = 0
|
||||
|
||||
|
||||
@property(Node)
|
||||
start_p: Node = null;
|
||||
@@ -64,7 +67,8 @@ export class MapMonsterComp extends CCComp {
|
||||
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.gold.cd*5);
|
||||
this.refresh_timer= new Timer(smc.vm_data.shuaxin.max);
|
||||
smc.vm_data.mission.m_less=this.total
|
||||
this.monster_refresh()
|
||||
this.load_role()
|
||||
this.load_boss()
|
||||
@@ -72,14 +76,16 @@ export class MapMonsterComp extends CCComp {
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
if(smc.vm_data.game_over){
|
||||
if(smc.vm_data.game_over||smc.vm_data.game_pause){
|
||||
return
|
||||
}
|
||||
if(this.setp_timer.update(dt)){
|
||||
if(this.total<=0) return
|
||||
this.monster_refresh()
|
||||
}
|
||||
this.is_reward()
|
||||
if (this.refresh_timer.update(dt)) {
|
||||
this.setp_num = 6
|
||||
this.setp_num=smc.vm_data.mission.once
|
||||
}
|
||||
if (this.mission_up_timer.update(dt)) {
|
||||
// 刷新怪物定时器
|
||||
@@ -87,10 +93,48 @@ export class MapMonsterComp extends CCComp {
|
||||
}
|
||||
this.count_hero_pos()
|
||||
this.count_mon_pos()
|
||||
|
||||
// if (this.game_timer.update(dt)) {
|
||||
// smc.vm_data.game.g_time += 1;
|
||||
// }
|
||||
// this.shuaxin(dt)
|
||||
}
|
||||
monster_refresh(){
|
||||
if (this.setp_num <= 0){
|
||||
return
|
||||
}
|
||||
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
|
||||
var scene = smc.map.MapView.scene;
|
||||
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+this.start_ys[this.mon_index])
|
||||
let monster_layer = scene.entityLayer!.node!
|
||||
this.addMonster(m[0],monster_layer,pos)
|
||||
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
|
||||
}
|
||||
do_reward(){
|
||||
console.log("do_reward")
|
||||
oops.message.dispatchEvent("do_reward");
|
||||
}
|
||||
private addMonster(uuid:number=1001,layer:any,pos:Vec3=v3(0,0,0)) {
|
||||
let monster = ecs.getEntity<Mon>(Mon);
|
||||
let scale = -1
|
||||
monster.load(pos,scale,uuid,layer);
|
||||
}
|
||||
|
||||
private on_other_add_monster(event: string, args: any) {
|
||||
var scene = smc.map.MapView.scene;
|
||||
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
|
||||
let monster_layer = scene.entityLayer!.node!
|
||||
this.addMonster(args.uuid,monster_layer,pos)
|
||||
}
|
||||
set_start_point(){
|
||||
this.start_p.setPosition(-240,BoxSet.GAME_LINE+this.start_ys[this.hero_index]+30,0)
|
||||
@@ -103,53 +147,48 @@ export class MapMonsterComp extends CCComp {
|
||||
}
|
||||
count_mon_pos(){
|
||||
let monsters:any= ecs.query(ecs.allOf(MonModelComp));
|
||||
let x = 320
|
||||
let x1 = 320
|
||||
let x2 = 320
|
||||
smc.enemy_pos[0].x=320
|
||||
smc.enemy_pos[1].x=320
|
||||
smc.enemy_pos[2].x=320
|
||||
for(let i=0;i<monsters.length;i++){
|
||||
if(monsters[i].MonView == undefined) return
|
||||
let mon:any = monsters[i].MonView.node.position
|
||||
if(mon.x < x&&mon.y == smc.enemy_pos[0].y){
|
||||
x = mon.x
|
||||
if(mon.x < smc.enemy_pos[0].x&&mon.y == smc.enemy_pos[0].y){
|
||||
smc.enemy_pos[0].x = mon.x
|
||||
continue
|
||||
}
|
||||
if(mon.x < x1&&mon.y == smc.enemy_pos[1].y){
|
||||
x1 = mon.x
|
||||
if(mon.x < smc.enemy_pos[1].x&&mon.y == smc.enemy_pos[1].y){
|
||||
smc.enemy_pos[1].x = mon.x
|
||||
continue
|
||||
}
|
||||
if(mon.x < x2&&mon.y == smc.enemy_pos[2].y){
|
||||
x2 = mon.x
|
||||
if(mon.x < smc.enemy_pos[2].x&&mon.y == smc.enemy_pos[2].y){
|
||||
smc.enemy_pos[2].x = mon.x
|
||||
continue
|
||||
}
|
||||
}
|
||||
smc.enemy_pos[0].x=x
|
||||
smc.enemy_pos[1].x=x1
|
||||
smc.enemy_pos[2].x=x2
|
||||
}
|
||||
count_hero_pos(){
|
||||
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
|
||||
let x = -320
|
||||
let x1 = -320
|
||||
let x2 = -320
|
||||
smc.hero_pos[0].x=-320
|
||||
smc.hero_pos[1].x=-320
|
||||
smc.hero_pos[2].x=-320
|
||||
for(let i=0;i<heros.length;i++){
|
||||
if(heros[i].HeroView == undefined) return
|
||||
let ho:any = heros[i].HeroView.node.position
|
||||
if(ho.x > x&&ho.y == smc.hero_pos[0].y){
|
||||
x = ho.x
|
||||
if(ho.x > smc.hero_pos[0].x&&ho.y == smc.hero_pos[0].y){
|
||||
smc.hero_pos[0].x = ho.x
|
||||
continue
|
||||
}
|
||||
if(ho.x > x1&&ho.y == smc.hero_pos[1].y ){
|
||||
x1 = ho.x
|
||||
if(ho.x > smc.hero_pos[0].x&&ho.y == smc.hero_pos[1].y ){
|
||||
smc.hero_pos[1].x = ho.x
|
||||
continue
|
||||
}
|
||||
if(ho.x > x2&&ho.y == smc.hero_pos[2].y){
|
||||
x2 = ho.x
|
||||
if(ho.x > smc.hero_pos[0].x&&ho.y == smc.hero_pos[2].y){
|
||||
smc.hero_pos[2].x = ho.x
|
||||
continue
|
||||
}
|
||||
}
|
||||
smc.hero_pos[0].x=x
|
||||
smc.hero_pos[1].x=x1
|
||||
smc.hero_pos[2].x=x2
|
||||
|
||||
}
|
||||
load_role(){
|
||||
let role = ecs.getEntity<Role>(Role);
|
||||
@@ -175,33 +214,7 @@ export class MapMonsterComp extends CCComp {
|
||||
}
|
||||
this.set_start_point()
|
||||
}
|
||||
monster_refresh(){
|
||||
if (this.setp_num <= 0){
|
||||
return
|
||||
}
|
||||
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
|
||||
var scene = smc.map.MapView.scene;
|
||||
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+this.start_ys[this.mon_index])
|
||||
let monster_layer = scene.entityLayer!.node!
|
||||
this.addMonster(m[0],monster_layer,pos)
|
||||
this.mon_index += 1
|
||||
if(this.mon_index>2){
|
||||
this.mon_index = 0
|
||||
}
|
||||
this.setp_num -= 1
|
||||
}
|
||||
private addMonster(uuid:number=1001,layer:any,pos:Vec3=v3(0,0,0)) {
|
||||
let monster = ecs.getEntity<Mon>(Mon);
|
||||
let scale = -1
|
||||
monster.load(pos,scale,uuid,layer);
|
||||
}
|
||||
|
||||
private on_other_add_monster(event: string, args: any) {
|
||||
var scene = smc.map.MapView.scene;
|
||||
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
|
||||
let monster_layer = scene.entityLayer!.node!
|
||||
this.addMonster(args.uuid,monster_layer,pos)
|
||||
}
|
||||
|
||||
load_boss(){
|
||||
let bs:any = RandomManager.instance.getRandomByObjectList(this.boss_list[this.monster_level],1)
|
||||
var scene = smc.map.MapView.scene;
|
||||
|
||||
38
assets/script/game/map/RewardsComp.ts
Normal file
38
assets/script/game/map/RewardsComp.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { _decorator } 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('RewardsComp')
|
||||
@ecs.register('Rewards', false)
|
||||
export class RewardsComp extends CCComp {
|
||||
reward_lv = 1;
|
||||
onLoad(){
|
||||
// 监听全局事件
|
||||
oops.message.on("do_reward", this.do_reward, this);
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
}
|
||||
do_reward(){
|
||||
this.node.active = true;
|
||||
}
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
9
assets/script/game/map/RewardsComp.ts.meta
Normal file
9
assets/script/game/map/RewardsComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "df8725c7-a5e8-4dfd-b357-59fb88b68283",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -29,8 +29,6 @@ export class MapViewComp extends CCComp {
|
||||
|
||||
start() {
|
||||
this.scene = this.getComponent(MapViewScene);
|
||||
this.load_data()
|
||||
// this.load_role()
|
||||
}
|
||||
|
||||
load_data(){
|
||||
@@ -38,20 +36,10 @@ export class MapViewComp extends CCComp {
|
||||
// console.log("heros",heros)
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
// if (this.game_timer.update(dt)) {
|
||||
// smc.vm_data.game.g_time += 1;
|
||||
// }
|
||||
// this.shuaxin(dt)
|
||||
// this.gold_add(dt)
|
||||
|
||||
}
|
||||
// 刷新怪物
|
||||
|
||||
gold_add(dt: number) {
|
||||
smc.vm_data.gold.time += dt;
|
||||
if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) {
|
||||
smc.vm_data.gold.min += 1;
|
||||
smc.vm_data.gold.time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user