diff --git a/assets/resources/game/map/map_rpg.prefab b/assets/resources/game/map/map_rpg.prefab index 510d9004..6d2779df 100644 --- a/assets/resources/game/map/map_rpg.prefab +++ b/assets/resources/game/map/map_rpg.prefab @@ -28,17 +28,17 @@ "_active": true, "_components": [ { - "__id__": 70 + "__id__": 78 }, { - "__id__": 72 + "__id__": 80 }, { - "__id__": 74 + "__id__": 82 } ], "_prefab": { - "__id__": 76 + "__id__": 84 }, "_lpos": { "__type__": "cc.Vec3", @@ -196,18 +196,24 @@ ], "_active": true, "_components": [ - { - "__id__": 63 - }, - { - "__id__": 65 - }, { "__id__": 67 + }, + { + "__id__": 69 + }, + { + "__id__": 71 + }, + { + "__id__": 73 + }, + { + "__id__": 75 } ], "_prefab": { - "__id__": 69 + "__id__": 77 }, "_lpos": { "__type__": "cc.Vec3", @@ -257,17 +263,17 @@ "__id__": 38 }, { - "__id__": 44 + "__id__": 46 } ], "_active": true, "_components": [ { - "__id__": 60 + "__id__": 64 } ], "_prefab": { - "__id__": 62 + "__id__": 66 }, "_lpos": { "__type__": "cc.Vec3", @@ -942,10 +948,13 @@ }, { "__id__": 41 + }, + { + "__id__": 43 } ], "_prefab": { - "__id__": 43 + "__id__": 45 }, "_lpos": { "__type__": "cc.Vec3", @@ -1022,6 +1031,24 @@ "__type__": "cc.CompPrefabInfo", "fileId": "6fzmfjcbNPK6tOzQOKJfRV" }, + { + "__type__": "c0f2fdqfBtOjKCjsgH1qG9+", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 38 + }, + "_enabled": true, + "__prefab": { + "__id__": 44 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "173LGjeL9OlLaNVYt3Y+qH" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -1045,20 +1072,23 @@ }, "_children": [ { - "__id__": 45 + "__id__": 47 } ], "_active": true, "_components": [ { - "__id__": 55 + "__id__": 57 }, { - "__id__": 57 + "__id__": 59 + }, + { + "__id__": 61 } ], "_prefab": { - "__id__": 59 + "__id__": 63 }, "_lpos": { "__type__": "cc.Vec3", @@ -1093,17 +1123,17 @@ "__type__": "cc.Node", "_objFlags": 0, "_parent": { - "__id__": 44 + "__id__": 46 }, "_prefab": { - "__id__": 46 + "__id__": 48 }, "__editorExtras__": {} }, { "__type__": "cc.PrefabInfo", "root": { - "__id__": 45 + "__id__": 47 }, "asset": { "__uuid__": "63c02880-bda6-4370-bb22-46bf4f49bbfe", @@ -1111,7 +1141,7 @@ }, "fileId": "fdklpBwCBM/qJ4WFlQF3kT", "instance": { - "__id__": 47 + "__id__": 49 }, "targetOverrides": null }, @@ -1124,15 +1154,9 @@ "mountedChildren": [], "mountedComponents": [], "propertyOverrides": [ - { - "__id__": 48 - }, { "__id__": 50 }, - { - "__id__": 51 - }, { "__id__": 52 }, @@ -1141,6 +1165,12 @@ }, { "__id__": 54 + }, + { + "__id__": 55 + }, + { + "__id__": 56 } ], "removedComponents": [] @@ -1148,7 +1178,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 49 + "__id__": 51 }, "propertyPath": [ "_name" @@ -1164,7 +1194,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 49 + "__id__": 51 }, "propertyPath": [ "_lpos" @@ -1179,7 +1209,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 49 + "__id__": 51 }, "propertyPath": [ "_lrot" @@ -1195,7 +1225,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 49 + "__id__": 51 }, "propertyPath": [ "_euler" @@ -1210,7 +1240,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 49 + "__id__": 51 }, "propertyPath": [ "_active" @@ -1220,7 +1250,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 49 + "__id__": 51 }, "propertyPath": [ "_lscale" @@ -1238,11 +1268,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 44 + "__id__": 46 }, "_enabled": true, "__prefab": { - "__id__": 56 + "__id__": 58 }, "_contentSize": { "__type__": "cc.Size", @@ -1266,11 +1296,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 44 + "__id__": 46 }, "_enabled": true, "__prefab": { - "__id__": 58 + "__id__": 60 }, "light": { "__uuid__": "319c7eb8-9826-48b6-81e4-82559dbf82a8", @@ -1282,6 +1312,28 @@ "__type__": "cc.CompPrefabInfo", "fileId": "90iY8Wt31JQZ1WhSvASP55" }, + { + "__type__": "b7739lRGUtNE4v/zX96Czu/", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 46 + }, + "_enabled": true, + "__prefab": { + "__id__": 62 + }, + "light": { + "__uuid__": "319c7eb8-9826-48b6-81e4-82559dbf82a8", + "__expectedType__": "cc.Prefab" + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "7dN39sPBROo6Jp9JrguYbQ" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -1305,7 +1357,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 61 + "__id__": 65 }, "_contentSize": { "__type__": "cc.Size", @@ -1346,7 +1398,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 68 }, "_contentSize": { "__type__": "cc.Size", @@ -1374,7 +1426,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 70 }, "camera": { "__id__": 3 @@ -1392,7 +1444,7 @@ "__id__": 41 }, "SkillLayer": { - "__id__": 57 + "__id__": 59 }, "isFollowPlayer": true, "_id": "" @@ -1411,7 +1463,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 72 }, "_id": "" }, @@ -1419,6 +1471,43 @@ "__type__": "cc.CompPrefabInfo", "fileId": "7eqXnRa8JJN6SutHuRICj9" }, + { + "__type__": "c0f2fdqfBtOjKCjsgH1qG9+", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 6 + }, + "_enabled": true, + "__prefab": { + "__id__": 74 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "eanjJqiNdFCbYjTOIs36JC" + }, + { + "__type__": "b7739lRGUtNE4v/zX96Czu/", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 6 + }, + "_enabled": true, + "__prefab": { + "__id__": 76 + }, + "light": null, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "5fhe2hAPlMUbqe7oghUpNM" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -1442,7 +1531,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 71 + "__id__": 79 }, "_contentSize": { "__type__": "cc.Size", @@ -1470,7 +1559,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 73 + "__id__": 81 }, "_cameraComponent": { "__id__": 3 @@ -1492,7 +1581,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 75 + "__id__": 83 }, "_alignFlags": 45, "_target": null, @@ -1531,7 +1620,7 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": [ { - "__id__": 45 + "__id__": 47 } ] } diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 7ebb0af7..49a59764 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -54,7 +54,7 @@ export class SingletonModuleComp extends ecs.Comp { level:1, level_max:4, eid:0, - ref_cost:2, + ref_cost:1, up_cost:4, }, hp: { @@ -66,8 +66,8 @@ export class SingletonModuleComp extends ecs.Comp { max: 30 }, gold: { - min: 3, - max: 3, + min: 20, + max: 20, max_limit:10, time:0, cd:10, diff --git a/assets/script/game/common/config/CardSet.ts b/assets/script/game/common/config/CardSet.ts index 2248ae6e..7054e1f2 100644 --- a/assets/script/game/common/config/CardSet.ts +++ b/assets/script/game/common/config/CardSet.ts @@ -9,11 +9,11 @@ export const CardType = { 2: "后排", } export const CardList={ - 1:[1101,1102,1201,1202,1301,1302,], - 2:[2101,2102,2201,2202,2301,2302,], - 3:[3101,3102,3201,3202,3301,3302,], - 4:[4101,4102,4201,4202,4301,4302,], - 5:[5001,5002,5003,5004], + 1:[{uuid:1101,type:1},{uuid:1102,type:1},{uuid:1201,type:1},{uuid:1202,type:1},{uuid:1301,type:1},{uuid:1302,type:1},{uuid:1001,type:2}], + 2:[{uuid:2101,type:1},{uuid:2102,type:1},{uuid:2201,type:1},{uuid:2202,type:1},{uuid:2301,type:1},{uuid:2302,type:1},], + 3:[{uuid:3101,type:1},{uuid:3102,type:1},{uuid:3201,type:1},{uuid:3202,type:1},{uuid:3301,type:1},{uuid:3302,type:1},], + 4:[{uuid:4101,type:1},{uuid:4102,type:1},{uuid:4201,type:1},{uuid:4202,type:1},{uuid:4301,type:1},{uuid:4302,type:1},], + 5:[{uuid:5001,type:1},{uuid:5002,type:1},{uuid:5003,type:1},{uuid:5004,type:1}], // 1:[1101,1102,1103,1104,1105,1106,1201,1202,1203,1204,1205,1301,1302,1303,1304,], // 2:[2101,2102,2103,2104,2105,2201,2202,2203,2204,2301,2302,2303,2304,2305,], // 3:[3101,3102,3103,3104,3201,3202,3203,3204,3205,3301,3302,3303,3304,], @@ -29,6 +29,11 @@ export const HeroSet ={ }, } +export const SkillSet={ + 1001:{uuid: 1001,path: "1001",type: 1,level: 1,name: "火球术",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,} + +} + export const CardSet = { 1101:{uuid: 1101,path: "1101",type: 1,level: 1,name: "守护犬",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "守护", info: "自身护盾",atktype: "攻击型", mon: "狗"}, diff --git a/assets/script/game/common/config/MissionSet.ts b/assets/script/game/common/config/MissionSet.ts index 9fa833b1..91add9f1 100644 --- a/assets/script/game/common/config/MissionSet.ts +++ b/assets/script/game/common/config/MissionSet.ts @@ -1,15 +1,5 @@ export const MissionNum = 3 -export const Mission= { - // 1:[1101,1102,1201,1202,1301,1302,], - // 2:[2101,2102,2201,2202,2301,2302,], - // 3:[3101,3102,3201,3202,3301,3302,], - // 4:[4101,4102,4201,4202,4301,4302,], - // 5:[5001,5002,5003,5004], - // 1:[1101,1102,1103,1104,1105,1106,1201,1202,1203,1204,1205,1301,1302,1303,1304,], - // 2:[2101,2102,2103,2104,2105,2201,2202,2203,2204,2301,2302,2303,2304,2305,], - // 3:[3101,3102,3103,3104,3201,3202,3203,3204,3205,3301,3302,3303,3304,], - // 4:[4101,4102,4103,4104,4201,4202,4203,4204,4301,4302,4303,4304,], - // 5:[5001,5002,5003,5004], +export const MonsetList = { 1:{ 1:[1101,1102,], 2:[1101,1102,2101,2102,], @@ -33,3 +23,42 @@ export const Mission= { }, } + +export const MissionSet = { + 1:{ + lv1_num:10, + lv2_num:10, + lv3_num:10, + lv4_num:10, + lv5_num:10, + lv1_skill_num:10, + lv2_skill_num:10, + lv3_skill_num:10, + lv4_skill_num:10, + lv5_skill_num:10, + }, + 2:{ + lv1_num:10, + lv2_num:10, + lv3_num:10, + lv4_num:10, + lv5_num:10, + lv1_skill_num:10, + lv2_skill_num:10, + lv3_skill_num:10, + lv4_skill_num:10, + lv5_skill_num:10, + }, + 3:{ + lv1_num:10, + lv2_num:10, + lv3_num:10, + lv4_num:10, + lv5_num:10, + lv1_skill_num:10, + lv2_skill_num:10, + lv3_skill_num:10, + lv4_skill_num:10, + lv5_skill_num:10, + } +} diff --git a/assets/script/game/map/CardController.ts b/assets/script/game/map/CardController.ts index f2e6436d..1a415c57 100644 --- a/assets/script/game/map/CardController.ts +++ b/assets/script/game/map/CardController.ts @@ -79,7 +79,7 @@ export class CardControllerComp extends CCComp { lists.forEach(element => { let card = ecs.getEntity(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; diff --git a/assets/script/game/map/MapMonsterComp.ts b/assets/script/game/map/MapMonsterComp.ts new file mode 100644 index 00000000..ce1048be --- /dev/null +++ b/assets/script/game/map/MapMonsterComp.ts @@ -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); + 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(); + } +} \ No newline at end of file diff --git a/assets/script/game/map/MapMonsterComp.ts.meta b/assets/script/game/map/MapMonsterComp.ts.meta new file mode 100644 index 00000000..c0892163 --- /dev/null +++ b/assets/script/game/map/MapMonsterComp.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "c0f2f76a-7c1b-4e8c-a0a3-b201f5a86f7e", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/map/MapSkillComp.ts b/assets/script/game/map/MapSkillComp.ts new file mode 100644 index 00000000..f5cd4755 --- /dev/null +++ b/assets/script/game/map/MapSkillComp.ts @@ -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(); + } +} \ No newline at end of file diff --git a/assets/script/game/map/MapSkillComp.ts.meta b/assets/script/game/map/MapSkillComp.ts.meta new file mode 100644 index 00000000..a61dc861 --- /dev/null +++ b/assets/script/game/map/MapSkillComp.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "b7739951-194b-4d13-8bff-cd7f7a0b3bbf", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/map/view/MapViewComp.ts b/assets/script/game/map/view/MapViewComp.ts index 08a72be5..25027c92 100644 --- a/assets/script/game/map/view/MapViewComp.ts +++ b/assets/script/game/map/view/MapViewComp.ts @@ -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); - let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE) - let camp = -1 - monster.load(pos,camp,uuid); - smc.monsters.splice(0,1) - } + } diff --git a/assets/script/game/map/view/map/layer/SkillLayer.ts b/assets/script/game/map/view/map/layer/SkillLayer.ts index e445880a..008a5b81 100644 --- a/assets/script/game/map/view/map/layer/SkillLayer.ts +++ b/assets/script/game/map/view/map/layer/SkillLayer.ts @@ -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); diff --git a/assets/script/game/monster/Hero.ts b/assets/script/game/monster/Hero.ts index e7b26355..0856a7d7 100644 --- a/assets/script/game/monster/Hero.ts +++ b/assets/script/game/monster/Hero.ts @@ -52,7 +52,7 @@ export class Hero extends ecs.Entity { resources.load(url, SpriteAtlas, (err: any, atlas) => { const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); - sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path); + sprite.spriteFrame = atlas.getSpriteFrame(smc.heros[uuid].path); }); this.hero_init(uuid,node) oops.message.dispatchEvent("hero_load",this) @@ -61,22 +61,22 @@ export class Hero extends ecs.Entity { hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ var mv = node.getComponent(MonsterViewComp)!; mv.hero_uuid=uuid; - mv.speed =mv.ospeed = CardSet[uuid].speed; - mv.hero_name= CardSet[uuid].name; - mv.hp= mv.hp_max = CardSet[uuid].hp; - mv.level = CardSet[uuid].level; - mv.atk = CardSet[uuid].atk; - mv.atk_cd = CardSet[uuid].atk_cd; - mv.power = CardSet[uuid].power; - mv.type = CardSet[uuid].type; + mv.speed =mv.ospeed = smc.heros[uuid].speed; + mv.hero_name= smc.heros[uuid].name; + mv.hp= mv.hp_max = smc.heros[uuid].hp; + mv.level = smc.heros[uuid].level; + mv.atk = smc.heros[uuid].atk; + mv.atk_cd = smc.heros[uuid].atk_cd; + mv.power = smc.heros[uuid].power; + mv.type = smc.heros[uuid].type; mv.Tpos = v3(0,0,0); mv.camp = 1; - mv.change_name(CardSet[uuid].name,1) + mv.change_name(smc.heros[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}) + smc.monsters_in.push({name:smc.heros[uuid].name,eid:eid}) } diff --git a/assets/script/game/monster/HeroCard.ts b/assets/script/game/monster/HeroCard.ts index d971d956..e88d7101 100644 --- a/assets/script/game/monster/HeroCard.ts +++ b/assets/script/game/monster/HeroCard.ts @@ -12,7 +12,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { UIID } from "../common/config/GameUIConfig"; import { smc } from "../common/SingletonModuleComp"; import{HeroCardViewComp} from "./HeroCardViewComp"; -import { CardSet } from "../common/config/CardSet"; +import { CardSet ,SkillSet} from "../common/config/CardSet"; /** 角色实体 */ @ecs.register(`HeroCard`) export class HeroCard extends ecs.Entity { @@ -32,20 +32,28 @@ export class HeroCard extends ecs.Entity { /** 加载角色 */ load(pos: Vec3 = Vec3.ZERO,uuid:number=1001,parent:Node,type:number=1) { - // console.log("load hero",uuid); - // var path = "game/monster/"+prefab_path; - switch(type){ + let path: string; + let url: string; + let pathName: string; + let name: string; + let level: number; + + switch (type) { case 1: - var path = "game/heros/hero_card"; + path = "game/heros/hero_card"; + url = "game/heros/heros"; + ({ path: pathName, name, level } = smc.heros[uuid]); break; case 2: - var path = "game/heros/skill_card"; + path = "game/heros/skill_card"; + url = "game/heros/skill"; + ({ path: pathName, name, level } = SkillSet[uuid]); break; case 3: - var path = "game/heros/item_card"; - break; default: - var path = "game/heros/hero_card"; + path = "game/heros/hero_card"; + url = "game/heros/heros"; + ({ path: pathName, name, level } = smc.heros[uuid]); } @@ -55,20 +63,19 @@ export class HeroCard 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) - const url = 'game/heros/heros'; + resources.load(url, SpriteAtlas, (err: any, atlas) => { const sprite = node.getChildByName("hero").getComponent(Sprite); - sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path); + sprite.spriteFrame = atlas.getSpriteFrame(pathName); }); var hcv = node.getComponent(HeroCardViewComp)!; - hcv.card_name=CardSet[uuid].name + hcv.card_name=name hcv.card_uid=uuid + hcv.card_type=type + hcv.card_level=level this.add(hcv); } - - - -} \ No newline at end of file +} diff --git a/assets/script/game/monster/HeroCardViewComp.ts b/assets/script/game/monster/HeroCardViewComp.ts index 33ecd2ca..99737a4a 100644 --- a/assets/script/game/monster/HeroCardViewComp.ts +++ b/assets/script/game/monster/HeroCardViewComp.ts @@ -13,11 +13,12 @@ const { ccclass, property } = _decorator; @ecs.register('HeroCardView', false) export class HeroCardViewComp extends CCComp { card_name:string = "hero_card"; - card_type:string = "hero"; card_uid:number = 1000; in_destroy:boolean = false; pos_x:number = 0; pos_y:number = 0; + card_type:number = 1; + card_level:number = 1; protected onLoad(): void { this.node.on(NodeEventType.TOUCH_START, this.onTouchMove, this); @@ -31,7 +32,7 @@ export class HeroCardViewComp extends CCComp { start() { this.pos_x=this.node.position.x; this.pos_y=this.node.position.y; - this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = CardSet[this.card_uid].level.toString(); + this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = this.card_level.toString(); this.node.getChildByName("name").getComponent(Label).string = this.card_name } @@ -97,14 +98,30 @@ export class HeroCardViewComp extends CCComp { } use_card(){ - if(smc.vm_data.gold.min >= smc.vm_data.cards.ref_cost){ + if(smc.vm_data.gold.min >= this.card_level){ this.in_destroy = true; - oops.message.dispatchEvent("do_add_hero",{uuid:this.card_uid}) + this.do_use_card() this.ent.destroy(); - smc.vm_data.gold.min -= smc.vm_data.cards.ref_cost; + smc.vm_data.gold.min -= this.card_level; }else{ oops.gui.toast("金币不够"); this.node.setPosition(this.pos_x,this.pos_y); } } + do_use_card(){ + switch (this.card_type) { // 添加括号并修正语法 + case 1: + oops.message.dispatchEvent("do_add_hero", { uuid: this.card_uid }); // 添加分号 + break; + case 2: + oops.message.dispatchEvent("do_use_skill", { uuid: this.card_uid }); // 添加分号 + // console.log("do_use_skill",this.card_uid) + break; + default: + + break; + } + + } + } \ No newline at end of file diff --git a/assets/script/game/monster/Monster.ts b/assets/script/game/monster/Monster.ts index 6fb40dd5..4c7c8ca7 100644 --- a/assets/script/game/monster/Monster.ts +++ b/assets/script/game/monster/Monster.ts @@ -52,29 +52,29 @@ export class Monster extends ecs.Entity { resources.load(url, SpriteAtlas, (err: any, atlas) => { const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); - sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path); + sprite.spriteFrame = atlas.getSpriteFrame(smc.heros[uuid].path); }); 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 = CardSet[uuid].speed; - mv.hero_name= CardSet[uuid].name; - mv.hp= mv.hp_max = CardSet[uuid].hp; - mv.level = CardSet[uuid].level; - mv.atk = CardSet[uuid].atk; - mv.atk_cd = CardSet[uuid].atk_cd; - mv.power = CardSet[uuid].power; - mv.type = CardSet[uuid].type; + mv.speed =mv.ospeed = smc.heros[uuid].speed; + mv.hero_name= smc.heros[uuid].name; + mv.hp= mv.hp_max = smc.heros[uuid].hp; + mv.level = smc.heros[uuid].level; + mv.atk = smc.heros[uuid].atk; + mv.atk_cd = smc.heros[uuid].atk_cd; + mv.power = smc.heros[uuid].power; + mv.type = smc.heros[uuid].type; mv.camp = -1; mv.Tpos = v3(0,0,0); - mv.change_name(CardSet[uuid].name,-1) + mv.change_name(smc.heros[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}) + smc.monsters_in.push({name:smc.heros[uuid].name,eid:eid}) } } \ No newline at end of file diff --git a/assets/script/game/map/view/map/layer/once.ts b/assets/script/game/skills/once.ts similarity index 100% rename from assets/script/game/map/view/map/layer/once.ts rename to assets/script/game/skills/once.ts diff --git a/assets/script/game/map/view/map/layer/once.ts.meta b/assets/script/game/skills/once.ts.meta similarity index 100% rename from assets/script/game/map/view/map/layer/once.ts.meta rename to assets/script/game/skills/once.ts.meta