diff --git a/assets/resources/game/heros/skill.prefab b/assets/resources/game/heros/skill.prefab index 5800c7b0..565dc633 100644 --- a/assets/resources/game/heros/skill.prefab +++ b/assets/resources/game/heros/skill.prefab @@ -39,7 +39,7 @@ }, "_lpos": { "__type__": "cc.Vec3", - "x": -0.041, + "x": 0, "y": 0, "z": 0 }, @@ -145,7 +145,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "eaER4oNWNGv7Dk5yvqhnSs" + "fileId": "b5fEMhH0dKibjzzPHF0aOs" }, { "__type__": "cc.Sprite", @@ -190,7 +190,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "54bnrJGBVKcJWcSYfj+9Oy" + "fileId": "b3BlM2kPhHS6sICuwzYueB" }, { "__type__": "cc.Animation", @@ -219,7 +219,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "e4WazVB3FEnoT9JTMotxuZ" + "fileId": "a0BzbhYAROvZlvm0xYALvJ" }, { "__type__": "cc.PrefabInfo", @@ -229,7 +229,7 @@ "asset": { "__id__": 0 }, - "fileId": "3d7pk/kuRJW5UaOHksQPAv", + "fileId": "1ecYrrQP9HyoMDN+sneaND", "instance": null, "targetOverrides": null, "nestedPrefabInstanceRoots": null @@ -413,7 +413,7 @@ "_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, - "y": 0 + "y": 0.5 }, "_id": "" }, diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 49a59764..b4cd4db6 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -8,6 +8,8 @@ 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 { BoxSet } from "./config/BoxSet"; + // import { Role } from "../role/Role"; // import { data } from "../data/data"; /** 游戏模块 */ @@ -17,6 +19,17 @@ export class SingletonModuleComp extends ecs.Comp { initialize: Initialize = null!; /** 游戏地图 */ map: GameMap = null!; + player_buffs: any = { + 1:{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y,eid:0}, + 2:{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y,eid:0}, + 3:{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y,eid:0}, + 4:{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y,eid:0}, + 5:{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y-70,eid:0}, + 6:{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y-70,eid:0}, + 7:{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y-70,eid:0}, + 8:{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y-70,eid:0}, + }; + monster_buffs: any = []; /** 游戏主角 */ // own: Role = null; /** 游戏数据 */ @@ -82,6 +95,7 @@ export class SingletonModuleComp extends ecs.Comp { vmAdd() { console.log("smc vm_data vmAdd"); VM.add(this.vm_data, "data"); + } reset() { for (var key in this.vm_data) { diff --git a/assets/script/game/common/config/BoxSet.ts b/assets/script/game/common/config/BoxSet.ts index 8eb21417..67a1a59e 100644 --- a/assets/script/game/common/config/BoxSet.ts +++ b/assets/script/game/common/config/BoxSet.ts @@ -26,6 +26,6 @@ export enum BoxSet { END_POINT = 360, //游戏地平线 GAME_LINE = 0, - CSKILL_X = 200, - CSKILL_Y = 500, + CSKILL_X = 280, + CSKILL_Y = 420, } \ No newline at end of file diff --git a/assets/script/game/map/MapSkillComp.ts b/assets/script/game/map/MapSkillComp.ts index 4dbe9863..5b5dcc03 100644 --- a/assets/script/game/map/MapSkillComp.ts +++ b/assets/script/game/map/MapSkillComp.ts @@ -19,8 +19,8 @@ export class MapSkillComp extends CCComp { oops.message.on("hero_load", this.doHeroLoad, this); oops.message.on("do_use_skill", this.doSkill, this); } - doSkill(){ - this.addSkill(); + doSkill(event: string, args: any){ + this.addSkill(args.uuid); } addSkill(uuid:number=1001){ let csk =ecs.getEntity(CSkill); diff --git a/assets/script/game/monster/CSkill.ts b/assets/script/game/monster/CSkill.ts index 1eefdc02..9556735b 100644 --- a/assets/script/game/monster/CSkill.ts +++ b/assets/script/game/monster/CSkill.ts @@ -3,6 +3,8 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { CSkillComp } from "./CSkillComp"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { smc } from "../common/SingletonModuleComp"; +import { SkillSet } from "../common/config/CardSet"; + /** CSkill 模块 */ @ecs.register(`CSkill`) export class CSkill extends ecs.Entity { @@ -14,6 +16,7 @@ export class CSkill extends ecs.Entity { /** 模块资源释放 */ destroy() { + this.remove(CSkillComp); // 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放 super.destroy(); } @@ -24,19 +27,30 @@ export class CSkill extends ecs.Entity { /** 加载角色 */ load(pos: Vec3 = Vec3.ZERO,camp:number = 1,uuid:number=1001) { // var path = "game/monster/"+prefab_path; - + console.log("load skill",this) var path = "game/heros/skill"; 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("skill").setScale(node.getChildByName("skill").scale.x*camp, node.getChildByName("skill").scale.y, node.getChildByName("skill").scale.z); - node.setPosition(pos) + let cskills = ecs.query(ecs.allOf(CSkillComp)) + for (let index = 1; index <= 8; index++) { + if(smc.player_buffs[index].eid == 0){ + pos.x=smc.player_buffs[index].x + pos.y=smc.player_buffs[index].y + smc.player_buffs[index].eid=this.eid + break + } + + } + console.log("load skill",pos,smc.player_buffs) + node.setPosition(pos.x*-camp,pos.y,pos.z) // console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) const url = 'game/heros/skill'; resources.load(url, SpriteAtlas, (err: any, atlas) => { const sprite = node.getChildByName("skill").getComponent(Sprite); - sprite.spriteFrame = atlas.getSpriteFrame('1002'); + sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path); }); this.skill_init(uuid,node,pos) oops.message.dispatchEvent("cskill_load",this) diff --git a/assets/script/game/monster/CSkillComp.ts b/assets/script/game/monster/CSkillComp.ts index 45f66fd1..c4cb2a08 100644 --- a/assets/script/game/monster/CSkillComp.ts +++ b/assets/script/game/monster/CSkillComp.ts @@ -40,7 +40,7 @@ export class CSkillComp extends CCComp { // console.log("CSkillComp.node.isValid"); setTimeout(() => { // console.log("CSkillComp.node.destroy",this); - this.node.destroy() + this.ent.destroy() }, 10); } } diff --git a/assets/script/game/monster/CSkillModel.ts b/assets/script/game/monster/CSkillModel.ts new file mode 100644 index 00000000..c9f18bf1 --- /dev/null +++ b/assets/script/game/monster/CSkillModel.ts @@ -0,0 +1,26 @@ +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel"; + +/** 数据层对象 */ +@ecs.register('CSkillModel') +export class CSkillModelComp extends ecs.Comp { + /** 提供 MVVM 组件使用的数据 */ + // private vm: any = {}; + + // /** 显示数据添加到 MVVM 框架中监视 */ + // vmAdd() { + // VM.add(this.vm, "CSkillModel"); + // } + + // /** 显示数据从 MVVM 框架中移除 */ + // vmRemove() { + // VM.remove("CSkillModel"); + // } + + /** 数据层组件移除时,重置所有数据为默认值 */ + reset() { + // for (var key in this.vm) { + // delete this.vm[key]; + // } + } +} \ No newline at end of file diff --git a/assets/script/game/monster/CSkillModel.ts.meta b/assets/script/game/monster/CSkillModel.ts.meta new file mode 100644 index 00000000..83225969 --- /dev/null +++ b/assets/script/game/monster/CSkillModel.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "917ea8ef-8f1b-498c-8bfe-654cd28a86a5", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/monster/HeroCardViewComp.ts b/assets/script/game/monster/HeroCardViewComp.ts index 61fe5545..7a9ccacb 100644 --- a/assets/script/game/monster/HeroCardViewComp.ts +++ b/assets/script/game/monster/HeroCardViewComp.ts @@ -8,6 +8,7 @@ import { CardSet } from "../common/config/CardSet"; import { HeroCard } from "./HeroCard"; import { HeroModelComp } from "./HeroModelComp"; import { Hero } from "./Hero"; +import { MonsterViewComp } from "./MonsterViewComp"; const { ccclass, property } = _decorator; /** 视图层对象 */ @@ -100,8 +101,10 @@ export class HeroCardViewComp extends CCComp { } use_card(){ - Hero + let heros = ecs.query(ecs.allOf(HeroModelComp)) + // let heross= ecs.query(ecs.allOf(MonsterViewComp)) + // console.log("heross",heross) if(heros.length >= 4){ oops.gui.toast("英雄数量达到上限"); this.node.setPosition(this.pos_x,this.pos_y);