Files
heros/assets/script/game/map/MissionHomeComp.ts
panw 5ed5579142 refactor(heroUi): 精简和优化英雄界面预制资源
heriui载入 还有问题
- 移除了大量冗余节点和组件,减小预制体体积
- 调整部分节点名称和层级结构,更加清晰易维护
- 优化部分节点位置和尺寸属性,提升界面表现一致性
- 更新部分精灵资源引用及颜色配置,保证视觉效果正确
- 删除无用的动画剪辑和挂载组件,提升加载性能
- 重新整理属性覆盖信息,保持配置整洁规范
2025-10-10 16:55:01 +08:00

123 lines
4.5 KiB
TypeScript

import { _decorator, instantiate, Prefab, resources, Sprite, SpriteAtlas, UITransform } 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 { smc } from "../common/SingletonModuleComp";
import { GameEvent } from "../common/config/GameEvent";
import { HeroPageComp } from "./HeroPageComp";
import { finishCurrGuide, GuideConfig, startGuide } from "../common/config/Guide";
import { Timer } from "db://oops-framework/core/common/timer/Timer";
import { randomSpeek, Speeks } from "../common/config/Tasks";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MissionHomeComp')
@ecs.register('MissionHome', false)
export class MissionHomeComp extends CCComp {
speek_time:number=0
speek_cd:Timer=new Timer(10)
protected onLoad(): void {
this.on(GameEvent.MissionEnd,this.mission_end,this)
}
/** 视图层逻辑代码分离演示 */
start() {
this.home_active()
}
onEnable(){
this.startNextGuide(); // 启动第一个引导
startGuide(1)
startGuide(2)
}
update(dt:number){
if(this.speek_cd.update(dt)){
let speek=randomSpeek()
let slot=Math.floor(Math.random()*2)
oops.message.dispatchEvent(GameEvent.HeroSpeek,{words:speek[0],slot:slot})
console.log("[MissionHomeComp]:speek",speek,slot)
}
}
/** 启动下一个引导 */
private startNextGuide() {
// 检查是否还有未完成的引导
if(smc.guides[GuideConfig[0].key]==0){
oops.message.dispatchEvent(GameEvent.GuideStart,0)
}
}
start_mission() {
finishCurrGuide(1)
finishCurrGuide(10)
oops.message.dispatchEvent(GameEvent.MissionStart, {})
this.node.active=false;
}
mission_end(){
this.home_active()
}
home_active(){
this.uodate_data()
this.node.active=true
this.btn_func("","fight")
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
}
uodate_data(){
}
isWxClient(){
return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function';
}
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
// }
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}