This commit is contained in:
2024-08-12 09:38:47 +08:00
parent 21b559abcf
commit 9941b5149d
6 changed files with 57 additions and 59 deletions

View File

@@ -530,7 +530,7 @@
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": -0.827, "x": -0.827,
"y": 264.282, "y": 53.339,
"z": 0 "z": 0
} }
}, },
@@ -589,7 +589,7 @@
"propertyPath": [ "propertyPath": [
"_active" "_active"
], ],
"value": false "value": true
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",

View File

@@ -48,6 +48,7 @@ export class SingletonModuleComp extends ecs.Comp {
gold: { gold: {
min: 3, min: 3,
max: 3, max: 3,
max_limit:10,
time:0, time:0,
cd:30, cd:30,
}, },

View File

@@ -25,7 +25,11 @@ export class MapViewComp extends CCComp {
current_map: any; current_map: any;
/** 转场碰撞点对象集合 */ /** 转场碰撞点对象集合 */
private timer: Timer = new Timer(3); private monster_refresh_rtimer: Timer = new Timer(3);
private mapLoaded() {
}
onLoad(){ onLoad(){
// 监听全局事件 // 监听全局事件
oops.message.on("do_add_monster", this.on_do_add_monster, this); oops.message.on("do_add_monster", this.on_do_add_monster, this);
@@ -34,11 +38,10 @@ export class MapViewComp extends CCComp {
private on_do_add_monster(event: string, args: any) { private on_do_add_monster(event: string, args: any) {
this.addMonster() this.addMonster()
} }
/**监听do_add_hero 添加hero,通过uuid */
private on_do_add_hero(event: string, args: any) { private on_do_add_hero(event: string, args: any) {
console.log("do_add_hero",args.HeroCardView) console.log("do_add_hero",args.uuid)
this.addHero(args.HeroCardView.card_uid) this.addHero(args.uuid)
this.addMonster()
} }
reset(): void { reset(): void {
@@ -49,19 +52,22 @@ export class MapViewComp extends CCComp {
} }
/** 转场 */
protected update(dt: number): void { protected update(dt: number): void {
if (this.monster_refresh_rtimer.update(dt)) {
this.monster_refresh()
}
// this.shuaxin(dt) // this.shuaxin(dt)
this.gold_add(dt) this.gold_add(dt)
} }
monster_refresh(){
private mapLoaded() { this.addMonster(1001)
} }
gold_add(dt: number) { gold_add(dt: number) {
smc.vm_data.gold.time += dt; smc.vm_data.gold.time += dt;
if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) { if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) {
if (smc.vm_data.gold.max < smc.vm_data.gold.max_limit) {
smc.vm_data.gold.max += 1;
}
smc.vm_data.gold.min = smc.vm_data.gold.max; smc.vm_data.gold.min = smc.vm_data.gold.max;
smc.vm_data.gold.time = 0; smc.vm_data.gold.time = 0;
} }
@@ -77,24 +83,15 @@ export class MapViewComp extends CCComp {
this.scene.node.active = true this.scene.node.active = true
let hero = ecs.getEntity<Hero>(Hero); let hero = ecs.getEntity<Hero>(Hero);
let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE) let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE)
let speed =CardSet[uuid].speed
let camp = 1 let camp = 1
let prefab_path = CardSet[uuid].prefab_path hero.load(pos,camp,uuid);
let name = CardSet[uuid].name
hero.load(pos,speed,camp,prefab_path,name);
} }
private addMonster() { private addMonster(uuid:number=1001) {
this.scene.node.active = true this.scene.node.active = true
if (smc.monsters.length>0){
let monster = ecs.getEntity<Monster>(Monster); let monster = ecs.getEntity<Monster>(Monster);
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE) let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let speed =smc.monsters[0].speed
let camp = -1 let camp = -1
let prefab_path = smc.monsters[0].prefab_path monster.load(pos,camp,uuid);
let name = smc.monsters[0].name
monster.load(pos,speed,camp,prefab_path,name);
smc.monsters.splice(0,1)
}
} }

View File

@@ -5,7 +5,7 @@
* @LastEditors: dgflash * @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04 * @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 { instantiate, Node, Prefab, Vec3,v3,resources,SpriteFrame,Sprite} from "cc";
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines"; import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
@@ -14,6 +14,7 @@ import { smc } from "../common/SingletonModuleComp";
import { MonsterModelComp } from "./MonsterModelComp"; import { MonsterModelComp } from "./MonsterModelComp";
import { MonsterSpine } from "./MonsterSpine"; import { MonsterSpine } from "./MonsterSpine";
import { MonsterViewComp } from "./MonsterViewComp"; import { MonsterViewComp } from "./MonsterViewComp";
import { CardSet } from "../common/config/CardSet";
/** 角色实体 */ /** 角色实体 */
@ecs.register(`Hero`) @ecs.register(`Hero`)
export class Hero extends ecs.Entity { export class Hero extends ecs.Entity {
@@ -34,7 +35,7 @@ export class Hero extends ecs.Entity {
} }
/** 加载角色 */ /** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,camp:number = 1,prefab_path:string = "monster",name:string="hero") { load(pos: Vec3 = Vec3.ZERO,camp:number = 1,uuid:number=1001) {
// var path = "game/monster/"+prefab_path; // var path = "game/monster/"+prefab_path;
var path = "game/heros/hero"; var path = "game/heros/hero";
@@ -47,25 +48,29 @@ export class Hero extends ecs.Entity {
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z); node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
node.setPosition(pos) node.setPosition(pos)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) // console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
const url = 'game/heros/hero/'+prefab_path+'/spriteFrame'; const url = 'game/heros/hero/'+CardSet[uuid].prefab_path+'/spriteFrame';
resources.load(url, SpriteFrame, (err: any, spriteFrame) => { resources.load(url, SpriteFrame, (err: any, spriteFrame) => {
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
sprite.spriteFrame = spriteFrame; sprite.spriteFrame = spriteFrame;
}); });
this.hero_init(uuid,node)
var mv = node.getComponent(MonsterViewComp)!;
mv.speed =mv.ospeed = speed;
mv.hero_name= name;
mv.camp = camp;
mv.Tpos = v3(0,0,0);
mv.change_name(name,camp)
this.add(mv);
smc.heros_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0})
oops.message.dispatchEvent("hero_load",this) oops.message.dispatchEvent("hero_load",this)
} }
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!;
mv.speed =mv.ospeed = CardSet[uuid].speed;
mv.hero_name= CardSet[uuid].name;
mv.Tpos = v3(0,0,0);
mv.camp = 1;
mv.change_name(CardSet[uuid].name,1)
this.add(mv);
this.push_monsters_in(uuid,mv.ent.eid)
}
push_monsters_in(uuid:number=1001,eid:number=0){
smc.monsters_in.push({name:CardSet[uuid].name,eid:eid})
}
} }

View File

@@ -45,13 +45,11 @@ export class HeroCardViewComp extends CCComp {
let active = parent.getChildByName("active"); let active = parent.getChildByName("active");
active.setPosition(this.node.position.x,this.node.position.y) active.setPosition(this.node.position.x,this.node.position.y)
active.active = true; active.active = true;
console.log(parent);
// if(this.ent.eid == smc.vm_data.cards.eid){ // if(this.ent.eid == smc.vm_data.cards.eid){
// this.node.getChildByName("active").active = true; // this.node.getChildByName("active").active = true;
// }else{ // }else{
// this.node.getChildByName("active").active = false; // this.node.getChildByName("active").active = false;
// } // }
console.log("onTouchMove");
let delta = event.getDelta(); let delta = event.getDelta();
this.node.setPosition(this.node.position.x+delta.x,this.node.position.y+delta.y); this.node.setPosition(this.node.position.x+delta.x,this.node.position.y+delta.y);
} }
@@ -68,7 +66,7 @@ export class HeroCardViewComp extends CCComp {
} }
use_card(){ use_card(){
if(smc.vm_data.gold.min >= CardSet[this.card_uid].level){ if(smc.vm_data.gold.min >= CardSet[this.card_uid].level){
oops.message.dispatchEvent("do_add_hero",this.ent) oops.message.dispatchEvent("do_add_hero",{uuid:this.card_uid})
this.ent.destroy(); this.ent.destroy();
smc.vm_data.gold.min -= CardSet[this.card_uid].level; smc.vm_data.gold.min -= CardSet[this.card_uid].level;
}else{ }else{

View File

@@ -5,7 +5,7 @@
* @LastEditors: dgflash * @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04 * @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 { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,} from "cc";
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines"; import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
@@ -14,6 +14,7 @@ import { smc } from "../common/SingletonModuleComp";
import { MonsterModelComp } from "./MonsterModelComp"; import { MonsterModelComp } from "./MonsterModelComp";
import { MonsterSpine } from "./MonsterSpine"; import { MonsterSpine } from "./MonsterSpine";
import { MonsterViewComp } from "./MonsterViewComp"; import { MonsterViewComp } from "./MonsterViewComp";
import { CardSet } from "../common/config/CardSet";
/** 角色实体 */ /** 角色实体 */
@ecs.register(`Monster`) @ecs.register(`Monster`)
export class Monster extends ecs.Entity { export class Monster extends ecs.Entity {
@@ -34,7 +35,7 @@ export class Monster extends ecs.Entity {
} }
/** 加载角色 */ /** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,camp:number = 1,prefab_path:string = "monster",name:string="hero") { load(pos: Vec3 = Vec3.ZERO,camp:number = -1,uuid:number=1001) {
// var path = "game/monster/"+prefab_path; // var path = "game/monster/"+prefab_path;
var path = "game/heros/hero"; var path = "game/heros/hero";
@@ -47,31 +48,27 @@ export class Monster extends ecs.Entity {
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z); node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
node.setPosition(pos) node.setPosition(pos)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) // console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
const url = 'game/heros/hero/'+prefab_path+'/spriteFrame'; const url = 'game/heros/hero/'+CardSet[uuid].prefab_path+'/spriteFrame';
resources.load(url, SpriteFrame, (err: any, spriteFrame) => { resources.load(url, SpriteFrame, (err: any, spriteFrame) => {
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
sprite.spriteFrame = spriteFrame; sprite.spriteFrame = spriteFrame;
}); });
this.hero_init(uuid,node)
oops.message.dispatchEvent("monster_load",this)
}
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
mv.speed =mv.ospeed = speed; mv.speed =mv.ospeed = CardSet[uuid].speed;
mv.hero_name= name; mv.hero_name= CardSet[uuid].name;
mv.camp = camp; mv.camp = -1;
mv.Tpos = v3(0,0,0); mv.Tpos = v3(0,0,0);
mv.change_name(name,camp) mv.change_name(CardSet[uuid].name,-1)
this.add(mv); this.add(mv);
if(camp == 1){ this.push_monsters_in(uuid,mv.ent.eid)
smc.heros_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0}) }
oops.message.dispatchEvent("hero_load",this) push_monsters_in(uuid:number=1001,eid:number=0){
}else{ smc.monsters_in.push({name:CardSet[uuid].name,eid:eid})
smc.monsters_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0})
oops.message.dispatchEvent("monster_load",this)
}
// console.log(smc.heros_in,smc.monsters_in)
} }
} }