xxx

import { ui } from "./../../ui/layaMaxUI"
import Global from "../Global"
import Const from "../Const"
import GameView from "./GameView"

export default class HomeView extends ui.HomeViewUI {
    isGameDataLoaded
    navigator
    guide
    settingIconRolling
    static instance

    constructor() {
        if(Laya.Browser.onMiniGame)
        {
            Laya.Browser.window.wx.showShareMenu();
            Laya.Browser.window.wx.onShareAppMessage(function(){
            return{title:"听说这游戏只有不到1%的人能通过第一关!",imageUrl:"res/texture/home/we.jpeg"}
            });
        }
       
        super()
        var t = this
        return t.isGameDataLoaded = !1, t.guide = !1, t.settingIconRolling = !1, console.log("HomeView constructor()"), 
        HomeView.instance = t, GameView.openInstance(), t;
    }
    
    static openInstance() {
        this.instance ? this.instance.onOpened() : Laya.Scene.open(Const.URL_HomeView, !1);
    }

    onOpened() {
        console.log("HomeView onOpened()")
        if (this.isGameDataLoaded) {
            if (GameView.instance) {
                GameView.instance.showDiamond()
                //GameView.instance.hideNavigator()'
            }

            // // 广告
            // n.randomShowBanner(!0)

            //互推导航
            //  if (Global.config.allow_navigator) {
            //      if (this.navigator) {
                   
            //          this.navigator.loadHomeIconInfoList();
            //      }
            //        else {
            //          this.navigator = new u.default(r.default)

            //          this.navigator.createHomeIcons(this.homeIconBox, this, ["home_icon_1", "home_icon_2", "home_icon_3", "home_icon_4", "home_icon_5", "home_icon_6", "home_icon_7", "home_icon_8", "home_icon_9", "home_icon_10"])

            //          this.navigator.createDrawer(this.drawerBox, "game_drawer")
            //          this.navigator.createMoreGame(this.moreGameBox, this.moreGameOpenButtonBox, "game_more")
            
            //      }
            
        }

        this.visible = !0;
    }


    onEnable() 
    {
        console.log("HomeView onEnable()")
        this.bindButtons()  
        this.versionLabel.changeText("v" + Const.VERSION)
        if (Laya.Browser.onMiniGame) {
            // this.initWeixin();
            //Laya.Stat.show();
            this.onGameDataLoaded();
        } else {
            //Laya.Stat.show();
            this.onGameDataLoaded();
        }
    }

    bindButtons() {
        var e = this;
        // 开始游戏
        this.startButton.on(Laya.Event.CLICK, this, function() {
            if (GameView.instance) {
                // Laya.Browser.onMiniGame && r.default.traceEvent("Click_Startgame")
                e.hide()
                GameView.openInstance()
                GameView.instance.loadCurrentLevelMission()
            }
        }     
    )

         // this.settingButton.on(Laya.Event.CLICK, this, function() {
        //     e.vibrateOff.visible || e.vibrateOn.visible ? e.hideSettings() : e.showSettings();
        // })
        // this.soundOn.on(Laya.Event.CLICK, this, function() {
        //     e.soundOn.visible = !1, e.soundOff.visible = !0, l.default.gameData.soundEnabled = !1, 
        //     e.updateGameData();
        // })
        // this.soundOff.on(Laya.Event.CLICK, this, function() {
        //     e.soundOn.visible = !0, e.soundOff.visible = !1, l.default.gameData.soundEnabled = !0, 
        //     e.updateGameData();
        // })
        // this.vibrateOn.on(Laya.Event.CLICK, this, function() {
        //     e.vibrateOn.visible = !1, e.vibrateOff.visible = !0, l.default.gameData.vibrateEnable = !1, 
        //     e.updateGameData();
        // })
        // this.vibrateOff.on(Laya.Event.CLICK, this, function() {
        //     e.vibrateOn.visible = !0, e.vibrateOff.visible = !1, l.default.gameData.vibrateEnable = !0, 
        //     e.updateGameData();
        // });
    }

    hide() {
        // n.hideCurrentBanner()
        this.visible = !1
    }

    // // 微信分享设置
    // initWeixin() {
    //     s.default.showShareMenu({
    //         withShareTicket: !0
    //     })
    //     s.default.onShareAppMessage(function() {
    //         var e = r.default.createShareOptions({
    //             pos: "ShareAppButton"
    //         });
    //         return {
    //             title: e.title,
    //             imageUrl: e.imageUrl,
    //             query: e.query
    //         };
    //     })
    //     r.default.init({
    //         host: "ws.lesscool.cn",
    //         version: o.VERSION,
    //         appid: 1078,
    //         secret: "e7abfe9df676d9d377ae2ee7e907516a",
    //         share: {
    //             title: "全民欢乐,天天游戏!",
    //             image: "http://oss.lesscool.cn/fcdh/96d172496dbafa4ab9c8335a7133476c.png"
    //         }
    //     })
    //     this.loginWs();
    // }

    // // 微信登录
    // loginWs() {
    //     r.default.traceEvent("WS_LOGINING")
    //     s.default.showLoading({
    //         title: "登录中",
    //         mask: !0
    //     })
    //     r.default.onLoginComplete(this.onLoginComplete.bind(this))
    //     r.default.login();
    // }

    onGameDataLoaded() {
        console.log("onGameDataLoaded", Global.gameData)
        this.isGameDataLoaded = !0
        this.onOpened()
        // c.default.instance && c.default.instance.loadCurrentLevelMission()
        
        // 广告
        // n.loadInterAd()
        this.startButton.visible = !0;
    }

    updateGameData(e = !1) {
        Global.gameData.updateTimestamp = Date.now()
        e && console.log("updateGameData", Global.gameData)
        // Laya.Browser.onMiniGame && r.default.setAllData(l.default.gameData, e);
    }
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值