123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- import { _decorator, Component, instantiate, Node, Prefab, Vec3 } from 'cc';
- import { att_count_down, event_item, task_data, widget_item_data } from '../../data/data';
- import { config } from '../config';
- import { ui_base } from './ui/ui_base';
- import { sound_text_content } from './ui/sound_text_content';
- import { gameManager } from './gameManager';
- import { ui_manifestations } from './tips/ui_manifestations';
- import { tools } from '../tools';
- import { ClientEvent } from '../clientEvent';
- import { taskServce } from './TaskSchedule/taskServce';
- import { count_down } from './ui/count_down';
- import { fail_ani } from './ui/fail_ani';
- import { content_rule_and_tips } from './tips/content_rule_and_tips';
- import { back_title } from './ui/back_title';
- import { boss_tips } from './tips/boss_tips';
- const { ccclass, property } = _decorator;
- @ccclass('ui_layer')
- export class ui_layer extends Component {
- @property(Node) ui_content:Node = null;
- @property(Prefab) not_have_interact_prefab:Prefab = null;
- @property(Prefab) interact_input_prefab:Prefab = null;
- @property(Prefab) interact_page_prefab:Prefab = null;
- @property(Prefab) interact_puzzle_prefab:Prefab = null;
- @property(Prefab) pointer_ding_wei_prefab:Prefab = null;
- @property(Prefab) wei_chi_pointer_prefab:Prefab = null;
- @property(Prefab) interact_scene_prefab:Prefab = null;
- @property(Prefab) count_down_prefab:Prefab = null;
- @property(Prefab) boss_info_data_prefab:Prefab = null;
- @property(Node) ui_manifestations:Node = null;
- @property(Node) content_rule_and_tips:Node = null;
- @property(Node) content_count_down:Node = null;
- @property(Node) back_title_node:Node = null;
- @property(Node) boss_tips:Node = null;
- private mUIList:Map<number,Node> = new Map;
- private mCountDownLlist:Map<number,widget_item_data> = new Map;
- private mData:widget_item_data[] = null;
- private mAttCountDown:count_down = null;
- public initUi(ui_widge_list:widget_item_data[]){
- this.mData = ui_widge_list;
- this.loadAllUi()
- let scene_des = ""
- this.back_title_node.getComponent(back_title).initView(scene_des,this.onBack.bind(this))
- ClientEvent.on(config.EventRun.NOTICE_EVENT,this.beActive.bind(this),this)
- ClientEvent.on(config.EventRun.ON_SHOW_RULE_BTN,this.onChangeShowRuleStatus.bind(this),this)
- }
- public unInit(){
- this.mAttCountDown = null;
- this.mData = null;
- this.mCountDownLlist.clear()
- this.mUIList.clear()
- this.content_count_down.removeAllChildren()
- this.ui_content.removeAllChildren()
- this.ui_manifestations.active = false;
- this.content_rule_and_tips.active =false;
- this.boss_tips.active = false;
- ClientEvent.off(config.EventRun.NOTICE_EVENT,this.beActive.bind(this),this)
- ClientEvent.off(config.EventRun.ON_SHOW_RULE_BTN,this.onChangeShowRuleStatus.bind(this),this)
- }
- onBack(){
- if(gameManager.Singleton.getLevelData()!=null){
- gameManager.Singleton.backGameList()
- }
- }
- protected onDestroy(): void {
- ClientEvent.off(config.EventRun.NOTICE_EVENT,this.beActive.bind(this),this)
- }
- loadAllUi(){
- this.ui_content.removeAllChildren()
- for (let index = 0; index < this.mData.length; index++) {
- const ui_data = this.mData[index];
- let item: Node = null;
- switch (ui_data.att.top_data.top_ui_type) {
- case config.top_view_type.not_have_interact:
- item = instantiate(this.not_have_interact_prefab)
- break;
- case config.top_view_type.interact_input:
- item = instantiate(this.interact_input_prefab)
- break;
- case config.top_view_type.interact_page:
- item = instantiate(this.interact_page_prefab)
- break;
- case config.top_view_type.interact_puzzle:
- item = instantiate(this.interact_puzzle_prefab)
- break;
- case config.top_view_type.pointer_ding_wei:
- item = instantiate(this.pointer_ding_wei_prefab)
- break;
- case config.top_view_type.wei_chi_pointer:
- item = instantiate(this.wei_chi_pointer_prefab)
- break;
- case config.top_view_type.interact_scene:
- item = instantiate(this.interact_scene_prefab)
- break;
- case config.top_view_type.boss_info:
- item = instantiate(this.boss_info_data_prefab)
- break;
- }
- if(item!=null){
- item.parent = this.ui_content;
- item.getComponent(ui_base).initView(ui_data)
- this.mUIList.set(ui_data.att.id,item)
- }
- }
- }
- initCountDownList(list:widget_item_data[]){
- this.mCountDownLlist.clear()
- for (let index = 0; index < list.length; index++) {
- const widget = list[index];
- this.mCountDownLlist.set(widget.att.id,widget);
- }
- }
- beActive(widgetId:number,event:event_item){
- if(event.type===config.event_type.top_view){
- let ui = this.mUIList.get(widgetId)
- if(ui){
- ui.getComponent(ui_base).show()
- }else{
- tools.showToast(`配置弹窗错误!${widgetId}`)
- }
- }else if(event.type===config.event_type.active_event){
- let time_count = this.mCountDownLlist.get(widgetId)
- if(time_count!=null){
- if(this.mAttCountDown==null){
- this.createCountDown(time_count)
- }
- }
- }else if(event.type===config.event_type.stop_active_event){
- let time_count = this.mCountDownLlist.get(widgetId)
- if(time_count!=null){
- if(this.mAttCountDown==null){
- this.createCountDown(time_count)
- }
- }
- }else if(event.type===config.event_type.hide){
- let ui = this.mUIList.get(widgetId)
- if(ui){
- ui.getComponent(ui_base).hide()
- }
- }else if(event.type===config.event_type.show_scene_title){
- this.back_title_node.getComponent(back_title).updateTitle(event.event_item_show_scene_title_data.title)
- }
- }
- createCountDown(data:widget_item_data){
- let item = instantiate(this.count_down_prefab)
- item.parent = this.content_count_down;
- item.position = new Vec3(data.att.x,data.att.y)
- this.mAttCountDown = item.getComponent(count_down)
- this.mAttCountDown.init(data.att.count_down,this.onCountDownOver.bind(this))
- this.mAttCountDown.startCountDown()
- ClientEvent.dispatchEvent(config.EventRun.ON_COUNT_DOWN_START,this.mAttCountDown.getData().start_event_id)
- ClientEvent.on(config.EventRun.ON_WIDGET_FINISH_COLLECT_EVENT,this.onCountDownListening.bind(this),this)
- }
- onCountDownListening(event_id:number){
- if(this.mAttCountDown!=null){
- let att_count_down_data = this.mAttCountDown.getData()
- if(att_count_down_data.start_event_id===event_id){
- // tools.showToast("完成了所有的收集")
- let finish_id = this.mAttCountDown.getData().finish_event_id;
- if(finish_id!=-1){
- gameManager.Singleton.exeEvent(finish_id)
- }else{
- tools.showToast("没有配置完成的倒计时事件")
- }
- this.onCountDownOver(false)
- }
- }
-
- }
- onCountDownOver(isFail:boolean){
- let fail_event_id = this.mAttCountDown.getData().fail_event_id
- if(isFail){
- if(fail_event_id!=-1){
- ClientEvent.dispatchEvent(config.EventRun.ON_COUNT_DOWN_FAIL,fail_event_id)
- }else{
- tools.showToast("配置倒计时失败事件错误!")
- }
- }else{
- }
- this.mAttCountDown.node.removeFromParent()
- this.mAttCountDown = null;
- ClientEvent.off(config.EventRun.ON_WIDGET_FINISH_COLLECT_EVENT,this.onCountDownListening.bind(this),this)
- }
- initTaskUi(data:task_data){
- this.ui_manifestations.active = false;
- this.content_rule_and_tips.active = false;
- switch (data.type) {
- case config.task_type.zhao_xi_jie:
- if(data._zhao_xi_jie_data==null){
- return tools.showToast("找细节玩法没有配置!");
- }
- this.ui_manifestations.active = true;
- this.ui_manifestations.getComponent(ui_manifestations).initView(data._zhao_xi_jie_data)
- break;
- case config.task_type.guo_ju_qing:
- if(data._guo_ju_qing==null){
- return tools.showToast("过剧情玩法没有配置!");
- }
-
- this.content_rule_and_tips.active = true;
- this.content_rule_and_tips.getComponent(content_rule_and_tips).initView(()=>{
- if(gameManager.Singleton.IsOpenRuleStatus()){
- gameManager.Singleton.showTips()
- }else{
- gameManager.Singleton.showFindRuleTips()
- }
-
- },()=>{
- gameManager.Singleton.showRule()
- },data._guo_ju_qing.binding_event_id==-1)
- break;
- case config.task_type.guo_ju_qing_not_rule:
- console.log('ui_layer initTaskUi 过剧情-无规则 过剧情-无规则')
- break;
- case config.task_type.da_guai:
- if(data._da_guai==null){
- return tools.showToast("打boss玩法没有配置!");
- }
- let scene_data = gameManager.Singleton.getSceneManager().getSceneData()
- let res = scene_data.att.scene_rule_tips_data.tips_data.tips_tips.res;
- if(res.length<=0){
- }else{
- this.boss_tips.active = true;
- this.boss_tips.getComponent(boss_tips).initView(this.onClickBossTips.bind(this))
- }
- break;
- }
-
- }
- onClickBossTips(){
- gameManager.Singleton.showTips()
- }
- onChangeShowRuleStatus(){
- gameManager.Singleton.showRule()
- this.content_rule_and_tips.getComponent(content_rule_and_tips).showRuleBtn()
- }
- }
|