This commit is contained in:
walkpan
2024-12-01 14:03:48 +08:00
parent 39b19eaef1
commit 90b081596f
15 changed files with 2606 additions and 2004 deletions

View File

@@ -16,8 +16,23 @@ export class Item extends ecs.Entity {
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;
switch(Items[uuid].lv){
case 1:
node.getChildByName("lv1").active = true;
break;
case 2:
node.getChildByName("lv2").active = true;
break;
case 3:
node.getChildByName("lv3").active = true;
break;
case 4:
node.getChildByName("lv4").active = true;
break;
}
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(pathName);

View File

@@ -3,6 +3,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { UIID } from "../common/config/GameUIConfig";
import { Items } from "../common/config/Items";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -14,8 +15,27 @@ export class ItemInfoComp extends CCComp {
this.node.getChildByName("info").getComponent(Label).string=args.info
let url = "gui/items";
let pathName= args.path;
this.node.getChildByName("lv1").active = false;
this.node.getChildByName("lv2").active = false;
this.node.getChildByName("lv3").active = false;
this.node.getChildByName("lv4").active = false;
switch(Items[args.uuid].lv){
case 1:
this.node.getChildByName("lv1").active = true;
break;
case 2:
this.node.getChildByName("lv2").active = true;
break;
case 3:
this.node.getChildByName("lv3").active = true;
break;
case 4:
this.node.getChildByName("lv4").active = true;
break;
}
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = this.node.getChildByName("item_bg").getChildByName("icon").getComponent(Sprite);
const sprite = this.node.getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
});
}

View File

@@ -45,10 +45,10 @@ export class VictoryComp extends CCComp {
this.rewards[0]={uuid:9001,num:gold}
for (let x = 1; x <= conut; x++) {
let item=ecs.getEntity<Item>(Item)
let r_i:any = RandomManager.instance.getRandomInt(0,MissionReward[this.reward_lv].length);
let r_i:any = RandomManager.instance.getRandomInt(0,MissionReward[this.reward_lv].length-1);
let ii = MissionReward[this.reward_lv][r_i];
let im = Items[ii];
// console.log("reward",r_i,ii,im)
console.log("reward",r_i,ii,im)
item.load(im.uuid,im.r_num,parent)
this.rewards[x]={uuid:im.uuid,num:im.r_num}
}