refactor(heroUi): 精简和优化英雄界面预制资源
heriui载入 还有问题 - 移除了大量冗余节点和组件,减小预制体体积 - 调整部分节点名称和层级结构,更加清晰易维护 - 优化部分节点位置和尺寸属性,提升界面表现一致性 - 更新部分精灵资源引用及颜色配置,保证视觉效果正确 - 删除无用的动画剪辑和挂载组件,提升加载性能 - 重新整理属性覆盖信息,保持配置整洁规范
This commit is contained in:
@@ -52,70 +52,12 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
do_drop(drop_item:any[],game_data:any={exp:0,gold:0,diamond:0}){
|
||||
// console.log("[MissionComp] do_drop",drop_item,game_data)
|
||||
this.game_data["exp"]+=game_data.exp
|
||||
this.game_data["gold"]+=game_data.gold
|
||||
this.game_data["diamond"]+=game_data.diamond
|
||||
let parent=this.node.getChildByName("reward").getChildByName("items")
|
||||
let items=parent.children
|
||||
if(drop_item.length>0){
|
||||
for(let i=0;i<drop_item.length;i++){
|
||||
let d_item=drop_item[i]
|
||||
// 查找是否已存在该物品
|
||||
const existingItem = this.rewards.find(item => item.item_uuid === d_item.item_uuid);
|
||||
if(existingItem){
|
||||
// 如果已存在该物品,累加数量
|
||||
existingItem.count += d_item.count;
|
||||
}else{
|
||||
// 如果不存在该物品,添加新物品
|
||||
this.rewards.push({item_uuid: d_item.item_uuid, count: d_item.count});
|
||||
}
|
||||
}
|
||||
}
|
||||
for(let i=0;i<items.length;i++){
|
||||
let hitem=items[i].getComponent(ItemComp)
|
||||
for(let j=0;j<drop_item.length;j++){
|
||||
let d_item=drop_item[j]
|
||||
if(d_item.item_uuid==hitem.item_uuid){
|
||||
hitem.addItemCount(d_item.count)
|
||||
drop_item.splice(j,1)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if(drop_item.length>0){
|
||||
// console.log("[MissionComp] do_drop 剩余物品",drop_item)
|
||||
for(let i=0;i<drop_item.length;i++){
|
||||
let d_item=drop_item[i]
|
||||
let path="game/gui/item"
|
||||
const prefab = oops.res.get(path, Prefab);
|
||||
if (!prefab) {
|
||||
console.error("[MissionComp=>do_drop] 预制体加载失败:", path);
|
||||
return;
|
||||
}
|
||||
const node = instantiate(prefab) as unknown as Node;
|
||||
node.parent=parent
|
||||
node.getComponent(ItemComp)!.update_data(d_item.item_uuid,d_item.count)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
do_mon_dead(event:any,data:any){
|
||||
// console.log("[MissionComp] do_mon_dead",event,data)
|
||||
smc.vmdata.mission_data.mon_num--
|
||||
if(data.drops){
|
||||
if(data.drops.length>0){
|
||||
this.do_drop(data.drops,data.game_data)
|
||||
}
|
||||
}
|
||||
if(smc.vmdata.mission_data.mon_num<=0) {
|
||||
smc.vmdata.mission_data.level++
|
||||
if(smc.vmdata.mission_data.level < smc.vmdata.mission_data.max_mission){
|
||||
oops.message.dispatchEvent(GameEvent.NewWave)
|
||||
return
|
||||
}
|
||||
smc.addMission(1)
|
||||
oops.message.dispatchEvent(GameEvent.FightEnd,{victory:true})
|
||||
oops.gui.open(UIID.Victory,{victory:true,rewards:this.rewards,game_data:this.game_data})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
do_hero_dead(event:any,data:any){
|
||||
@@ -194,7 +136,6 @@ export class MissionComp extends CCComp {
|
||||
smc.vmdata.mission_data.fight_time=0
|
||||
smc.vmdata.mission_data.level=0
|
||||
this.rewards=[] // 改为数组,用于存储掉落物品列表
|
||||
this.node.getChildByName("reward").getChildByName("items").removeAllChildren()
|
||||
// console.log("[MissionComp]局内数据初始化",smc.vmdata.mission_data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user