This commit is contained in:
pan
2024-08-20 18:27:34 +08:00
parent 87a445c225
commit b9edfd7001
17 changed files with 407 additions and 143 deletions

View File

@@ -79,7 +79,7 @@ export class CardControllerComp extends CCComp {
lists.forEach(element => {
let card = ecs.getEntity<HeroCard>(HeroCard);
let pos = v3(x,y)
card.load(pos,element[0],cards_node,1);
card.load(pos,element[0].uuid,cards_node,element[0].type);
x=x+142
});
this.in_load = false;

View File

@@ -0,0 +1,62 @@
import { _decorator ,Vec3,v3} 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 { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { Monster } from "../monster/Monster";
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";
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(){
// 监听全局事件
oops.message.on("do_add_monster", this.on_do_add_monster, this);
}
protected update(dt: number): void {
if (this.monster_refresh_rtimer.update(dt)) {
// 刷新怪物定时器
this.monster_refresh()
}
// 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)
}
}
private addMonster(uuid:number=1101) {
let monster = ecs.getEntity<Monster>(Monster);
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let camp = -1
monster.load(pos,camp,uuid);
smc.monsters.splice(0,1)
}
private on_do_add_monster(event: string, args: any) {
// this.addMonster(args.uuid)
}
/** 视图层逻辑代码分离演示 */
start() {
this.scene = this.getComponent(MapViewScene);
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "c0f2f76a-7c1b-4e8c-a0a3-b201f5a86f7e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,53 @@
import { _decorator ,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";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MapSkillComp')
@ecs.register('MapSkill', false)
export class MapSkillComp extends CCComp {
@property(Prefab)
light: Prefab = null;
onLoad(){
oops.message.on("monster_load", this.doMonsterLoad, this);
oops.message.on("hero_load", this.doHeroLoad, this);
oops.message.on("do_use_skill", this.doSkill, this);
}
doSkill(){
// console.log("doSkill")
}
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);
}
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this);
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b7739951-194b-4d13-8bff-cd7f7a0b3bbf",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -21,24 +21,18 @@ export class MapViewComp extends CCComp {
scene: MapViewScene = null!;
current_map: any;
private game_timer: Timer = new Timer(1);
private monster_refresh_rtimer: Timer = new Timer(3);
private mapLoaded() {
}
async onLoad(){
// 监听全局事件
oops.message.on("do_add_monster", this.on_do_add_monster, this);
oops.message.on("do_add_hero", this.on_do_add_hero, this);
}
private on_do_add_monster(event: string, args: any) {
this.addMonster()
}
/**监听do_add_hero 添加hero,通过uuid */
private on_do_add_hero(event: string, args: any) {
console.log("do_add_hero",args.uuid)
// console.log("do_add_hero",args.uuid)
this.addHero(args.uuid)
}
reset(): void {
@@ -54,22 +48,15 @@ export class MapViewComp extends CCComp {
// console.log("heros",heros)
}
protected update(dt: number): void {
if (this.monster_refresh_rtimer.update(dt)) {
// 刷新怪物定时器
this.monster_refresh()
}
if (this.game_timer.update(dt)) {
smc.vm_data.game.g_time += 1;
}
// if (this.game_timer.update(dt)) {
// smc.vm_data.game.g_time += 1;
// }
// this.shuaxin(dt)
this.gold_add(dt)
}
// 刷新怪物
monster_refresh(){
if(smc.monsters.length > 0 ){
this.addMonster(smc.monsters[0].uuid)
}
}
gold_add(dt: number) {
smc.vm_data.gold.time += dt;
if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) {
@@ -94,13 +81,6 @@ export class MapViewComp extends CCComp {
let camp = 1
hero.load(pos,camp,uuid);
}
private addMonster(uuid:number=1001) {
this.scene.node.active = true
let monster = ecs.getEntity<Monster>(Monster);
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let camp = -1
monster.load(pos,camp,uuid);
smc.monsters.splice(0,1)
}
}

View File

@@ -22,16 +22,20 @@ export default class SkillLayer extends Component {
@property(Prefab)
light: Prefab = null;
onLoad(){
oops.message.on("monster_load", this.onMonsterLoaded, this);
oops.message.on("hero_load", this.onHeroLoaded, this);
oops.message.on("monster_load", this.doMonsterLoad, this);
oops.message.on("hero_load", this.doHeroLoad, this);
oops.message.on("do_use_skill", this.doSkill, this);
}
onMonsterLoaded(){
doSkill(){
// console.log("doSkill")
}
doMonsterLoad(){
// const light = instantiate(this.light);
// light.setPosition(300,-30,0);
// this.node.addChild(light);
}
onHeroLoaded(){
doHeroLoad(){
const light = instantiate(this.light);
light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
this.node.addChild(light);

View File

@@ -1,23 +0,0 @@
import { _decorator, Component, Node, sp } from 'cc';
const { ccclass, property ,} = _decorator;
@ccclass('once')
export class once extends Component {
private spine!: sp.Skeleton;
start() {
}
protected onLoad(): void {
this.spine = this.getComponent(sp.Skeleton)!;
this.spine.setCompleteListener(trackEntry => {
this.node.destroy()
});
}
update(deltaTime: number) {
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"6e0a995d-16c1-4554-8f80-29394f24213b","files":[],"subMetas":{},"userData":{}}