refactor(heroUi): 精简和优化英雄界面预制资源
heriui载入 还有问题 - 移除了大量冗余节点和组件,减小预制体体积 - 调整部分节点名称和层级结构,更加清晰易维护 - 优化部分节点位置和尺寸属性,提升界面表现一致性 - 更新部分精灵资源引用及颜色配置,保证视觉效果正确 - 删除无用的动画剪辑和挂载组件,提升加载性能 - 重新整理属性覆盖信息,保持配置整洁规范
This commit is contained in:
284
assets/resources/game/gui/hui.prefab
Normal file
284
assets/resources/game/gui/hui.prefab
Normal file
@@ -0,0 +1,284 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.Prefab",
|
||||
"_name": "hui",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_native": "",
|
||||
"data": {
|
||||
"__id__": 1
|
||||
},
|
||||
"optimizationPolicy": 0,
|
||||
"persistent": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "hui",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": null,
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 12
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 14
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 1073741824,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "hero",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
},
|
||||
{
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 9
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 24.526,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -1,
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 1073741824,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 4
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 256,
|
||||
"height": 256
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "b3BhGcxeJJ9IRMJTbKLOQF"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
"_dstBlendFactor": 4,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "9e5ec114-01a4-47d3-b7b7-df3b90209c91@6ce90",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
"_type": 0,
|
||||
"_fillType": 0,
|
||||
"_sizeMode": 1,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_useGrayscale": false,
|
||||
"_atlas": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "78s2jWtghFSJ10WVZvCYyj"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Animation",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 8
|
||||
},
|
||||
"playOnLoad": true,
|
||||
"_clips": [],
|
||||
"_defaultClip": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "04ZDVs86tM0LEHGsLe8zMR"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "13JkxatXdBLKqRNIkqgxSF",
|
||||
"instance": null,
|
||||
"targetOverrides": null,
|
||||
"nestedPrefabInstanceRoots": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 220,
|
||||
"height": 300
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "7bkSfj+OVGuqT1IoJ0Rnz6"
|
||||
},
|
||||
{
|
||||
"__type__": "d625fKFNwZPLr8w4D408WZQ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 13
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "bcpbQYKUNJ/4vYjVze363q"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "c46/YsCPVOJYA4mWEpNYRx",
|
||||
"instance": null,
|
||||
"targetOverrides": null
|
||||
}
|
||||
]
|
||||
13
assets/resources/game/gui/hui.prefab.meta
Normal file
13
assets/resources/game/gui/hui.prefab.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ver": "1.1.50",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "1d27f1fe-b64a-41b3-ab71-e1922a0f3d37",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "hui"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Animation, AnimationClip, CCInteger, Component, Label, Node, resources } from 'cc';
|
||||
import { _decorator, Animation, AnimationClip, CCInteger, Component, instantiate, Label, Node, Prefab, resources, v3 } from 'cc';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { HeroInfo } from '../common/config/heroSet';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
@@ -12,66 +12,39 @@ const { ccclass, property } = _decorator;
|
||||
export class HeroReadyCom extends Component {
|
||||
@property(CCInteger)
|
||||
slot: number=0;
|
||||
@property(Prefab)
|
||||
hero_prefab: Prefab = null!;
|
||||
protected onLoad(): void {
|
||||
oops.message.on(GameEvent.UpdateHero,this.update_hero,this)
|
||||
oops.message.on(GameEvent.UpdateFightHero,this.update_hero,this)
|
||||
oops.message.on(GameEvent.HeroSpeek,this.to_speek,this)
|
||||
|
||||
}
|
||||
start() {
|
||||
this.hide_speek()
|
||||
this.update_hero()
|
||||
|
||||
}
|
||||
hide_speek(){
|
||||
this.node.getChildByName("tooltip").active=false
|
||||
}
|
||||
to_speek(e:any,args:any){
|
||||
console.log("[HeroReadyCom]:to_speek",args,this.slot)
|
||||
if(args.slot!=this.slot) return
|
||||
if(smc.fight_heros[this.slot]==0) return
|
||||
this.node.getChildByName("tooltip").active=true
|
||||
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = args.words
|
||||
this.scheduleOnce(()=>{
|
||||
this.hide_speek()
|
||||
},3)
|
||||
this.add_heros()
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
update_hero(){
|
||||
let hero = smc.fight_heros[this.slot]
|
||||
// console.log("[HeroReadyCom]hero",hero,smc.fight_heros,this.slot)
|
||||
if(hero==0){
|
||||
this.no_hero()
|
||||
return
|
||||
add_heros(){
|
||||
let heros=smc.heros
|
||||
let x=0
|
||||
for(let key in heros){
|
||||
this.add_hero(heros[key].uuid,x)
|
||||
console.log("[HeroReadyCom]:add_hero",heros[key],x)
|
||||
x++
|
||||
}
|
||||
this.node.getChildByName("icon").active=true
|
||||
this.node.getChildByName("add").active=false
|
||||
}
|
||||
add_hero(hero:any,pos:number){
|
||||
let hero_data = HeroInfo[hero]
|
||||
// console.log("[HeroReadyCom]hero_data",smc.fight_heros,hero,smc.fight_heros[this.slot],this.slot,hero_data)
|
||||
if(!this.hero_prefab) return
|
||||
const node = instantiate(this.hero_prefab) as unknown as Node;
|
||||
let anm_path=hero_data.path
|
||||
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
|
||||
this.node.getChildByName("icon").getComponent(Animation).addClip(clip);
|
||||
this.node.getChildByName("icon").getComponent(Animation).play("idle");
|
||||
node.getChildByName("hero").getComponent(Animation).addClip(clip);
|
||||
node.getChildByName("hero").getComponent(Animation).play("idle");
|
||||
});
|
||||
this.node.getChildByName("lv").active=true
|
||||
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[hero].lv.toString()
|
||||
// console.log("[HeroReadyCom]clip",this.node.getChildByName("icon").getComponent(Animation))
|
||||
|
||||
node.parent = this.node;
|
||||
node.setPosition(v3(-pos*100,0,0))
|
||||
}
|
||||
|
||||
no_hero(){
|
||||
this.node.getChildByName("lv").active=false
|
||||
this.node.getChildByName("add").active=true
|
||||
this.node.getChildByName("icon").active=false
|
||||
}
|
||||
select_hero(){
|
||||
if(oops.gui.has(UIID.HeroSelect)) return
|
||||
if(smc.fight_heros[this.slot]==0) {
|
||||
finishCurrGuide(8)
|
||||
}
|
||||
oops.gui.open(UIID.HeroSelect,{slot:this.slot})
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -48,12 +48,13 @@ export class MissionHeroCompComp extends CCComp {
|
||||
smc.vmdata.mission_data.hero_num=0
|
||||
// console.log("[MissionHeroComp]:fight_ready",smc.fight_heros,Object.keys(smc.fight_heros).length)
|
||||
let heros:any = smc.fight_heros
|
||||
for(let i=0;i<Object.keys(heros).length;i++){
|
||||
if(heros[i]!=0){
|
||||
// console.log("[MissionHeroComp]:fight_ready",heros[i])
|
||||
this.addHero(heros[i],false)
|
||||
}
|
||||
}
|
||||
this.addHero(heros[0],false)
|
||||
// for(let i=0;i<Object.keys(heros).length;i++){
|
||||
// if(heros[i]!=0){
|
||||
// // console.log("[MissionHeroComp]:fight_ready",heros[i])
|
||||
// this.addHero(heros[i],false)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(smc.mission.status != 1) return
|
||||
|
||||
@@ -69,50 +69,50 @@ export class MissionHomeComp extends CCComp {
|
||||
}
|
||||
btn_func(e:string,data:any){
|
||||
|
||||
// console.log("[MissionHomeComp]:btn_func",e,data)
|
||||
let page_heros=this.node.getChildByName("heros_page")
|
||||
let page_shop=this.node.getChildByName("shop_page")
|
||||
// let page_fight=this.node.getChildByName("fight_page")
|
||||
// let page_skill=this.node.getChildByName("skill_page")
|
||||
// let page_set=this.node.getChildByName("set_page")
|
||||
let btns=this.node.getChildByName("btns")
|
||||
let btn_shop =btns.getChildByName("shop")
|
||||
let btn_heros =btns.getChildByName("heros")
|
||||
let btn_fight =btns.getChildByName("fight")
|
||||
let btn_skill =btns.getChildByName("skill")
|
||||
let btn_set =btns.getChildByName("set")
|
||||
btn_shop.getChildByName("act").active=false
|
||||
btn_heros.getChildByName("act").active=false
|
||||
btn_fight.getChildByName("act").active=false
|
||||
btn_skill.getChildByName("act").active=false
|
||||
btn_set.getChildByName("act").active=false
|
||||
page_heros.active=false
|
||||
page_shop.active=false
|
||||
switch(data){
|
||||
case "shop":
|
||||
page_shop.active=true
|
||||
btn_shop.getChildByName("act").active=true
|
||||
break
|
||||
case "heros":
|
||||
finishCurrGuide(2)
|
||||
page_heros.active=true
|
||||
btn_heros.getChildByName("act").active=true
|
||||
break
|
||||
case "fight":
|
||||
finishCurrGuide(7)
|
||||
startGuide(8)
|
||||
btn_fight.getChildByName("act").active=true
|
||||
break
|
||||
case "skill":
|
||||
btn_skill.getChildByName("act").active=true
|
||||
break
|
||||
case "set":
|
||||
btn_set.getChildByName("act").active=true
|
||||
break
|
||||
default:
|
||||
btn_fight.getChildByName("act").active=true
|
||||
break
|
||||
}
|
||||
// // console.log("[MissionHomeComp]:btn_func",e,data)
|
||||
// let page_heros=this.node.getChildByName("heros_page")
|
||||
// let page_shop=this.node.getChildByName("shop_page")
|
||||
// // let page_fight=this.node.getChildByName("fight_page")
|
||||
// // let page_skill=this.node.getChildByName("skill_page")
|
||||
// // let page_set=this.node.getChildByName("set_page")
|
||||
// let btns=this.node.getChildByName("btns")
|
||||
// let btn_shop =btns.getChildByName("shop")
|
||||
// let btn_heros =btns.getChildByName("heros")
|
||||
// let btn_fight =btns.getChildByName("fight")
|
||||
// let btn_skill =btns.getChildByName("skill")
|
||||
// let btn_set =btns.getChildByName("set")
|
||||
// btn_shop.getChildByName("act").active=false
|
||||
// btn_heros.getChildByName("act").active=false
|
||||
// btn_fight.getChildByName("act").active=false
|
||||
// btn_skill.getChildByName("act").active=false
|
||||
// btn_set.getChildByName("act").active=false
|
||||
// page_heros.active=false
|
||||
// page_shop.active=false
|
||||
// switch(data){
|
||||
// case "shop":
|
||||
// page_shop.active=true
|
||||
// btn_shop.getChildByName("act").active=true
|
||||
// break
|
||||
// case "heros":
|
||||
// finishCurrGuide(2)
|
||||
// page_heros.active=true
|
||||
// btn_heros.getChildByName("act").active=true
|
||||
// break
|
||||
// case "fight":
|
||||
// finishCurrGuide(7)
|
||||
// startGuide(8)
|
||||
// btn_fight.getChildByName("act").active=true
|
||||
// break
|
||||
// case "skill":
|
||||
// btn_skill.getChildByName("act").active=true
|
||||
// break
|
||||
// case "set":
|
||||
// btn_set.getChildByName("act").active=true
|
||||
// break
|
||||
// default:
|
||||
// btn_fight.getChildByName("act").active=true
|
||||
// break
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user