123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import { _decorator, Component, Label, Node, sys, Animation, resources, Prefab, instantiate, Tween, SpriteFrame, Sprite, UIOpacity } from 'cc';
- import { yinyue } from './yinyue';
- import { yinxiao } from './yinxiao';
- import { peiyin } from './peiyin';
- import { gameManager } from '../gameManager';
- import { config } from '../../config';
- import { sidebar_page } from '../sidebar/sidebar_page';
- import { SdkUtil } from '../../sdkUtil';
- const { ccclass, property } = _decorator;
- @ccclass('login_view')
- export class login_view extends Component {
- @property(Node) btn_start:Node = null;
- @property(Node) yinyue:Node = null;
- @property(Node) yinxiao:Node = null;
- @property(Node) peiyin:Node = null;
- @property(Node) clock_node:Node = null;
- @property(Node) book_img:Node = null;
- @property(Node) btn_clear_data:Node = null;
- @property(Node) btn_check_debug:Node = null;
- @property(Node) lab_check_debug:Node = null;
- @property(Node) btn_sidebar_box:Node = null;
- private m_start_game_call = null;
- private book_img_original_sf:SpriteFrame = null;
- private is_start_game:boolean = false;
- protected start(): void {
- this.book_img_original_sf = this.book_img.getComponent(Sprite).spriteFrame
- }
- public initView(start_game_call){
- if(config.debug){
- if(sys.platform==sys.Platform.MOBILE_BROWSER){
- this.btn_clear_data.active = true;
- this.btn_clear_data.off(Node.EventType.TOUCH_END)
- this.btn_clear_data.on(Node.EventType.TOUCH_END,()=>{
- sys.localStorage.clear()
- })
- }else{
- this.btn_clear_data.active = false;
- }
- }else{
- this.btn_clear_data.active = false;
- }
- this.btn_check_debug.on(Node.EventType.TOUCH_END,()=>{
- this.lab_check_debug.getComponent(Label).string = `id:${gameManager.getStaticUserData().id}`
- })
- this.m_start_game_call = start_game_call;
- this.btn_start.off(Node.EventType.TOUCH_END)
- this.btn_start.on(Node.EventType.TOUCH_END,()=>{
- if(this.is_start_game) { return }
- this.is_start_game = true
- if(this.m_start_game_call!=null){
- this.startGame()
- } else {
- this.is_start_game = false
- }
- gameManager.Singleton.sys_click_button_music()
- })
- gameManager.Singleton.mSceneManager.play_music()
- this.yinyue.getComponent(yinyue).initView()
- this.yinxiao.getComponent(yinxiao).initView()
- this.peiyin.getComponent(peiyin).initView()
- }
- private startGame() {
- this.node.getComponent(Animation).play()
- setTimeout(()=>{
- this.is_start_game = false
- this.m_start_game_call()
- },920)
- }
- public show() {
- this.clock_node.getComponent(Animation).play()
- if(this.btn_sidebar_box.active) {
- this.btn_sidebar_box.getComponent(Animation).play()
- }
- }
- public hide() {
- this.book_img.getComponent(Sprite).spriteFrame = this.book_img_original_sf
- this.clock_node.getComponent(Animation).stop()
- if(this.btn_sidebar_box.active) {
- this.btn_sidebar_box.getComponent(Animation).stop()
- }
- }
- public checkSidebar() {
- let userUnlockLevesData = gameManager.getUserUnlockLevesData()
- if(SdkUtil.ttCheckSceneShowRewards()==false || userUnlockLevesData.status==1) {
- return
- }
- this.btn_sidebar_box.active = true
- this.btn_sidebar_box.getComponent(Animation).play()
- this.btn_sidebar_box.off(Node.EventType.TOUCH_END)
- this.btn_sidebar_box.on(Node.EventType.TOUCH_END, ()=> {
- gameManager.Singleton.sys_click_button_music()
- resources.load("prefab/run/sidebar_page", Prefab, (err, prefab)=> {
- if(!err) {
- let node = instantiate(prefab)
- node.parent = this.node
- let isToEnterFromSidebar = SdkUtil.ttCheckToEnterFromSidebar()
- node.getComponent(sidebar_page).show(isToEnterFromSidebar, (view:sidebar_page)=> {
- gameManager.request_user_unlock_number_status(config.User_unlock_levels_number_status.RECEIVE,(data)=> {
- view.close()
- this.btn_sidebar_box.getComponent(Animation).stop()
- this.btn_sidebar_box.active = false
- },null)
- })
- }
- })
- })
- }
- }
|