dd
This commit is contained in:
@@ -8,7 +8,7 @@ import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/mod
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { Initialize } from "../initialize/Initialize";
|
||||
import { GameMap } from "../map/GameMap";
|
||||
import { Role } from "../role/Role";
|
||||
// import { Role } from "../role/Role";
|
||||
// import { data } from "../data/data";
|
||||
/** 游戏模块 */
|
||||
@ecs.register('SingletonModule')
|
||||
@@ -18,7 +18,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
/** 游戏地图 */
|
||||
map: GameMap = null!;
|
||||
/** 游戏主角 */
|
||||
own: Role = null;
|
||||
// own: Role = null;
|
||||
/** 游戏数据 */
|
||||
// data:data = null!;
|
||||
/**怪物数据 数组 */
|
||||
|
||||
@@ -11,7 +11,7 @@ import { CCVMParentComp } from "../../../../../extensions/oops-plugin-framework/
|
||||
import { UIID } from "../../common/config/GameUIConfig";
|
||||
import { smc } from "../../common/SingletonModuleComp";
|
||||
import { GameMap } from "../../map/GameMap";
|
||||
import { Role } from "../../role/Role";
|
||||
// import { Role } from "../../role/Role";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 游戏资源加载 */
|
||||
|
||||
42
assets/script/game/map/CardController.ts
Normal file
42
assets/script/game/map/CardController.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
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 { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('ControllerComp')
|
||||
@ecs.register('Controller', false)
|
||||
export class ControllerComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
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;
|
||||
// }
|
||||
// }
|
||||
shuaxin(dt: number) {
|
||||
smc.vm_data.shuaxin.min += smc.vm_data.shuaxin.speed*dt;
|
||||
if (smc.vm_data.shuaxin.min >= smc.vm_data.shuaxin.max) {
|
||||
smc.vm_data.shuaxin.min = 0;
|
||||
oops.message.dispatchEvent("do_add_hero",this)
|
||||
}
|
||||
}
|
||||
/** 转场 */
|
||||
protected update(dt: number): void {
|
||||
this.shuaxin(dt)
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/map/CardController.ts.meta
Normal file
9
assets/script/game/map/CardController.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "ee99b110-f3d9-44b5-abc0-1d0b18dac6da",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
29
assets/script/game/map/Controller.ts
Normal file
29
assets/script/game/map/Controller.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
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";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('CardControllerComp')
|
||||
@ecs.register('CardController', false)
|
||||
export class CardControllerComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
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(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/map/Controller.ts.meta
Normal file
9
assets/script/game/map/Controller.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7c495718-13bc-4f64-8ecc-27c210626d0a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -27,10 +27,16 @@ export class MapViewComp extends CCComp {
|
||||
private timer: Timer = new Timer(3);
|
||||
onLoad(){
|
||||
// 监听全局事件
|
||||
oops.message.on("monster_load", this.onMonsterLoaded, this);
|
||||
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 onMonsterLoaded(event: string, args: any) {
|
||||
// console.log('on_monster_load');
|
||||
private on_do_add_monster(event: string, args: any) {
|
||||
this.addMonster()
|
||||
}
|
||||
private on_do_add_hero(event: string, args: any) {
|
||||
this.addHero()
|
||||
this.addMonster()
|
||||
|
||||
}
|
||||
reset(): void {
|
||||
|
||||
@@ -44,7 +50,7 @@ export class MapViewComp extends CCComp {
|
||||
/** 转场 */
|
||||
protected update(dt: number): void {
|
||||
|
||||
this.shuaxin(dt)
|
||||
// this.shuaxin(dt)
|
||||
this.gold_add(dt)
|
||||
}
|
||||
|
||||
@@ -65,23 +71,11 @@ export class MapViewComp extends CCComp {
|
||||
smc.vm_data.shuaxin.min += smc.vm_data.shuaxin.speed*dt;
|
||||
if (smc.vm_data.shuaxin.min >= smc.vm_data.shuaxin.max) {
|
||||
smc.vm_data.shuaxin.min = 0;
|
||||
this.addHero();
|
||||
}
|
||||
}
|
||||
/** 添加玩家 */
|
||||
private addHero() {
|
||||
this.scene.node.active = true
|
||||
if (smc.monsters.length>0){
|
||||
let monster = ecs.getEntity<Monster>(Monster);
|
||||
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
|
||||
let speed =smc.monsters[0].speed
|
||||
let camp = -1
|
||||
let prefab_path = smc.monsters[0].prefab_path
|
||||
let name = smc.monsters[0].name
|
||||
monster.load(pos,speed,camp,prefab_path,name);
|
||||
smc.monsters.splice(0,1)
|
||||
}
|
||||
|
||||
if(smc.heros.length>0) {
|
||||
console.log("heros load")
|
||||
let hero = ecs.getEntity<Hero>(Hero);
|
||||
@@ -92,21 +86,23 @@ export class MapViewComp extends CCComp {
|
||||
let name = smc.heros[0].name
|
||||
hero.load(pos,speed,camp,prefab_path,name);
|
||||
smc.heros.splice(0,1)
|
||||
}
|
||||
smc.vm_data.hp.min = 100
|
||||
|
||||
}
|
||||
}
|
||||
private addMonster() {
|
||||
this.scene.node.active = true
|
||||
if (smc.monsters.length>0){
|
||||
let monster = ecs.getEntity<Monster>(Monster);
|
||||
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
|
||||
let speed =smc.monsters[0].speed
|
||||
let camp = -1
|
||||
let prefab_path = smc.monsters[0].prefab_path
|
||||
let name = smc.monsters[0].name
|
||||
monster.load(pos,speed,camp,prefab_path,name);
|
||||
smc.monsters.splice(0,1)
|
||||
}
|
||||
}
|
||||
|
||||
private addMonster(name:string = "niu",speed:number = 100) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private getRandomInt(min: number, max: number): number {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
57
assets/script/game/monster/HeroCard.ts
Normal file
57
assets/script/game/monster/HeroCard.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
/*
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-11-18 17:47:56
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-08-04 15:43:04
|
||||
*/
|
||||
import { instantiate, Node, Prefab, Vec3 ,tween, v3,Collider2D,Contact2DType,PhysicsSystem2D,IPhysics2DContact, animation,Label,resources,SpriteFrame,Sprite} from "cc";
|
||||
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
|
||||
/** 角色实体 */
|
||||
@ecs.register(`HeroCard`)
|
||||
export class HeroCard extends ecs.Entity {
|
||||
// 数据层
|
||||
|
||||
// 视图层
|
||||
|
||||
|
||||
protected init() {
|
||||
// this.addComponents<ecs.Comp>(
|
||||
// MonsterModelComp);
|
||||
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
// this.remove(MonsterViewComp);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,camp:number = 1,prefab_path:string = "monster",name:string="hero") {
|
||||
// var path = "game/monster/"+prefab_path;
|
||||
var path = "game/monster/hero";
|
||||
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.entityLayer!.node!;
|
||||
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
|
||||
node.setPosition(pos)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
const url = 'game/heros/hero/'+prefab_path+'/spriteFrame';
|
||||
resources.load(url, SpriteFrame, (err: any, spriteFrame) => {
|
||||
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||
|
||||
sprite.spriteFrame = spriteFrame;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
1
assets/script/game/monster/HeroCard.ts.meta
Normal file
1
assets/script/game/monster/HeroCard.ts.meta
Normal file
@@ -0,0 +1 @@
|
||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"9ec1b4da-2a40-4f23-8f9d-96f10cafb1b0","files":[],"subMetas":{},"userData":{}}
|
||||
@@ -9,7 +9,7 @@ import { EventTouch, Vec3, _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 { smc } from '../../common/SingletonModuleComp';
|
||||
import { Role } from '../Role';
|
||||
// import { Role } from '../Role';
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -17,10 +17,10 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('RoleViewUIController', false)
|
||||
export class RoleViewUIControllerComp extends CCComp {
|
||||
|
||||
private target: Role = null!;
|
||||
// private target: Role = null!;
|
||||
|
||||
start() {
|
||||
this.target = smc.own;
|
||||
// this.target = smc.own;
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
||||
Reference in New Issue
Block a user