卡牌技能
This commit is contained in:
@@ -7,38 +7,72 @@ import { BoxSet } from "../common/config/BoxSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { MapViewScene } from "./view/MapViewScene";
|
||||
|
||||
import { MissionSet,MissionNum,MonsetList } from "../common/config/MissionSet";
|
||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('MapMonsterComp')
|
||||
@ecs.register('MapMonster', false)
|
||||
export class MapMonsterComp extends CCComp {
|
||||
scene: MapViewScene = null;
|
||||
current_map: any;
|
||||
|
||||
private monster_refresh_rtimer: Timer = new Timer(1);
|
||||
async onLoad(){
|
||||
// scene: MapViewScene = null;
|
||||
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 = 2; ///最小每次刷新怪物数量
|
||||
max_monster_num:number = 2; //最大每次刷新怪物数量
|
||||
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 = []
|
||||
setp_timer: Timer = new Timer(0.5);
|
||||
setp_num:number = 2;
|
||||
onLoad(){
|
||||
// 监听全局事件
|
||||
oops.message.on("do_add_monster", this.on_do_add_monster, this);
|
||||
|
||||
|
||||
}
|
||||
start() {
|
||||
// this.scene = this.getComponent(MapViewScene);
|
||||
let num =RandomManager.instance.getRandomByObjectList(MissionNum,1)
|
||||
this.cur_mission = num[0]
|
||||
this.mission_list = MonsetList[this.cur_mission]
|
||||
console.log("当前关卡方案",this.cur_mission,this.mission_list)
|
||||
this.refresh_timer= new Timer(smc.vm_data.gold.cd);
|
||||
this.monster_refresh()
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if (this.monster_refresh_rtimer.update(dt)) {
|
||||
// 刷新怪物定时器
|
||||
if(this.setp_timer.update(dt)){
|
||||
this.monster_refresh()
|
||||
}
|
||||
if (this.refresh_timer.update(dt)) {
|
||||
this.setp_num = RandomManager.instance.getRandomInt(this.max_monster_num,this.max_monster_level,2)
|
||||
}
|
||||
if (this.mission_up_timer.update(dt)) {
|
||||
// 刷新怪物定时器
|
||||
this.cur_count += 1;
|
||||
}
|
||||
// if (this.game_timer.update(dt)) {
|
||||
// smc.vm_data.game.g_time += 1;
|
||||
// }
|
||||
// this.shuaxin(dt)
|
||||
}
|
||||
monster_refresh(){
|
||||
if(smc.monsters.length > 0 ){
|
||||
this.addMonster(smc.monsters[0].uuid)
|
||||
if (this.setp_num <= 0){
|
||||
return
|
||||
}
|
||||
console.log("当前波数",this.cur_count)
|
||||
console.log("当前怪物池",this.mission_list[this.monster_level])
|
||||
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
|
||||
console.log("刷怪",m)
|
||||
this.addMonster(m[0])
|
||||
this.setp_num -= 1
|
||||
}
|
||||
private addMonster(uuid:number=1101) {
|
||||
|
||||
let monster = ecs.getEntity<Monster>(Monster);
|
||||
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
|
||||
let camp = -1
|
||||
@@ -50,10 +84,7 @@ export class MapMonsterComp extends CCComp {
|
||||
// this.addMonster(args.uuid)
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
this.scene = this.getComponent(MapViewScene);
|
||||
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { _decorator ,Prefab,instantiate,Node} from "cc";
|
||||
import { _decorator ,v3,Prefab,instantiate,Node} 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";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
|
||||
import { MapViewScene } from "./view/MapViewScene";
|
||||
import { CSkill } from "../monster/CSkill";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('MapSkillComp')
|
||||
@ecs.register('MapSkill', false)
|
||||
export class MapSkillComp extends CCComp {
|
||||
// scene: MapViewScene = null;
|
||||
@property(Prefab)
|
||||
light: Prefab = null;
|
||||
onLoad(){
|
||||
@@ -18,19 +20,24 @@ export class MapSkillComp extends CCComp {
|
||||
oops.message.on("do_use_skill", this.doSkill, this);
|
||||
}
|
||||
doSkill(){
|
||||
// console.log("doSkill")
|
||||
this.addSkill();
|
||||
}
|
||||
addSkill(uuid:number=1001){
|
||||
let csk =ecs.getEntity<CSkill>(CSkill);
|
||||
let camp = 1
|
||||
let pos = v3(BoxSet.CSKILL_X*-camp,BoxSet.CSKILL_Y)
|
||||
csk.load(pos,camp,uuid);
|
||||
}
|
||||
doMonsterLoad(){
|
||||
|
||||
// const light = instantiate(this.light);
|
||||
// light.setPosition(300,-30,0);
|
||||
// this.node.addChild(light);
|
||||
}
|
||||
doHeroLoad(){
|
||||
// console.log(this.light)
|
||||
// const light = instantiate(this.light);
|
||||
// light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
|
||||
// this.node.addChild(light);
|
||||
console.log(this.light)
|
||||
const light = instantiate(this.light);
|
||||
light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
|
||||
this.node.addChild(light);
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
|
||||
@@ -25,7 +25,9 @@ export default class EntityLayer extends Component {
|
||||
// this.node.children.sort(this.zIndexSort);
|
||||
}
|
||||
|
||||
|
||||
protected start(): void {
|
||||
console.log("EntityLayer start")
|
||||
}
|
||||
|
||||
public clear() {
|
||||
this.node.children.forEach(n => {
|
||||
|
||||
@@ -36,9 +36,9 @@ export default class SkillLayer extends Component {
|
||||
// this.node.addChild(light);
|
||||
}
|
||||
doHeroLoad(){
|
||||
const light = instantiate(this.light);
|
||||
light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
|
||||
this.node.addChild(light);
|
||||
// const light = instantiate(this.light);
|
||||
// light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
|
||||
// this.node.addChild(light);
|
||||
}
|
||||
update(dt: number) {
|
||||
// this.timer.update(dt)
|
||||
@@ -46,7 +46,9 @@ export default class SkillLayer extends Component {
|
||||
// this.node.children.sort(this.zIndexSort);
|
||||
}
|
||||
|
||||
|
||||
start(){
|
||||
console.log("SkillLayer start")
|
||||
}
|
||||
|
||||
public clear() {
|
||||
this.node.children.forEach(n => {
|
||||
|
||||
Reference in New Issue
Block a user