技能ui完成, todo 技能执行
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { instantiate, Prefab } from "cc";
|
||||
import { instantiate, Label, Prefab, resources, Sprite, SpriteAtlas } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { MSCardComp } from "./MSCardComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
|
||||
/** MSCard 模块 */
|
||||
@ecs.register(`MSCard`)
|
||||
@@ -15,17 +17,21 @@ export class MSCard extends ecs.Entity {
|
||||
}
|
||||
load(uuid:number=1001,parent:any,zone:number=0) {
|
||||
var path = "game/gui/MSCard";
|
||||
// var icon_path = "game/heros/herois"
|
||||
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
// const sprite = node.getChildByName("Mask").getChildByName("icon").getComponent(Sprite);
|
||||
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
|
||||
// });
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
console.log("load_hcard",prefab)
|
||||
var node = instantiate(prefab);
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = node.getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path);
|
||||
});
|
||||
|
||||
node.getChildByName("name").getComponent(Label).string = SkillSet[uuid].name
|
||||
|
||||
node.parent = parent
|
||||
var msc = node.getComponent(MSCardComp)!;
|
||||
msc.s_uuid= uuid
|
||||
msc.update_data()
|
||||
if(zone==1) {msc.is_update=true }else{msc.is_update=false}
|
||||
if(zone==2) {msc.is_select=true}else{msc.is_select=false}
|
||||
this.add(msc)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { _decorator } from "cc";
|
||||
import { _decorator, Label } 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 { smc } from "../common/SingletonModuleComp";
|
||||
import { MissionHomeComp } from "./MissionHomeComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -34,9 +35,12 @@ export class MSCardComp extends CCComp {
|
||||
}else{
|
||||
this.node.getChildByName("set").active=false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
update_data(){
|
||||
this.node.getChildByName("lv").getComponent(Label).string = smc.skills[this.s_uuid].lv.toString()+"级";
|
||||
this.node.getChildByName("update").getChildByName("cost").getComponent(Label).string =smc.skills[this.s_uuid].num.toString()+ " / "+(SkillSet[this.s_uuid].upcost*(1+smc.skills[this.s_uuid].lv)).toString()
|
||||
}
|
||||
select(){
|
||||
smc.mission.mskill=this.s_uuid
|
||||
this.mhc.select_skill()
|
||||
@@ -50,7 +54,19 @@ export class MSCardComp extends CCComp {
|
||||
this.node.getChildByName("set").getChildByName("btn").active=true
|
||||
}
|
||||
}
|
||||
|
||||
update_lv(){
|
||||
if(smc.skills[this.s_uuid].num <= (SkillSet[this.s_uuid].upcost*(1+smc.skills[this.s_uuid].lv))){
|
||||
oops.gui.toast("升级需要消耗"+SkillSet[this.s_uuid].upcost+"个能力石")
|
||||
return
|
||||
}
|
||||
smc.skills[this.s_uuid].num -= (SkillSet[this.s_uuid].upcost*(1+smc.skills[this.s_uuid].lv))
|
||||
smc.skills[this.s_uuid].lv++
|
||||
let mscards:any= ecs.query(ecs.allOf(MSCardComp));
|
||||
for(let i=0;i<mscards.length;i++){
|
||||
mscards[i].MSCardComp.update_data()
|
||||
}
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
@@ -149,23 +149,16 @@ export class MissionComp extends CCComp {
|
||||
this.clear_x1()
|
||||
}
|
||||
clear_x1(){
|
||||
smc.vmdata.items[9001].x1=smc.vmdata.items[9001].x10=0
|
||||
smc.vmdata.items[1001].x1=smc.vmdata.items[1001].x10=0
|
||||
smc.vmdata.items[1002].x1=smc.vmdata.items[1002].x10=0
|
||||
smc.vmdata.items[1003].x1=smc.vmdata.items[1003].x10=0
|
||||
smc.vmdata.items[1004].x1=smc.vmdata.items[1004].x10=0
|
||||
smc.vmdata.items[1005].x1=smc.vmdata.items[1005].x10=0
|
||||
smc.vmdata.items[1006].x1=smc.vmdata.items[1006].x10=0
|
||||
smc.vmdata.items[1007].x1=smc.vmdata.items[1007].x10=0
|
||||
smc.vmdata.items[1008].x1=smc.vmdata.items[1008].x10=0
|
||||
smc.vmdata.items[1009].x1=smc.vmdata.items[1009].x10=0
|
||||
smc.vmdata.items[1010].x1=smc.vmdata.items[1010].x10=0
|
||||
smc.vmdata.items[1011].x1=smc.vmdata.items[1011].x10=0
|
||||
smc.vmdata.items[1012].x1=smc.vmdata.items[1012].x10=0
|
||||
smc.vmdata.items[1013].x1=smc.vmdata.items[1013].x10=0
|
||||
smc.vmdata.items[1014].x1=smc.vmdata.items[1014].x10=0
|
||||
smc.vmdata.items[1015].x1=smc.vmdata.items[1015].x10=0
|
||||
smc.vmdata.items[1016].x1=smc.vmdata.items[1016].x10=0
|
||||
for (let i in smc.vmdata.items) {
|
||||
smc.vmdata.items[i].x1=smc.vmdata.items[i].x10=0
|
||||
}
|
||||
for (let i in smc.skills) {
|
||||
smc.skills[i].x1=smc.skills[i].x10=0
|
||||
}
|
||||
for (let i in smc.heros) {
|
||||
smc.heros[i].x1=smc.heros[i].x10=0
|
||||
}
|
||||
console.log("clear_x1",smc.vmdata.items,smc.skills,smc.heros)
|
||||
}
|
||||
mskill_init(){
|
||||
this.MSComp.group=BoxSet.HERO
|
||||
|
||||
@@ -4,6 +4,8 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { Items } from "../common/config/Items";
|
||||
import { Item } from "./Item";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -13,26 +15,80 @@ const { ccclass, property } = _decorator;
|
||||
export class ShopHomeComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
|
||||
this.get_items();
|
||||
}
|
||||
get_items(){
|
||||
let free = this.node.getChildByName("goods_list").getChildByName("free").getChildByName("items");
|
||||
let goods1 = this.node.getChildByName("goods_list").getChildByName("goods1").getChildByName("items");
|
||||
let goods2 = this.node.getChildByName("goods_list").getChildByName("goods2").getChildByName("items");
|
||||
let goods3 = this.node.getChildByName("goods_list").getChildByName("goods3").getChildByName("items");
|
||||
|
||||
for (let x = 0; x < smc.goods.free.length; x++) {
|
||||
let item=ecs.getEntity<Item>(Item)
|
||||
item.load(smc.goods.free[x].uuid,smc.goods.free[x].num,free)
|
||||
}
|
||||
for (let x = 0; x < smc.goods.goods1.length; x++) {
|
||||
let item=ecs.getEntity<Item>(Item)
|
||||
item.load(smc.goods.goods1[x].uuid,smc.goods.goods1[x].num,goods1)
|
||||
}
|
||||
for (let x = 0; x < smc.goods.goods2.length; x++) {
|
||||
let item=ecs.getEntity<Item>(Item)
|
||||
item.load(smc.goods.goods2[x].uuid,smc.goods.goods2[x].num,goods2)
|
||||
}
|
||||
|
||||
for (let x = 0; x < smc.goods.goods3.length; x++) {
|
||||
let item=ecs.getEntity<Item>(Item)
|
||||
item.load(smc.goods.goods3[x].uuid,smc.goods.goods3[x].num,goods3)
|
||||
}
|
||||
// for (let x = 0; x < smc.goods.goods4.length; x++) {
|
||||
// let item=ecs.getEntity<Item>(Item)
|
||||
// item.load(smc.goods.goods4[x].uuid,smc.goods.goods4[x].num,goods4)
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
item_show(e:any,val:any){
|
||||
oops.gui.open(UIID.ItemInfo, Items[val]);
|
||||
}
|
||||
get_free(){
|
||||
console.log("免费领取")
|
||||
if(smc.vmdata.free.buy <= 0){
|
||||
oops.gui.toast("今日领取次数已用完");
|
||||
return
|
||||
}
|
||||
smc.vmdata.free.buy--
|
||||
}
|
||||
get_goods1(){
|
||||
console.log("购买商品1")
|
||||
if(smc.vmdata.goods1.buy <= 0){
|
||||
oops.gui.toast("今日购买次数已用完");
|
||||
return
|
||||
}
|
||||
smc.vmdata.goods1.buy--
|
||||
}
|
||||
get_goods2(){
|
||||
console.log("购买商品2")
|
||||
if(smc.vmdata.goods2.buy <= 0){
|
||||
oops.gui.toast("今日购买次数已用完");
|
||||
return
|
||||
}
|
||||
smc.vmdata.goods2.buy--
|
||||
}
|
||||
get_goods3(){
|
||||
console.log("购买商品3")
|
||||
if(smc.vmdata.goods3.buy <= 0){
|
||||
oops.gui.toast("今日购买次数已用完");
|
||||
return
|
||||
}
|
||||
smc.vmdata.goods3.buy--
|
||||
}
|
||||
get_goods4(){
|
||||
console.log("购买商品4")
|
||||
if(smc.vmdata.goods4.buy <= 0){
|
||||
oops.gui.toast("今日购买次数已用完");
|
||||
return
|
||||
}
|
||||
smc.vmdata.goods4.buy--
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
|
||||
35
assets/script/game/map/SkillHomeComp.ts
Normal file
35
assets/script/game/map/SkillHomeComp.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { _decorator, UITransform } 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 { MSklist } from "../common/config/SkillSet";
|
||||
import { MSCard } from "./MSCard";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('SkillHomeComp')
|
||||
@ecs.register('SkillHome', false)
|
||||
export class SkillHomeComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
this.load_skill_card()
|
||||
}
|
||||
|
||||
load_skill_card(){
|
||||
let ms_num:number =MSklist.length
|
||||
let parent= this.node.getChildByName("skills").getChildByName("view").getChildByName("content")
|
||||
let height=ms_num*135
|
||||
parent.getComponent(UITransform).width=height
|
||||
for (let i = 0; i < ms_num; i++) {
|
||||
let msc =ecs.getEntity<MSCard>(MSCard)
|
||||
msc.load(MSklist[i],parent,1)
|
||||
}
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/map/SkillHomeComp.ts.meta
Normal file
9
assets/script/game/map/SkillHomeComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "cf5847e5-a4d7-4a84-8064-024371ea2125",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user