开箱 重做完成, item 信息更新修改

This commit is contained in:
2024-12-20 14:59:38 +08:00
parent 330f8da3da
commit e34eb5452b
6 changed files with 406 additions and 417 deletions

View File

@@ -87,7 +87,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": -400,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -99,8 +99,8 @@
}, },
"_lscale": { "_lscale": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 1, "x": 0.7,
"y": 1, "y": 0.7,
"z": 1 "z": 1
}, },
"_mobility": 0, "_mobility": 0,

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
export const BoxDrop={ export const BoxDrop={
1:[ 1:[
{uuid: 1009,dropRate: 10,num_max: 10,type:0}, {uuid: 1001,dropRate: 10,num_max: 10,type:0},
{uuid: 1010,dropRate: 10,num_max: 10,type:0}, {uuid: 1002,dropRate: 10,num_max: 10,type:0},
{uuid: 1011,dropRate: 10,num_max: 10,type:0}, {uuid: 1003,dropRate: 10,num_max: 10,type:0},
], ],
2:[ 2:[
{uuid: 1001,dropRate: 10,num_max: 10,type:0}, {uuid: 1001,dropRate: 10,num_max: 10,type:0},

View File

@@ -15,35 +15,12 @@ export class Item extends ecs.Entity {
var path = "game/gui/item"; var path = "game/gui/item";
var prefab: Prefab = oops.res.get(path, Prefab)!; var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab); var node = instantiate(prefab);
node.getChildByName("num").getComponent(Label).string = num.toString();
if(num==0){
node.getChildByName("num").getComponent(Label).string ="";
}
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);
});
node.parent = praent node.parent = praent
let iv = node.getComponent(ItemComp)!; let iv = node.getComponent(ItemComp)!;
iv.i_uuid = uuid iv.i_uuid = uuid
iv.num=num iv.num=num
iv.update_data(uuid,num)
this.add(iv) this.add(iv)
} }
/** 模块资源释放 */ /** 模块资源释放 */

View File

@@ -17,6 +17,34 @@ export class ItemComp extends CCComp {
//todo 设定icon 显示 //todo 设定icon 显示
} }
update_data(uuid:number,num:number){
this.i_uuid=uuid;
this.num=num;
this.node.getChildByName("num").getComponent(Label).string = num.toString();
if(num==0){
this.node.getChildByName("num").getComponent(Label).string ="";
}
let url = "gui/items";
let pathName= Items[uuid].path;
switch(Items[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("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
});
}
show_info(){ show_info(){
oops.gui.open(UIID.ItemInfo, {uuid:this.i_uuid,type:0}); oops.gui.open(UIID.ItemInfo, {uuid:this.i_uuid,type:0});
} }

View File

@@ -1,4 +1,4 @@
import { _decorator, instantiate, Prefab ,Node, Label, Sprite, resources, SpriteAtlas} from "cc"; import { _decorator, instantiate, Prefab ,Node, Label, Sprite, resources, SpriteAtlas, v3} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
@@ -9,6 +9,7 @@ import { HChipComp } from "../hero/HChipComp";
import { BoxDrop } from "../common/config/RewardSet"; import { BoxDrop } from "../common/config/RewardSet";
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager"; import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
import { SChipComp } from "../hero/SChipComp"; import { SChipComp } from "../hero/SChipComp";
import { ItemComp } from "./ItemComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -145,11 +146,13 @@ export class LuckHomeCompComp extends CCComp {
let path = "game/gui/hchip"; let path = "game/gui/hchip";
let prefab: Prefab = oops.res.get(path, Prefab)!; let prefab: Prefab = oops.res.get(path, Prefab)!;
let node = instantiate(prefab); let node = instantiate(prefab);
node.setScale(2,2)
let hc= node.getComponent(HChipComp) let hc= node.getComponent(HChipComp)
hc.update_data(uuid,num) hc.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox"); node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items"); node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5) }, 0.5)
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
node.destroy(); node.destroy();
@@ -160,34 +163,13 @@ export class LuckHomeCompComp extends CCComp {
var path = "game/gui/item"; var path = "game/gui/item";
var prefab: Prefab = oops.res.get(path, Prefab)!; var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab); var node = instantiate(prefab);
node.getChildByName("num").getComponent(Label).string = num.toString(); node.setScale(2,2)
if(num==0){ let ic= node.getComponent(ItemComp)
node.getChildByName("num").getComponent(Label).string =""; ic.update_data(uuid,num)
}
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);
});
node.parent = this.node.getChildByName("bbox"); node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items"); node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5) }, 0.5)
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
node.destroy(); node.destroy();
@@ -197,11 +179,13 @@ export class LuckHomeCompComp extends CCComp {
let path = "game/gui/schip"; let path = "game/gui/schip";
let prefab: Prefab = oops.res.get(path, Prefab)!; let prefab: Prefab = oops.res.get(path, Prefab)!;
let node = instantiate(prefab); let node = instantiate(prefab);
node.setScale(2,2)
let sc= node.getComponent(SChipComp) let sc= node.getComponent(SChipComp)
sc.update_data(uuid,num) sc.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox"); node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items"); node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5) }, 0.5)
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
node.destroy(); node.destroy();
@@ -213,7 +197,7 @@ export class LuckHomeCompComp extends CCComp {
var prefab: Prefab = oops.res.get(path, Prefab)!; var prefab: Prefab = oops.res.get(path, Prefab)!;
let box = instantiate(prefab); let box = instantiate(prefab);
box.parent = parent; box.parent = parent;
// parent.getChildByName("light").active = true; parent.getChildByName("light").active = true;
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
parent.getChildByName("light").active = false; parent.getChildByName("light").active = false;
}, 0.5) }, 0.5)