diff --git a/assets/resources/game/map/map_rpg.prefab b/assets/resources/game/map/map_rpg.prefab index 4bd6a924..05b9b84f 100644 --- a/assets/resources/game/map/map_rpg.prefab +++ b/assets/resources/game/map/map_rpg.prefab @@ -530,7 +530,7 @@ "value": { "__type__": "cc.Vec3", "x": -0.827, - "y": 264.282, + "y": 53.339, "z": 0 } }, @@ -589,7 +589,7 @@ "propertyPath": [ "_active" ], - "value": false + "value": true }, { "__type__": "cc.UITransform", diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 617c32ad..86d9b058 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -48,6 +48,7 @@ export class SingletonModuleComp extends ecs.Comp { gold: { min: 3, max: 3, + max_limit:10, time:0, cd:30, }, diff --git a/assets/script/game/map/view/MapViewComp.ts b/assets/script/game/map/view/MapViewComp.ts index f12866a4..7b3c4594 100644 --- a/assets/script/game/map/view/MapViewComp.ts +++ b/assets/script/game/map/view/MapViewComp.ts @@ -25,7 +25,11 @@ export class MapViewComp extends CCComp { current_map: any; /** 转场碰撞点对象集合 */ - private timer: Timer = new Timer(3); + private monster_refresh_rtimer: Timer = new Timer(3); + + private mapLoaded() { + + } onLoad(){ // 监听全局事件 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) { this.addMonster() } + /**监听do_add_hero 添加hero,通过uuid */ private on_do_add_hero(event: string, args: any) { - console.log("do_add_hero",args.HeroCardView) - this.addHero(args.HeroCardView.card_uid) - this.addMonster() - + console.log("do_add_hero",args.uuid) + this.addHero(args.uuid) } reset(): void { @@ -49,19 +52,22 @@ export class MapViewComp extends CCComp { } - /** 转场 */ protected update(dt: number): void { - + if (this.monster_refresh_rtimer.update(dt)) { + this.monster_refresh() + } // this.shuaxin(dt) this.gold_add(dt) } - - private mapLoaded() { - + monster_refresh(){ + this.addMonster(1001) } gold_add(dt: number) { smc.vm_data.gold.time += dt; 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.time = 0; } @@ -77,24 +83,15 @@ export class MapViewComp extends CCComp { this.scene.node.active = true let hero = ecs.getEntity(Hero); let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE) - let speed =CardSet[uuid].speed let camp = 1 - let prefab_path = CardSet[uuid].prefab_path - let name = CardSet[uuid].name - hero.load(pos,speed,camp,prefab_path,name); + hero.load(pos,camp,uuid); } - private addMonster() { + private addMonster(uuid:number=1001) { this.scene.node.active = true - if (smc.monsters.length>0){ let monster = ecs.getEntity(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) - } + monster.load(pos,camp,uuid); } diff --git a/assets/script/game/monster/Hero.ts b/assets/script/game/monster/Hero.ts index 10d1c6e7..51da84d5 100644 --- a/assets/script/game/monster/Hero.ts +++ b/assets/script/game/monster/Hero.ts @@ -5,7 +5,7 @@ * @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 { instantiate, Node, Prefab, Vec3,v3,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"; @@ -14,6 +14,7 @@ import { smc } from "../common/SingletonModuleComp"; import { MonsterModelComp } from "./MonsterModelComp"; import { MonsterSpine } from "./MonsterSpine"; import { MonsterViewComp } from "./MonsterViewComp"; +import { CardSet } from "../common/config/CardSet"; /** 角色实体 */ @ecs.register(`Hero`) 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/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.setPosition(pos) // 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) => { const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); sprite.spriteFrame = spriteFrame; }); - - 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}) + this.hero_init(uuid,node) 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}) + } } \ No newline at end of file diff --git a/assets/script/game/monster/HeroCardViewComp.ts b/assets/script/game/monster/HeroCardViewComp.ts index e919bc21..8a33d51c 100644 --- a/assets/script/game/monster/HeroCardViewComp.ts +++ b/assets/script/game/monster/HeroCardViewComp.ts @@ -45,13 +45,11 @@ export class HeroCardViewComp extends CCComp { let active = parent.getChildByName("active"); active.setPosition(this.node.position.x,this.node.position.y) active.active = true; - console.log(parent); // if(this.ent.eid == smc.vm_data.cards.eid){ // this.node.getChildByName("active").active = true; // }else{ // this.node.getChildByName("active").active = false; // } - console.log("onTouchMove"); let delta = event.getDelta(); 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(){ 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(); smc.vm_data.gold.min -= CardSet[this.card_uid].level; }else{ diff --git a/assets/script/game/monster/Monster.ts b/assets/script/game/monster/Monster.ts index 5ac83f2c..dc006322 100644 --- a/assets/script/game/monster/Monster.ts +++ b/assets/script/game/monster/Monster.ts @@ -5,7 +5,7 @@ * @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 { instantiate, Node, Prefab, Vec3 ,v3,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"; @@ -14,6 +14,7 @@ import { smc } from "../common/SingletonModuleComp"; import { MonsterModelComp } from "./MonsterModelComp"; import { MonsterSpine } from "./MonsterSpine"; import { MonsterViewComp } from "./MonsterViewComp"; +import { CardSet } from "../common/config/CardSet"; /** 角色实体 */ @ecs.register(`Monster`) 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/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.setPosition(pos) // 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) => { const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); 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)!; - mv.speed =mv.ospeed = speed; - mv.hero_name= name; - mv.camp = camp; + mv.speed =mv.ospeed = CardSet[uuid].speed; + mv.hero_name= CardSet[uuid].name; + mv.camp = -1; mv.Tpos = v3(0,0,0); - mv.change_name(name,camp) + mv.change_name(CardSet[uuid].name,-1) this.add(mv); - if(camp == 1){ - smc.heros_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0}) - oops.message.dispatchEvent("hero_load",this) - }else{ - 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) + 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}) } - } \ No newline at end of file