67 lines
2.1 KiB
TypeScript
67 lines
2.1 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 { 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(){
|
|
}
|
|
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)
|
|
}
|
|
}
|
|
|
|
|
|
start_mission() {
|
|
|
|
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){
|
|
|
|
}
|
|
|
|
|
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
this.node.destroy();
|
|
}
|
|
} |