完成奖励 物品和英雄碎片奖励界面,todo 技能修改为碎片升级+技能升级+ui奖励碎片ui制作

This commit is contained in:
2024-12-17 16:01:50 +08:00
parent c4cb0e737b
commit 3aca9948f2
10 changed files with 1543 additions and 1278 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "40f0eb45-ca9b-486a-aa48-936a2ec8d05d",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "reward"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -22,14 +22,6 @@ export class SingletonModuleComp extends ecs.Comp {
initialize: Initialize = null!;
/** 游戏地图 */
map: GameMap = null!;
cards: any = [
{uuid:9001,type:1},
];
item_list: any = [
{uuid:6005,type:2},{uuid:6006,type:2},{uuid:6101,type:2},{uuid:6102,type:2}, {uuid:6210,type:2},{uuid:6211,type:2},{uuid:6212,type:2},
// {uuid:6213,type:2},{uuid:6214,type:2},{uuid:6215,type:2},
// {uuid:6216,type:2},{uuid:6217,type:2},{uuid:6218,type:2}
];
mission:any={
play:false,
pause:false,
@@ -55,9 +47,9 @@ export class SingletonModuleComp extends ecs.Comp {
};
/** 游戏主角 */
heros:any={
9001:{uuid:9001,lv:1,exp:0,slv:0,stone:0,num:100,x1:0,x10:0},
9002:{uuid:9002,lv:2,exp:0,slv:1,stone:0,num:80,x1:0,x10:0},
9003:{uuid:9003,lv:3,exp:0,slv:2,stone:0,num:90,x1:0,x10:0},
9001:{uuid:9001,lv:1,exp:0,slv:0,stone:0,num:100,x1:1,x10:0},
9002:{uuid:9002,lv:2,exp:0,slv:1,stone:0,num:80,x1:2,x10:0},
9003:{uuid:9003,lv:3,exp:0,slv:2,stone:0,num:90,x1:3,x10:0},
};
goods:any={
free: [ {uuid:9001,num:100000}, {uuid:1001,num:10}, {uuid:1002,num:10}, {uuid:1007,num:10},],
@@ -66,23 +58,23 @@ export class SingletonModuleComp extends ecs.Comp {
goods3:[ {uuid:1007,num:100}, {uuid:9002,num:1} ],
goods4:[ {uuid:9001,num:100}, {uuid:9002,num:1} ],
};
items:{
1001:{num:1000,x1:1,x10:0},
1002:{num:1000,x1:2,x10:0},
1003:{num:1000,x1:3,x10:0},
1004:{num:1000,x1:0,x10:0},
1005:{num:1000,x1:0,x10:0},
1006:{num:1000,x1:0,x10:0},
1007:{num:1000,x1:0,x10:0},
1008:{num:1000,x1:0,x10:0},
1009:{num:1000,x1:0,x10:0},
1010:{num:1000,x1:0,x10:0},
1011:{num:1000,x1:0,x10:0},
1012:{num:1000,x1:0,x10:0},
1013:{num:1000,x1:0,x10:0},
1014:{num:1000,x1:0,x10:0},
1015:{num:1000,x1:0,x10:0},
1016:{num:1000,x1:0,x10:0},
items:any={
1001:{uuid:1001,num:1000,x1:1,x10:0},
1002:{uuid:1002,num:1000,x1:0,x10:0},
1003:{uuid:1003,num:1000,x1:0,x10:0},
1004:{uuid:1004,num:1000,x1:0,x10:0},
1005:{uuid:1005,num:1000,x1:0,x10:0},
1006:{uuid:1006,num:1000,x1:0,x10:0},
1007:{uuid:1007,num:1000,x1:0,x10:0},
1008:{uuid:1008,num:1000,x1:0,x10:0},
1009:{uuid:1009,num:1000,x1:0,x10:0},
1010:{uuid:1010,num:1000,x1:0,x10:0},
1011:{uuid:1011,num:1000,x1:0,x10:0},
1012:{uuid:1012,num:1000,x1:0,x10:0},
1013:{uuid:1013,num:1000,x1:0,x10:0},
1014:{uuid:1014,num:1000,x1:0,x10:0},
1015:{uuid:1015,num:1000,x1:0,x10:0},
1016:{uuid:1016,num:1000,x1:0,x10:0},
};
fight_heros=[9001,9002]
mheros:any = [];

View File

@@ -117,6 +117,7 @@ export class MissionComp extends CCComp {
rewards[i].ItemComp.ent.destroy()
}
this.to_mission_home()
oops.gui.open(UIID.Victory)
}
to_mission_home(){
let home =this.node.parent.getComponent(CardControllerComp);
@@ -146,7 +147,7 @@ export class MissionComp extends CCComp {
smc.vmdata.mission.mcrit=0
smc.vmdata.mission.mdead=0
smc.vmdata.mission.mdodge=0
this.clear_x1()
// this.clear_x1()
}
clear_x1(){
for (let i in smc.items) {

View File

@@ -0,0 +1,20 @@
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
/** Reward 模块 */
@ecs.register(`Reward`)
export class Reward extends ecs.Entity {
/** 实始添加的数据层组件 */
protected init() {
// this.addComponents<ecs.Comp>();
}
load() {
// this.loadData(data);
}
/** 模块资源释放 */
destroy() {
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
super.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "e1ec0b04-8288-4c12-a6ef-ee8ebb9a3282",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,60 @@
import { _decorator, instantiate, Label, Prefab, 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { Items } from "../common/config/Items";
import { HChipComp } from "../hero/HChipComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('RewardComp')
@ecs.register('RewardComp', false)
export class RewardComp extends CCComp {
i_uuid: number = 0;
x1: number = 0;
x10: number = 0;
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this);
}
init(uuid:number,x1:number,x10:number,parent:any,type:number=0){
if(type==0){
var icon_path = "gui/items"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = this.node.getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(Items[uuid].path);
});
}
if(type==1){
this.node.getChildByName("icon").active=false
this.node.getChildByName("hchip").active=true
let hchipcomp= this.node.getChildByName("hchip").getComponent(HChipComp)
hchipcomp.update_data(uuid,0)
}
this.node.getChildByName("x1").getComponent(Label).string = x1.toString()
this.node.getChildByName("x10").getComponent(Label).string = x10.toString()
this.node.parent = parent
}
protected onDestroy(): void {
console.log("释放奖励界面");
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "0d093357-3eb4-48e9-812e-3c4ab37a36c9",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,4 +1,4 @@
import { _decorator, Label ,v3} from "cc";
import { _decorator, instantiate, Label ,Prefab,resources,Sprite,SpriteAtlas,v3} 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
@@ -11,6 +11,7 @@ import { Items } from "../common/config/Items";
import { Item } from "./Item";
import { UIID } from "../common/config/GameUIConfig";
import { PopViewParams, UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
import { RewardComp} from "./RewardComp";
const { ccclass, property } = _decorator;
@@ -26,30 +27,62 @@ export class VictoryComp extends CCComp {
}
onAdded(args: any) {
console.log("VictoryComp onAdded",args)
let items=smc.items
if(smc.vmdata.gold.x1 > 0) this.node.getChildByName("items").getChildByName("gold").active=true
if(smc.vmdata.skp.x1 > 0) this.node.getChildByName("items").getChildByName("skp").active=true
if(smc.vmdata.exp.x1 > 0) this.node.getChildByName("items").getChildByName("exp").active=true
if(smc.vmdata.gold.x1 > 0) {
this.node.getChildByName("items").getChildByName("gold").active=true
smc.vmdata.gold.x10=smc.vmdata.gold.x1*9
}
if(smc.vmdata.skp.x1 > 0) {
this.node.getChildByName("items").getChildByName("skp").active=true
smc.vmdata.skp.x10=smc.vmdata.skp.x1*9
}
if(smc.vmdata.exp.x1 > 0) {
this.node.getChildByName("items").getChildByName("exp").active=true
smc.vmdata.exp.x10=smc.vmdata.exp.x1*9
}
var parent = this.node.getChildByName("items")
for (let i in smc.items) {
if(smc.items[i].x1 > 0){
smc.items[i].x10 =smc.items[i].x1*9
var path = "game/gui/reward";
var prefab: Prefab = oops.res.get(path, Prefab)!;
console.log("VictoryComp",prefab,smc.items[i])
var node = instantiate(prefab);
let rc:any= node.getComponent(RewardComp)!;
rc.init(smc.items[i].uuid,smc.items[i].x1,smc.items[i].x10,parent,0)
}
}
for (let i in smc.skills) {
}
for (let i in smc.heros) {
if(smc.heros[i].x1 > 0){
smc.heros[i].x10 =smc.heros[i].x1*9
var path = "game/gui/reward";
var prefab: Prefab = oops.res.get(path, Prefab)!;
console.log("VictoryComp",prefab,smc.heros[i])
var node = instantiate(prefab);
let rc:any= node.getComponent(RewardComp)!;
rc.init(smc.heros[i].uuid,smc.heros[i].x1,smc.heros[i].x10,parent,1)
}
}
}
do_x10(){
console.log("do_x10",smc.vmdata)
for (let i in smc.items) {
smc.items[i].num+=smc.items[i].x10
}
for (let i in smc.heros) {
smc.heros[i].num+=smc.heros[i].x10
}
this.clear_x1()
this.reset();
}
do_x1(){
console.log("x1",smc.vmdata)
this.clear_x1()
this.reset();
}
clear_x1(){
@@ -72,7 +105,9 @@ export class VictoryComp extends CCComp {
console.log("item_show",val)
oops.gui.open(UIID.ItemInfo, Items[val]);
}
protected onDestroy(): void {
console.log("释放胜利界面");
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
oops.gui.remove(UIID.Victory, false);