卡牌技能位置
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -0.041,
|
"x": 0,
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.CompPrefabInfo",
|
"__type__": "cc.CompPrefabInfo",
|
||||||
"fileId": "eaER4oNWNGv7Dk5yvqhnSs"
|
"fileId": "b5fEMhH0dKibjzzPHF0aOs"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Sprite",
|
"__type__": "cc.Sprite",
|
||||||
@@ -190,7 +190,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.CompPrefabInfo",
|
"__type__": "cc.CompPrefabInfo",
|
||||||
"fileId": "54bnrJGBVKcJWcSYfj+9Oy"
|
"fileId": "b3BlM2kPhHS6sICuwzYueB"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Animation",
|
"__type__": "cc.Animation",
|
||||||
@@ -219,7 +219,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.CompPrefabInfo",
|
"__type__": "cc.CompPrefabInfo",
|
||||||
"fileId": "e4WazVB3FEnoT9JTMotxuZ"
|
"fileId": "a0BzbhYAROvZlvm0xYALvJ"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.PrefabInfo",
|
"__type__": "cc.PrefabInfo",
|
||||||
@@ -229,7 +229,7 @@
|
|||||||
"asset": {
|
"asset": {
|
||||||
"__id__": 0
|
"__id__": 0
|
||||||
},
|
},
|
||||||
"fileId": "3d7pk/kuRJW5UaOHksQPAv",
|
"fileId": "1ecYrrQP9HyoMDN+sneaND",
|
||||||
"instance": null,
|
"instance": null,
|
||||||
"targetOverrides": null,
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
@@ -413,7 +413,7 @@
|
|||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
"x": 0.5,
|
"x": 0.5,
|
||||||
"y": 0
|
"y": 0.5
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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 { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { Initialize } from "../initialize/Initialize";
|
import { Initialize } from "../initialize/Initialize";
|
||||||
import { GameMap } from "../map/GameMap";
|
import { GameMap } from "../map/GameMap";
|
||||||
|
import { BoxSet } from "./config/BoxSet";
|
||||||
|
|
||||||
// import { Role } from "../role/Role";
|
// import { Role } from "../role/Role";
|
||||||
// import { data } from "../data/data";
|
// import { data } from "../data/data";
|
||||||
/** 游戏模块 */
|
/** 游戏模块 */
|
||||||
@@ -17,6 +19,17 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
initialize: Initialize = null!;
|
initialize: Initialize = null!;
|
||||||
/** 游戏地图 */
|
/** 游戏地图 */
|
||||||
map: GameMap = 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;
|
// own: Role = null;
|
||||||
/** 游戏数据 */
|
/** 游戏数据 */
|
||||||
@@ -82,6 +95,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
vmAdd() {
|
vmAdd() {
|
||||||
console.log("smc vm_data vmAdd");
|
console.log("smc vm_data vmAdd");
|
||||||
VM.add(this.vm_data, "data");
|
VM.add(this.vm_data, "data");
|
||||||
|
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
for (var key in this.vm_data) {
|
for (var key in this.vm_data) {
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ export enum BoxSet {
|
|||||||
END_POINT = 360,
|
END_POINT = 360,
|
||||||
//游戏地平线
|
//游戏地平线
|
||||||
GAME_LINE = 0,
|
GAME_LINE = 0,
|
||||||
CSKILL_X = 200,
|
CSKILL_X = 280,
|
||||||
CSKILL_Y = 500,
|
CSKILL_Y = 420,
|
||||||
}
|
}
|
||||||
@@ -19,8 +19,8 @@ export class MapSkillComp extends CCComp {
|
|||||||
oops.message.on("hero_load", this.doHeroLoad, this);
|
oops.message.on("hero_load", this.doHeroLoad, this);
|
||||||
oops.message.on("do_use_skill", this.doSkill, this);
|
oops.message.on("do_use_skill", this.doSkill, this);
|
||||||
}
|
}
|
||||||
doSkill(){
|
doSkill(event: string, args: any){
|
||||||
this.addSkill();
|
this.addSkill(args.uuid);
|
||||||
}
|
}
|
||||||
addSkill(uuid:number=1001){
|
addSkill(uuid:number=1001){
|
||||||
let csk =ecs.getEntity<CSkill>(CSkill);
|
let csk =ecs.getEntity<CSkill>(CSkill);
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
|||||||
import { CSkillComp } from "./CSkillComp";
|
import { CSkillComp } from "./CSkillComp";
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
|
import { SkillSet } from "../common/config/CardSet";
|
||||||
|
|
||||||
/** CSkill 模块 */
|
/** CSkill 模块 */
|
||||||
@ecs.register(`CSkill`)
|
@ecs.register(`CSkill`)
|
||||||
export class CSkill extends ecs.Entity {
|
export class CSkill extends ecs.Entity {
|
||||||
@@ -14,6 +16,7 @@ export class CSkill extends ecs.Entity {
|
|||||||
|
|
||||||
/** 模块资源释放 */
|
/** 模块资源释放 */
|
||||||
destroy() {
|
destroy() {
|
||||||
|
this.remove(CSkillComp);
|
||||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
@@ -24,19 +27,30 @@ export class CSkill extends ecs.Entity {
|
|||||||
/** 加载角色 */
|
/** 加载角色 */
|
||||||
load(pos: Vec3 = Vec3.ZERO,camp:number = 1,uuid:number=1001) {
|
load(pos: Vec3 = Vec3.ZERO,camp:number = 1,uuid:number=1001) {
|
||||||
// var path = "game/monster/"+prefab_path;
|
// var path = "game/monster/"+prefab_path;
|
||||||
|
console.log("load skill",this)
|
||||||
var path = "game/heros/skill";
|
var path = "game/heros/skill";
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||||
var node = instantiate(prefab);
|
var node = instantiate(prefab);
|
||||||
var scene = smc.map.MapView.scene;
|
var scene = smc.map.MapView.scene;
|
||||||
node.parent = scene.entityLayer!.node!;
|
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.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))
|
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||||
const url = 'game/heros/skill';
|
const url = 'game/heros/skill';
|
||||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||||
const sprite = node.getChildByName("skill").getComponent(Sprite);
|
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)
|
this.skill_init(uuid,node,pos)
|
||||||
oops.message.dispatchEvent("cskill_load",this)
|
oops.message.dispatchEvent("cskill_load",this)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export class CSkillComp extends CCComp {
|
|||||||
// console.log("CSkillComp.node.isValid");
|
// console.log("CSkillComp.node.isValid");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// console.log("CSkillComp.node.destroy",this);
|
// console.log("CSkillComp.node.destroy",this);
|
||||||
this.node.destroy()
|
this.ent.destroy()
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
assets/script/game/monster/CSkillModel.ts
Normal file
26
assets/script/game/monster/CSkillModel.ts
Normal file
@@ -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];
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
9
assets/script/game/monster/CSkillModel.ts.meta
Normal file
9
assets/script/game/monster/CSkillModel.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "917ea8ef-8f1b-498c-8bfe-654cd28a86a5",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import { CardSet } from "../common/config/CardSet";
|
|||||||
import { HeroCard } from "./HeroCard";
|
import { HeroCard } from "./HeroCard";
|
||||||
import { HeroModelComp } from "./HeroModelComp";
|
import { HeroModelComp } from "./HeroModelComp";
|
||||||
import { Hero } from "./Hero";
|
import { Hero } from "./Hero";
|
||||||
|
import { MonsterViewComp } from "./MonsterViewComp";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
/** 视图层对象 */
|
/** 视图层对象 */
|
||||||
@@ -100,8 +101,10 @@ export class HeroCardViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
use_card(){
|
use_card(){
|
||||||
Hero
|
|
||||||
let heros = ecs.query(ecs.allOf(HeroModelComp))
|
let heros = ecs.query(ecs.allOf(HeroModelComp))
|
||||||
|
// let heross= ecs.query(ecs.allOf(MonsterViewComp))
|
||||||
|
// console.log("heross",heross)
|
||||||
if(heros.length >= 4){
|
if(heros.length >= 4){
|
||||||
oops.gui.toast("英雄数量达到上限");
|
oops.gui.toast("英雄数量达到上限");
|
||||||
this.node.setPosition(this.pos_x,this.pos_y);
|
this.node.setPosition(this.pos_x,this.pos_y);
|
||||||
|
|||||||
Reference in New Issue
Block a user