奖励物品基本完成
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
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 { ItemComp } from "./ItemComp";
|
||||
import { Items } from "../common/config/Items";
|
||||
|
||||
/** Item 模块 */
|
||||
@ecs.register(`Item`)
|
||||
@@ -14,6 +15,13 @@ export class Item extends ecs.Entity {
|
||||
var path = "game/gui/item";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.getChildByName("num").getComponent(Label).string = num.toString();
|
||||
let url = "gui/items";
|
||||
let pathName= Items[uuid].path;
|
||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = node.getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
});
|
||||
node.parent = praent
|
||||
let iv = node.getComponent(ItemComp)!;
|
||||
iv.i_uuid = uuid
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { _decorator, Label } from "cc";
|
||||
import { _decorator, Label, resources, Sprite, SpriteAtlas } 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 { Items } from "../common/config/Items";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -11,7 +12,7 @@ export class ItemComp extends CCComp {
|
||||
i_uuid:number = 0;
|
||||
num:number = 0;
|
||||
start() {
|
||||
this.node.getChildByName("num").getComponent(Label).string = this.num.toString();
|
||||
|
||||
//todo 设定icon 显示
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import { HCardComp } from "./HCardComp";
|
||||
import { MSkill } from "../skills/MSkill";
|
||||
import { MSkillComp } from "../skills/MSkillComp";
|
||||
import { VictoryComp } from "./VictoryComp";
|
||||
import { ItemComp } from "./ItemComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -107,6 +108,7 @@ export class MissionComp extends CCComp {
|
||||
let monsters:any= this.get_mons();
|
||||
let hcards:any= ecs.query(ecs.allOf(HCardComp));
|
||||
let mska:any= ecs.query(ecs.allOf(MSkillComp));
|
||||
let res:any= ecs.query(ecs.allOf(ItemComp));
|
||||
for(let i=0;i<mska.length;i++){
|
||||
mska[i].MSkillComp.reset()
|
||||
mska[i].MSkillComp.ent.destroy()
|
||||
@@ -129,6 +131,10 @@ export class MissionComp extends CCComp {
|
||||
monsters[i].HeroView.reset()
|
||||
monsters[i].HeroView.ent.destroy()
|
||||
}
|
||||
for(let i=0;i<res.length;i++){
|
||||
res[i].ItemComp.reset()
|
||||
res[i].ItemComp.ent.destroy()
|
||||
}
|
||||
}
|
||||
check_buff(){
|
||||
if(smc.vmdata.mission.a_exp >= smc.vmdata.mission.a_up_exp){
|
||||
|
||||
Reference in New Issue
Block a user