(function () { 'use strict'; class Consts { } Consts.width = 720; Consts.height = 1280; Consts.appName = "MiniGame"; Consts.appId = "wx85f6b2f44c2c6197"; Consts.appSecret = "ef546eea46fd8d07be1327c7091c6653"; Consts.videoId = "adunit-bb8b86a848fa7157"; Consts.bannerId = "adunit-6dddf31a31e4176f"; Consts.gridId = "adunit-6dddf31a31e4176f"; Consts.screenId = "adunit-cdc70d23cd88abfd"; Consts.bannerAppIds = ["wx392f322b348d818a"]; Consts.version = "101.2.1"; Consts.debug = false; Consts.constName = "81_3dttt"; Consts.host = "https://www.apgame.cn"; Consts.defaultName = "游客"; Consts.defaultPhoto = "UI/default.png"; Consts.ad_data_statistics = false; class BaseData { static init() { Laya.timer.loop(5000, this, () => { this.saveData(); }); } static getNumber(key, defaultValue = 0) { let value = this.getItem(key); if (value) { return parseFloat(value); } return defaultValue; } static addNumber(key, add, max) { let old = this.getNumber(key); let value = old + add; if (max != null) { value = Math.max(Math.min(value, max), 0); } this.setNumber(key, value); } static setNumber(key, value) { this.setItem(key, value.toString()); } static getBoolean(key, defaultValue = false) { let value = this.getItem(key); if (value == "1") { return true; } else if (value == "0") { return false; } return defaultValue; } static setBoolean(key, value) { if (value) { this.setItem(key, "1"); } else { this.setItem(key, "0"); } } static getString(key, defaultValue = "") { let value = this.getItem(key); return value ? value : defaultValue; } static setString(key, value) { this.setItem(key, value); } static setItem(key, value) { this.allDatas[key] = value; } static getItem(key) { if (this.allDatas[key] !== undefined) { return this.allDatas[key]; } this.allDatas[key] = Laya.LocalStorage.getItem(key); this.cacheAllDatas[key] = this.allDatas[key]; return this.allDatas[key]; } static getObject(key) { let str = this.getString(key); if (str == null || str == "") { return null; } return JSON.parse(str); } static setObject(key, object) { let str = JSON.stringify(object); this.setString(key, str); } static saveData() { for (let key in this.allDatas) { if (this.cacheAllDatas[key] != this.allDatas[key]) { this.cacheAllDatas[key] = this.allDatas[key]; Laya.LocalStorage.setItem(key, this.allDatas[key]); } } } } BaseData.allDatas = {}; BaseData.cacheAllDatas = {}; class LibData extends BaseData { static setGameData(gameData) { super.setString("GameData", gameData); } static getGameData() { let gameData = super.getString("GameData", "{\"mode\":0,\"shareDivVedio\":999,\"force\":1,\"bannerMode\":1,\"adMode\":0}"); let table = JSON.parse(gameData); return table; } static getBannerMode() { let mode = this.getGameData().bannerMode; if (mode === undefined) { return 1; } return mode; } static setFriendsData(data) { super.setString("FriendsData", data); } static getFriendsData() { let s = super.getString("FriendsData", "[]"); let datas = JSON.parse(s); return datas; } static getOpenid() { return super.getString("Openid"); } static setOpenid(value) { super.setString("Openid", value); } static getNickname() { return super.getString("Nickname", Consts.defaultName); } static setNickname(name) { super.setString("Nickname", name); } static getPhoto() { return super.getString("Photo", Consts.defaultPhoto); } static setPhoto(value) { super.setString("Photo", value); } static getForce() { return this.getGameData().force; } static setInAppId(inAppId = 0) { super.setNumber("InAppId", inAppId); } static getInAppId() { return super.getNumber("InAppId", 0); } static getGameMode() { return this.getGameData().mode; } static setAuthorize() { super.setBoolean("Authorize", true); } static isAuthorize() { return super.getBoolean("Authorize"); } static setMatchUser(data) { super.setString("MatchUser", data); } static getSessionKey() { return super.getString("SessionKey"); } static setSessionKey(value) { super.setString("SessionKey", value); } static getShareDivVedio() { return this.getGameData().shareDivVedio + 1; } static setUsers(datas) { console.log(datas); super.setString("Users", datas); } static getUsers() { return JSON.parse(super.getString("Users", "[]")); } static getAddMode() { return this.getGameData().adMode; } static set_FlowIcon_Data(data) { let str = JSON.stringify(data); super.setString("FlowIconData", str); } static get_FlowIcon_Data() { let str = super.getString("FlowIconData", "[]"); let table = JSON.parse(str); for (let i = 1, len = table.length; i < len; i++) { const random = Math.floor(Math.random() * (i + 1)); [table[i], table[random]] = [table[random], table[i]]; } return table; } static setBannerState(value) { super.setBoolean("BannerState", value); } static getBannerState() { return super.getBoolean("BannerState", true); } static setExtraData(extraStr) { super.setString("ExtraData", extraStr); } static getExtraData() { return super.getString("ExtraData", "{}"); } static getGroupID() { return super.getString("GroupOpenID"); } static setGroupID(value) { super.setString("GroupOpenID", value); } static setAID(id = "") { super.setString("ADAID", id); } static getAID() { return super.getString("ADAID"); } static setUserType(type) { super.setNumber("UserType", type); } static getUserType() { return super.getNumber("UserType", 0); } static setUserIdentity(type) { super.setNumber("setUserIdentity", type); } static getUserIdentity() { return super.getNumber("setUserIdentity", 0); } static setExtraT(type) { super.setNumber("ExtraT", type); } static getExtraT() { return super.getNumber("ExtraT", 1); } static setExtraTT(type) { super.setNumber("ExtraTT", type); } static getExtraTT() { return super.getNumber("ExtraTT", 0); } } class Data extends BaseData { static getPlayCount() { return super.getNumber("PlayCount"); } static setPlayCount(value) { super.setNumber("PlayCount", value); } static addPlayCount() { super.addNumber("PlayCount", 1); } static getScore() { return super.getNumber("Score"); } static setScore(value) { super.setNumber("Score", value); } static addScore(value) { super.addNumber("Score", value); this.setMaxScore(this.getScore()); } static getMaxScore() { return super.getNumber("MaxScore"); } static setMaxScore(value) { let max = this.getMaxScore(); super.setNumber("MaxScore", Math.max(max, value)); } static getGoods(type, defaultValue = 0) { return super.getNumber("GoodsType" + type, defaultValue); } static setGoods(type, defaultValue = 0) { super.setNumber("GoodsType" + type, defaultValue); } static addGoods(type, value, max = null) { if (value <= 0) { return false; } super.addNumber("GoodsType" + type, value, max); return true; } static subGoods(type, value) { if (value <= 0) { return false; } let goods = Data.getGoods(type); if (goods < value) { return false; } super.setNumber("GoodsType" + type, goods - value); return true; } static setEnterSceneID(id = 0) { super.setNumber("EnterSceneID", id); } static getEnterSceneID() { let id = super.getNumber("EnterSceneID", 0); this.setEnterSceneID(); return id; } static getHoldCoinsNum() { return super.getNumber("HoldCoinsNum"); } static setHoldCoinsNum(value) { super.setNumber("HoldCoinsNum", value); } static getHoldStrengthNum() { return super.getNumber("HoldStrengthNum"); } static setHoldStrengthNum(value) { super.setNumber("HoldStrengthNum", value); } static getKnifeInfo() { return super.getObject("KnifeInfo"); } static setKnifeInfo(value) { super.setObject("KnifeInfo", value); } static getCritInfo() { return super.getObject("CritInfo"); } static setCritInfo(value) { super.setObject("CritInfo", value); } static getCoinInfo() { return super.getObject("CoinInfo"); } static setCoinInfo(value) { super.setObject("CoinInfo", value); } static getLastOfflineTime() { return super.getNumber("OfflineTime"); } static setThisOfflineTime(value) { super.setNumber("OfflineTime", value); } static setAvailableIncomeData(value) { super.setNumber("AvailableIncome", value); } static getAvailableIncomeData() { return super.getNumber("AvailableIncome"); } static setLastNormalStartTime(value) { super.setNumber("LastNormalStartTime", value); } static getLastNormalStartTime() { return super.getNumber("LastNormalStartTime"); } static setLastFasterStartTime(value) { super.setNumber("LastFasterStartTime", value); } static getLastFasterStartTime() { return super.getNumber("LastFasterStartTime"); } static setRecoverStrengthCountDownStartTime(value) { super.setNumber("RecoverStrengthCountDownStartTime", value); } static getRecoverStrengthCountDownStartTime() { return super.getNumber("RecoverStrengthCountDownStartTime"); } static setPropTeach(value) { super.setBoolean("PropTeach", value); } static getPropTeach() { return super.getBoolean("PropTeach"); } } class EventHandler extends Laya.EventDispatcher { static getInstance() { if (this._instance == null) { this._instance = new EventHandler(); } return this._instance; } Emit(InName, agv) { this.event(InName, agv); } addEvent(InName, caller, listener, arg) { this.on(InName, caller, listener, (arg == null) ? null : ([arg])); } } EventHandler._instance = null; class WeixinAPI { static onShareAppMessage(object) { let wx = window["wx"]; if (wx == null) return; wx.onShareAppMessage(object); } static showShareMenu() { let wx = window["wx"]; if (wx == null) return; wx.showShareMenu(); } static updateShareMenu() { let wx = window["wx"]; if (wx == null) return; wx.updateShareMenu({ withShareTicket: true }); } static login(object) { let wx = window["wx"]; if (wx == null) return; wx.login(object); } static getLaunchOptionsSync() { let wx = window["wx"]; if (wx == null) return; return wx.getLaunchOptionsSync(); } static onShow(object) { let wx = window["wx"]; if (wx == null) return; wx.onShow(object); } static onHide(object) { let wx = window["wx"]; if (wx == null) return; wx.onHide(object); } static showToast(object) { let wx = window["wx"]; if (wx == null) return; wx.showToast(object); } static updateManager() { let wx = window["wx"]; if (wx == null) return; if (typeof wx.getUpdateManager === 'function') { const updateManager = wx.getUpdateManager(); updateManager.onUpdateReady(function () { updateManager.applyUpdate(); }); } } static showModal(object) { let wx = window["wx"]; if (wx == null) return; wx.showModal(object); } static createRewardedVideoAd(object) { let wx = window["wx"]; if (wx == null) return; return wx.createRewardedVideoAd(object); } static shareAppMessage(object) { let wx = window["wx"]; if (wx == null) return; wx.shareAppMessage(object); } static setUserCloudStorage(object) { let wx = window["wx"]; if (wx == null) return; wx.setUserCloudStorage(object); } static navigateToMiniProgram(object) { let wx = window["wx"]; if (wx == null) return; wx.navigateToMiniProgram(object); } static createFeedbackButton(object) { let wx = window["wx"]; if (wx == null) return; return wx.createFeedbackButton(object); } static getSetting(object) { let wx = window["wx"]; if (wx == null) return; wx.getSetting(object); } static getShareInfo(object) { let wx = window["wx"]; if (wx == null) return; wx.getShareInfo(object); } } class DataEntity { } DataEntity.shareContent = [ [{ title: "发光的,一个就够了", image: "UI/shareImg1.jpg" }, { title: "风里雨里,我在游戏里等你~", image: "UI/shareImg2.jpg" }], [{ title: "发光的,一个就够了", image: "UI/shareImg1.jpg" }, { title: "风里雨里,我在游戏里等你~", image: "UI/shareImg2.jpg" }] ]; class FlowIcon extends Laya.Image { constructor() { super(); this.listData = []; this.curIndex = 0; this.curData = null; this.visible = false; this.anchorX = 0.5; this.anchorY = 0.5; this.on(Laya.Event.CLICK, this, () => { WXContro.navigateToMiniProgram(this.curData.appId); Http.sharePoint(this.curData.appName, 103); }); Laya.timer.clearAll(this); Laya.timer.loop(5000, this, this.update); let action = (rot, duration, callBack) => { Laya.Tween.to(this, { rotation: rot }, duration, Laya.Ease.linearNone, Laya.Handler.create(this, callBack)); }; Laya.timer.loop(1500, this, () => { action(10, 50, () => { action(-10, 100, () => { action(10, 100, () => { action(-10, 100, () => { action(0, 50, () => { }); }); }); }); }); }); } update() { if (this.listData.length < 2) { return; } ++this.curIndex; if (this.curIndex >= this.listData.length) { this.curIndex = this.listData.length - 1; } this.curData = this.listData[this.curIndex]; this.skin = this.curData.icon; } setListData(listData) { if (listData.length == 0) { this.visible = false; return; } this.visible = true; this.listData = listData; this.curIndex = 0; this.curData = this.listData[this.curIndex]; this.skin = this.curData.icon; } clean() { Laya.timer.clearAll(this); this.removeSelf(); } } class FlowIconMgr extends Laya.View { constructor() { super(); FlowIconMgr.thiz = this; } static refresh(flowdata) { this.listData1 = []; this.listData2 = []; this.listData3 = []; Consts.bannerAppIds = []; for (let i = 0; i < flowdata.length; ++i) { let data = flowdata[i]; if (data == null) { continue; } if (FlowIconMgr.showType == FlowIconMgr.TYPE_ONE) { this.listData1.push(data); } else { let index = i % 3; if (index == 0) { this.listData1.push(data); } else if (index == 1) { this.listData2.push(data); } else if (index == 2) { this.listData3.push(data); } } Consts.bannerAppIds.push(data.appId); } this.icon1.setListData(this.listData1); this.icon2.setListData(this.listData2); this.icon3.setListData(this.listData3); } static init(table, showType = FlowIconMgr.TYPE_V) { FlowIconMgr.showType = showType; if (FlowIconMgr.thiz) { this.icon1.clean(); this.icon2.clean(); this.icon1 = null; this.icon2 = null; this.listData3 = []; FlowIconMgr.thiz.removeSelf(); FlowIconMgr.thiz = null; } FlowIconMgr.thiz = new FlowIconMgr(); FlowIconMgr.thiz.x = table.x + 50; FlowIconMgr.thiz.y = table.y + 50; table.layer.addChild(FlowIconMgr.thiz); this.icon1 = new FlowIcon(); FlowIconMgr.thiz.addChild(this.icon1); this.icon2 = new FlowIcon(); FlowIconMgr.thiz.addChild(this.icon2); this.icon3 = new FlowIcon(); FlowIconMgr.thiz.addChild(this.icon3); if (FlowIconMgr.showType == FlowIconMgr.TYPE_ONE) { this.icon2.visible = false; } if (FlowIconMgr.showType == FlowIconMgr.TYPE_V) { this.icon1.x = 0; this.icon1.y = 0; this.icon2.x = 0; this.icon2.y = 105; this.icon3.x = 0; this.icon3.y = 210; } else { this.icon1.x = 0; this.icon1.y = 0; this.icon2.x = 105; this.icon2.y = 0; this.icon3.x = 210; this.icon3.y = 0; } } static setFlowData(flowdata) { FlowIconMgr.refresh(flowdata); } static reset_FlowIconMgr_pos(x, y) { FlowIconMgr.thiz.x = x + 50; FlowIconMgr.thiz.y = y + 50; } static showFlowIcon() { FlowIconMgr.thiz.visible = true; } static hideFlowIcon() { FlowIconMgr.thiz.visible = false; } } FlowIconMgr.TYPE_H = 0; FlowIconMgr.TYPE_V = 1; FlowIconMgr.TYPE_ONE = 3; FlowIconMgr.showType = FlowIconMgr.TYPE_V; FlowIconMgr.icon1 = null; FlowIconMgr.icon2 = null; FlowIconMgr.icon3 = null; FlowIconMgr.listAllData = []; FlowIconMgr.thiz = null; FlowIconMgr.listData1 = []; FlowIconMgr.listData2 = []; FlowIconMgr.listData3 = []; class MiniBanner { static init(laya_ui, banner_data) { this.isShow = false; this.bannerUI_data = banner_data["mini_banner"]; this.bannerAppId = Consts.bannerAppIds[this.bannerAppIdIndex]; this.get_BannerFlow_Data(); Laya.timer.once(1500, this, () => { this.createBannerFlow(laya_ui); this.refreshBannerFlow(); Laya.timer.loop(30000, this, () => { this.refreshBannerFlow(); }); }); } static get_BannerFlow_Data() { Http.getAllFlowIconData(this.get_BannerFlow_Data_success.bind(this), this.get_BannerFlow_Data_fail.bind(this)); } static get_BannerFlow_Data_success(data) { this.bannerFlowData = data; for (let i = 0, _length = this.bannerFlowData.length; i < _length; i++) { this.prioritySum += this.bannerFlowData[i]["priority"]; } this.set_flow_icon(); let refresh_timer = FlowIconMgr.showType == FlowIconMgr.TYPE_ONE ? 50000 : 25000; Laya.timer.loop(refresh_timer, this, () => { this.set_flow_icon(); }); } static set_flow_icon() { let show_bannerFlow_Arr = this.getShowBannerFlow(10); if (!show_bannerFlow_Arr) return; let datas = new Array(); for (let i = 0; i < show_bannerFlow_Arr.length; i++) { let data = {}; data["appId"] = this.bannerFlowData[show_bannerFlow_Arr[i]]["appId"]; data["appName"] = this.bannerFlowData[show_bannerFlow_Arr[i]]["appName"]; data["icon"] = this.bannerFlowData[show_bannerFlow_Arr[i]]["cdnIcon"]; datas.push(data); } FlowIconMgr.setFlowData(datas); } static get_BannerFlow_Data_fail() { this.bannerFlowData = null; Laya.timer.once(20000, this, () => { this.get_BannerFlow_Data(); }); } static createBannerFlow(laya_ui) { this.bannerFlow = new Laya.Image(); if (LibData.getBannerMode() == 0) { this.bannerFlow.visible = false; } else if (LibData.getBannerMode() == 1) { this.bannerFlow.skin = "UI/ad.jpg"; this.bannerFlow.on(Laya.Event.CLICK, this, () => { WXContro.navigateToMiniProgram(this.bannerAppId); Http.sharePoint("BannerAd_minigame", 103); }); } else if (LibData.getBannerMode() == 2) { this.bannerFlow.skin = "UI/ad.png"; } let design = new Laya.Box(); design.width = Consts.width; design.height = Consts.height; design.anchorX = 0.5; design.anchorY = 0.5; design.x = Consts.width / 2; design.y = Consts.height / 2; laya_ui.addChild(design); design.mouseThrough = true; design.addChild(this.bannerFlow); this.initBannerFlow(); this.bannerFlow.visible = this.isShow; } static initBannerFlow() { this.bannerFlow.width = this.bannerUI_data["width"]; this.bannerFlow.height = this.bannerUI_data["height"]; this.bannerFlow.anchorX = 0; this.bannerFlow.anchorY = 0; this.bannerFlow.x = this.bannerUI_data["left"]; this.bannerFlow.y = this.bannerUI_data["top"]; } static refreshBannerFlow() { this.recycleBannerFlow(); let show_bannerFlow_Arr = this.getShowBannerFlow(this.showBannerNum); if (LibData.getBannerMode() == 2 && show_bannerFlow_Arr) { this.bannerFlow.skin = "UI/ad.png"; for (let i = 0; i < 5; i++) { let x = this.bannerFlow.width / 5 / 2 + i * this.bannerFlow.width / 5; let y = this.bannerFlow.height / 2; let icon = Laya.Pool.getItemByClass("bannerFlowIcon", Laya.Image); icon.scale(this.bannerUI_data["scale"], this.bannerUI_data["scale"]); icon.skin = this.bannerFlowData[show_bannerFlow_Arr[i]]["cdnIcon"]; icon.anchorX = 0.5; icon.anchorY = 0.5; icon.x = x; icon.y = y; this.bannerFlow.addChild(icon); let txt = Laya.Pool.getItemByClass("bannerFlowName", Laya.Text); txt.color = "#ffffff"; txt.font = "SimHei"; txt.text = this.bannerFlowData[show_bannerFlow_Arr[i]]["cnName"]; txt.fontSize = 20; txt.align = "center"; txt.width = this.bannerFlow.width / 5 / this.bannerUI_data["scale"]; txt.y = 105; txt.x = -23; icon.addChild(txt); icon.on(Laya.Event.MOUSE_DOWN, this, () => { console.log("点击aaa", this.bannerFlowData[show_bannerFlow_Arr[i]]["cnName"], this.bannerFlowData[show_bannerFlow_Arr[i]]["appId"]); WXContro.navigateToMiniProgram(this.bannerFlowData[show_bannerFlow_Arr[i]]["appId"]); }); this.BannerIconArr.push(icon); this.BannerNameArr.push(txt); } } else if (LibData.getBannerMode() == 2 && !show_bannerFlow_Arr) { this.bannerFlow.visible = false; } } static recycleBannerFlow() { for (let i = 0; i < this.BannerIconArr.length; i++) { this.BannerIconArr[i].removeSelf(); this.BannerNameArr[i].removeSelf(); this.BannerIconArr[i].offAll(); Laya.Pool.recover("bannerFlowIcon", this.BannerIconArr[i]); Laya.Pool.recover("bannerFlowName", this.BannerNameArr[i]); } this.BannerIconArr = []; this.BannerNameArr = []; } static getShowBannerFlow(num) { let show_bannerFlow_Arr = []; if (!this.bannerFlowData) { return null; } if (this.bannerFlowData.length < num) { return null; } while (show_bannerFlow_Arr.length < num) { let random_priorty = Math.floor(Math.random() * this.prioritySum); let _id = this.getFlowIconID(random_priorty); if (!this.check_id_repetition(_id, show_bannerFlow_Arr)) { show_bannerFlow_Arr.push(_id); } } return show_bannerFlow_Arr; } static getFlowIconID(target_priorty) { let id = 0; let _priorty = 0; for (let i = 0, _length = this.bannerFlowData.length; i < _length; i++) { if (target_priorty > _priorty && target_priorty <= this.bannerFlowData[i]["priority"] + _priorty) { id = i; break; } _priorty += this.bannerFlowData[i]["priority"]; } return id; } static check_id_repetition(id, arr) { for (let i = 0; i < arr.length; i++) { if (id == arr[i]) { return true; } } return false; } static show() { this.isShow = true; if (this.bannerFlow) { this.bannerFlow.visible = true; } } static hide() { this.isShow = false; if (this.bannerFlow) { this.bannerFlow.visible = false; } } } MiniBanner.isShow = false; MiniBanner.bannerUI_data = {}; MiniBanner.bannerFlow = null; MiniBanner.bannerAppId = ""; MiniBanner.bannerAppIdIndex = 0; MiniBanner.BannerIconArr = []; MiniBanner.BannerNameArr = []; MiniBanner.bannerFlowData = null; MiniBanner.prioritySum = 0; MiniBanner.showBannerNum = 7; class AdBanner { static init(banner_data, bannerAdKey, call) { this.banner_data = banner_data["ad_banner"]; this.callBack = call; return this.createBanner(bannerAdKey); } static createBanner(bannerAdKey) { let wx = window["wx"]; if (!wx) { this.callBack(null, bannerAdKey, 0); return; } let bannerAd = wx.createBannerAd({ adUnitId: Consts.bannerId, style: { left: this.banner_data["left"], top: this.banner_data["top"], width: this.banner_data["width"], height: this.banner_data["height"], } }); bannerAd.onError((res) => { console.log("bannerAD", res); this.callBack(null, bannerAdKey, res.errCode); }); bannerAd.onLoad(() => { this.callBack(bannerAd, bannerAdKey, 0); }); bannerAd.show(); } } AdBanner.banner_data = {}; AdBanner.callBack = null; class GridBanner { static init(banner_data, bannerAdKey, call) { this.banner_data = banner_data["grid_banner"]; this.callBack = call; this.createBanner(bannerAdKey); } static createBanner(bannerAdKey) { let wx = window["wx"]; if (!wx) { this.callBack(null, bannerAdKey, 0); return; } let gridAd = wx.createGridAd({ adUnitId: Consts.gridId, adTheme: 'white', gridCount: 5, style: { left: this.banner_data["left"], top: this.banner_data["top"], width: this.banner_data["width"], height: this.banner_data["height"], } }); gridAd.onError((res) => { console.log("gridAD", res); this.callBack(null, bannerAdKey, res.errCode); }); gridAd.onLoad(() => { this.callBack(gridAd, bannerAdKey, 0); }); gridAd.show(); } } GridBanner.banner_data = {}; GridBanner.callBack = null; class BannerAd { static init(laya_ui) { LibData.setBannerState(true); this.init_banner_data(); this.create_mini_banner(laya_ui); this.init_wx_banner(); } static init_wx_banner() { this.show_wx_banner(); Laya.timer.loop(this.PERIOD * 2 * 1000, this, this.update); } static update() { if (!this.isShow) { return; } this.show_wx_banner(); } static show_wx_banner() { if (this.autoRefresh) { this.create_wx_banner("bannerAd1"); Laya.timer.once(2000, this, () => { if (this.bannerAd2) { this.bannerAd2.hide(); } }); Laya.timer.once(this.PERIOD * 1000, this, () => { this.create_wx_banner("bannerAd2"); Laya.timer.once(2000, this, () => { if (this.bannerAd1) { this.bannerAd1.hide(); } }); }); } } static create_wx_banner(bannerAdKey) { if (this[bannerAdKey]) { this[bannerAdKey].destroy(); this[bannerAdKey] = null; } this.refreshBannerTime = new Date().getTime(); this.create_wx_ad_banner(bannerAdKey); } static create_wx_ad_banner(bannerAdKey) { AdBanner.init(this.banner_data, bannerAdKey, this.create_wx_ad_banner_call.bind(this)); } static create_wx_ad_banner_call(banner, bannerAdKey, errCode) { if (banner) { MiniBanner.hide(); this.show_banner_type = 0; this[bannerAdKey] = banner; if (!this.isShow) { if (LibData.getBannerState()) { this.hideBannerAd(1); } else { this.hideBannerAd(0); } } this.banner_num_statistics(); } else { this[bannerAdKey] = null; this.banner_num_statistics_fail(errCode); this.create_wx_grid_banner(bannerAdKey); } } static create_wx_grid_banner(bannerAdKey) { GridBanner.init(this.banner_data, bannerAdKey, this.create_wx_grid_banner_call.bind(this)); } static create_wx_grid_banner_call(banner, bannerAdKey, errCode) { if (banner) { this.show_banner_type = 1; MiniBanner.hide(); this[bannerAdKey] = banner; if (!this.isShow) { if (LibData.getBannerState()) { this.hideBannerAd(1); } else { this.hideBannerAd(0); } } this.grid_num_statistics(); } else { this.grid_num_statistics_fail(errCode); this[bannerAdKey] = null; this.show_banner_type = 2; if (this.isShow) { MiniBanner.show(); } else { MiniBanner.hide(); } } } static create_mini_banner(laya_ui) { MiniBanner.init(laya_ui, this.banner_data); } static showBannerAd(param = 0) { this.isShow = true; if (this.show_banner_type != 2) { if (this.bannerAd1) { this.bannerAd1.show(); if (param == 0) { LibData.setBannerState(true); } } if (this.bannerAd2) { this.bannerAd2.show(); if (param == 0) { LibData.setBannerState(true); } } } else { MiniBanner.show(); } } static hideBannerAd(param = 0) { this.isShow = false; if (this.bannerAd1) { this.bannerAd1.hide(); } if (this.bannerAd2) { this.bannerAd2.hide(); } MiniBanner.hide(); if (param == 0) { LibData.setBannerState(false); } } static refreshBanner() { if (this.refreshBannerTime == 0) { this.refreshBannerTime = new Date().getTime(); this.create_wx_banner("bannerAd1"); } else { if (new Date().getTime() - this.refreshBannerTime > 30 * 1000) { this.refreshBannerTime = new Date().getTime(); this.create_wx_banner("bannerAd1"); } } } static init_banner_data() { this.init_wx_ad_banner_data(); this.init_wx_grid_banner_data(); this.init_mini_banner_data(); } static init_wx_ad_banner_data() { let wx = window["wx"]; if (!wx) return; let SCALE = 1; let winSize = wx.getSystemInfoSync(); let bannerWidth = 0; let bannerHeight = 0; let top = 0; let left = 0; if (Consts.width > Consts.height) { let actual_width = WXContro.wx_to_laya_size(300); let bannerAd_Width_px = actual_width * SCALE; let bannerAd_heigth_px = bannerAd_Width_px * this.H_DIV_W; bannerWidth = WXContro.laya_to_wx_size(bannerAd_Width_px); bannerHeight = WXContro.laya_to_wx_size(bannerAd_heigth_px); let offset = 0; offset = (WXContro.wx_to_laya_size(winSize.windowWidth) - Consts.width) / 2; offset = WXContro.laya_to_wx_size(offset); left = winSize.windowWidth - bannerWidth - offset; top = winSize.windowHeight - bannerHeight; } else { if (this.isSmall) { SCALE = 300 / wx.getSystemInfoSync().windowWidth; } bannerWidth = winSize.windowWidth * SCALE; bannerHeight = bannerWidth * this.H_DIV_W; let offset = 0; if (winSize.windowHeight / winSize.windowWidth > Consts.height / Consts.width && !this.isBottom) { offset = (winSize.windowHeight - WXContro.laya_to_wx_size(Consts.height)) / 2; } left = (winSize.windowWidth - bannerWidth) / 2; top = winSize.windowHeight - bannerHeight - offset; } let ad_banner = { "width": bannerWidth, "height": bannerHeight, "top": top, "left": left, "scale": SCALE }; this.banner_data["ad_banner"] = ad_banner; } static init_wx_grid_banner_data() { let wx = window["wx"]; if (!wx) return; let SCALE = 1; let winSize = wx.getSystemInfoSync(); let bannerWidth = 0; let bannerHeight = 0; let top = 0; let left = 0; if (Consts.width > Consts.height) { SCALE = 1; let actual_width = WXContro.wx_to_laya_size(300); let bannerAd_Width_px = actual_width * SCALE; let bannerAd_heigth_px = bannerAd_Width_px * this.H_DIV_W; bannerWidth = WXContro.laya_to_wx_size(bannerAd_Width_px); bannerHeight = WXContro.laya_to_wx_size(bannerAd_heigth_px); let offset = 0; offset = (WXContro.wx_to_laya_size(winSize.windowWidth) - Consts.width) / 2; offset = WXContro.laya_to_wx_size(offset); left = winSize.windowWidth - bannerWidth - offset; top = winSize.windowHeight - bannerHeight; } else { if (this.isSmall) { SCALE = 300 / wx.getSystemInfoSync().windowWidth; } bannerWidth = winSize.windowWidth * SCALE; bannerHeight = bannerWidth * this.H_DIV_W; let offset = 0; if (winSize.windowHeight / winSize.windowWidth > Consts.height / Consts.width && !this.isBottom) { offset = (winSize.windowHeight - WXContro.laya_to_wx_size(Consts.height)) / 2; } left = (winSize.windowWidth - bannerWidth) / 2; top = winSize.windowHeight - bannerHeight - offset; } let grid_banner = { "width": bannerWidth, "height": bannerHeight, "top": top, "left": left, "scale": SCALE }; this.banner_data["grid_banner"] = grid_banner; } static init_mini_banner_data() { let SCALE = 1; let bannerWidth = 0; let bannerHeight = 0; let top = 0; let left = 0; let wx = window["wx"]; if (Consts.width > Consts.height) { SCALE = 300 / 400; if (wx) { bannerWidth = WXContro.wx_to_laya_size(300); } else { bannerWidth = 700 * SCALE; } bannerHeight = bannerWidth * this.H_DIV_W; top = Consts.height - bannerHeight; left = Consts.width - bannerWidth; } else { if (this.isSmall) { SCALE = 300 / wx.getSystemInfoSync().windowWidth; } bannerWidth = Consts.width * SCALE; bannerHeight = bannerWidth * this.H_DIV_W; top = Consts.height - bannerHeight; left = (Consts.width - bannerWidth) / 2; } let mini_banner = { "width": bannerWidth, "height": bannerHeight, "top": top, "left": left, "scale": SCALE }; this.banner_data["mini_banner"] = mini_banner; } static banner_num_statistics() { let banner_num_timer = Data.getNumber("banner_num_timer", 0); if (new Date().getTime() - banner_num_timer > 24 * 60 * 60 * 1000) { Data.setNumber("banner_num_index", 1); let date_timer = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0).getTime(); Data.setNumber("banner_num_timer", date_timer); } else { Data.addNumber("banner_num_index", 1); } if (Consts.ad_data_statistics) { let index = Data.getNumber("banner_num_index", 1); let index_str = ("000" + index).substr(-3); Http.sharePoint("bannerAD_refresh_" + index_str, 105); } } static getBannerIndex() { if (this.show_banner_type != 0) { return -1; } let banner_num_timer = Data.getNumber("banner_num_timer", 0); if (new Date().getTime() - banner_num_timer > 24 * 60 * 60 * 1000) { return 0; } else { return Data.getNumber("banner_num_index", 1); } } static banner_num_statistics_fail(errCode) { if (!Consts.ad_data_statistics) return; let index = Data.getNumber("banner_num_index", 1); let index_str = ("000" + (index + 1)).substr(-3); let point_str = "bannerAD_err_" + errCode + "_" + index_str; if (Data.getString("bannerAD_refresh_errS") != point_str) { Data.setString("bannerAD_refresh_errS", point_str); Http.sharePoint(point_str, 105); } } static grid_num_statistics() { let grid_num_timer = Data.getNumber("grid_num_timer", 0); if (new Date().getTime() - grid_num_timer > 24 * 60 * 60 * 1000) { Data.setNumber("grid_num_index", 1); let date_timer = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0).getTime(); Data.setNumber("grid_num_timer", date_timer); } else { Data.addNumber("grid_num_index", 1); } if (Consts.ad_data_statistics) { let index = Data.getNumber("grid_num_index", 1); let index_str = ("000" + index).substr(-3); Http.sharePoint("gridAD_refresh_" + index_str, 105); } } static grid_num_statistics_fail(errCode) { if (!Consts.ad_data_statistics) return; let index = Data.getNumber("grid_num_index", 1); let index_str = ("000" + (index + 1)).substr(-3); let point_str = "gridAD_err_" + errCode + "_" + index_str; if (Data.getString("gridAD_refresh_errS") != point_str) { Data.setString("gridAD_refresh_errS", point_str); Http.sharePoint(point_str, 105); } } } BannerAd.banner_data = {}; BannerAd.H_DIV_W = 104 / 300; BannerAd.isBottom = false; BannerAd.PERIOD = 30; BannerAd.bannerAd1 = null; BannerAd.bannerAd2 = null; BannerAd.refreshBannerTime = 0; BannerAd.isSmall = false; BannerAd.isShow = true; BannerAd.autoRefresh = true; BannerAd.show_banner_type = -1; var SHAREIMG_POINT; (function (SHAREIMG_POINT) { SHAREIMG_POINT["LOGIN_SHARE_NAME"] = "LOGIN_SHARE_NAME"; SHAREIMG_POINT["LOGIN_FIRST_TIMER"] = "LOGIN_FIRST_TIMER"; SHAREIMG_POINT["LOGIN_LAST_TIMER"] = "LOGIN_LAST_TIMER"; })(SHAREIMG_POINT || (SHAREIMG_POINT = {})); class DataPoint { static shareImgPoint(shareName) { let open_share_name = Data.getString(SHAREIMG_POINT.LOGIN_SHARE_NAME, "0"); if (shareName != null && open_share_name == "0") { Data.setString(SHAREIMG_POINT.LOGIN_SHARE_NAME, shareName); let date = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0); Data.setString(SHAREIMG_POINT.LOGIN_LAST_TIMER, date.getTime() + ""); Data.setString(SHAREIMG_POINT.LOGIN_FIRST_TIMER, date.getTime() + ""); Http.sharePoint(shareName + "_new", 104); } else if (shareName == null && open_share_name == "0") { Data.setString(SHAREIMG_POINT.LOGIN_SHARE_NAME, "1"); } else if (open_share_name != "0" && open_share_name != "1") { this.check_shareImgPoint(shareName); } } static check_shareImgPoint(shareName) { let now_date = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), 0, 0); let first_login_timer = parseInt(Data.getString(SHAREIMG_POINT.LOGIN_FIRST_TIMER, "0")); let one_day_millisecond = 24 * 60 * 60 * 1000; let time_distance = now_date.getTime() - first_login_timer; let last_login_timer = parseInt(Data.getString(SHAREIMG_POINT.LOGIN_LAST_TIMER, "0")); if (now_date.getTime() - last_login_timer > one_day_millisecond) { let date_login = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0); if (time_distance > one_day_millisecond * 1 && time_distance < one_day_millisecond * 2) { Data.setString(SHAREIMG_POINT.LOGIN_LAST_TIMER, date_login.getTime() + ""); Http.sharePoint(shareName + "_next", 104); } else if (time_distance > one_day_millisecond * 3 && time_distance < one_day_millisecond * 4) { Data.setString(SHAREIMG_POINT.LOGIN_LAST_TIMER, date_login.getTime() + ""); Http.sharePoint(shareName + "_three", 104); } else if (time_distance > one_day_millisecond * 7 && time_distance < one_day_millisecond * 8) { Data.setString(SHAREIMG_POINT.LOGIN_LAST_TIMER, date_login.getTime() + ""); Http.sharePoint(shareName + "_seven", 104); } } } } class WXContro { static init(layer) { this._layer = layer; this.show_version(); BaseData.init(); Http.getGameData(); this.onShareAppMessage(); this.login(); this.onShow(); this.onHide(); } static show_version() { let ver_txt = new Laya.Text(); Laya.timer.once(500, this, () => { ver_txt.text = Consts.version; ver_txt.color = "#ffffff"; this._layer.addChild(ver_txt); }); } static onShareAppMessage() { let wx = window["wx"]; if (wx == null) return; WeixinAPI.onShareAppMessage(() => { let contents = DataEntity.shareContent[LibData.getGameMode() == 0 ? 0 : 1]; let content = contents; if (contents["length"]) { content = contents[Math.floor(Math.random() * contents["length"])]; } let query = "shareName=" + content.name; if (LibData.getInAppId() == 1) { query += "&inAppId=" + LibData.getInAppId(); } return { title: content.title, imageUrl: content.image, query: query, }; }); WeixinAPI.showShareMenu(); WeixinAPI.updateShareMenu(); } static login() { WeixinAPI.login({ success: (res) => { let code = res.code; console.log("-> login code:" + code); Http.getSessionKey(code, (res) => { let jsonRes = JSON.parse(res); if (jsonRes && jsonRes.openid && jsonRes.openid.length > 0) { LibData.setOpenid(jsonRes.openid); console.log("-> openid:" + LibData.getOpenid()); } else if (LibData.getOpenid().length == 0) { LibData.setOpenid("ms" + new Date().getTime()); console.log("-> openid:" + LibData.getOpenid()); } LibData.setSessionKey(jsonRes.session_key); let loginCallBack = (res) => { console.log("-> login res:" + JSON.stringify(res)); let openid = res.query.openid; let name = res.query.name; let type = res.query.type; let scene = res.scene; if (openid != null && name != null) { console.log("login -----------------------------"); console.log("login -> 用户 name:" + LibData.getNickname() + "(openid:" + LibData.getOpenid() + ")"); console.log("login -> 点了 name:" + name + "(openid:" + openid + ")分享的小游戏"); console.log("login -----------------------------"); } this.getGroupID(res.shareTicket); let weixinadinfo = res.query.weixinadinfo; if (weixinadinfo) { let weixinadinfoArr = weixinadinfo.split("."); let aid = weixinadinfoArr[0]; LibData.setAID(aid); } let shareName = res.query.shareName; if (shareName != null) { DataPoint.shareImgPoint(shareName); } if (scene != null) { Data.setEnterSceneID(scene); } else { Data.setEnterSceneID(); } Http.userCalcIn(res); Http.userGameDateCheck(0, res.query.inAppId, res.scene, res.referrerInfo); }; loginCallBack(WeixinAPI.getLaunchOptionsSync()); }); } }); } static getGroupID(shareTicket) { if (!shareTicket) return; WeixinAPI.getShareInfo({ shareTicket: shareTicket, success: (res) => { let cryptoJS = window["CryptoJS"]; if (!cryptoJS) return; try { if (res.errMsg == "getShareInfo:ok") { let key = cryptoJS.enc.Base64.parse(LibData.getSessionKey()); let iv = cryptoJS.enc.Base64.parse(res.iv); let decrypted = cryptoJS.AES.decrypt(res.encryptedData, key, { iv: iv, mode: cryptoJS.mode.CBC, padding: cryptoJS.pad.Pkcs7 }); let decryptedResult = JSON.parse(decrypted.toString(cryptoJS.enc.Utf8)); LibData.setGroupID(decryptedResult.openGId); } return; } catch (error) { console.log("解密失败!", error); return; } }, fail: () => { return; } }); return; } static onHide() { WeixinAPI.onHide((res) => { console.log("-> onHide ---------"); BaseData.saveData(); this.shareDone = true; }); } static onShow() { WeixinAPI.onShow((res) => { console.log("-> onShow res:" + JSON.stringify(res)); WeixinAPI.showToast({ title: '处理中', duration: 1000, mask: true, icon: 'loading' }); this.getGroupID(res.shareTicket); let goneTime = new Date().getTime() - this.shareTime; Laya.timer.once(1000, this, () => { if (this.successCallBack) { console.log("-> wx.onShow goneTime:" + goneTime); this.shareHandle(goneTime, this.successCallBack, this.failCallBack); this.successCallBack = null; this.failCallBack = null; } }); let openid = res.query.openid; let name = res.query.name; if (openid != null && name != null) { console.log("onShow -----------------------------"); console.log("onShow -> 用户 name:" + LibData.getNickname() + "(openid:" + LibData.getOpenid() + ")"); console.log("onShow -> 点了 name:" + name + "(openid:" + openid + ")分享的小游戏"); console.log("onShow -----------------------------"); } WeixinAPI.updateManager(); Http.userGameDateCheck(1, null, res.scene, res.referrerInfo); }); } static shareHandle(span, successCallBack, failCallBack) { let wx = window["wx"]; if (wx == null) return; let reward = false; if (span < 1.5 * 1000) { if (LibData.getForce() == 1) { this.showPoint_Done = false; WeixinAPI.showModal({ title: "提示", content: "成功分享才有奖励~", showCancel: this.share_type, success: (res) => { if (res.confirm) { this.sharePoint(this.pointName, true, this.share_type, successCallBack, failCallBack, this.param); } else if (res.cancel) { this.sharePoint_fail(1, failCallBack); return; } } }); } return; } else if (span > 10 * 1000) { reward = true; } else { if (this.shareSuccessCount == 0) { if (span < 2 * 1000 && this.failCount < 3) { this.showPoint_Done = false; if (LibData.getForce() == 1) { WeixinAPI.showModal({ title: "提示", content: "成功分享才有奖励~", showCancel: this.share_type, success: (res) => { if (res.confirm) { this.sharePoint(this.pointName, true, this.share_type, successCallBack, failCallBack, this.param); } else if (res.cancel) { this.sharePoint_fail(1, failCallBack); return; } } }); } } else { reward = true; this.lastSuccessShareNeedTime = span; } } else if (this.shareSuccessCount == 1) { if (span < this.lastSuccessShareNeedTime && this.failCount < 3) { this.showPoint_Done = false; if (LibData.getForce() == 1) { WeixinAPI.showModal({ title: "提示", content: "成功分享才有奖励~", showCancel: this.share_type, success: (res) => { if (res.confirm) { this.sharePoint(this.pointName, true, this.share_type, successCallBack, failCallBack, this.param); } else if (res.cancel) { this.sharePoint_fail(1, failCallBack); return; } } }); } } else { reward = true; this.findGroupTime = span - this.lastSuccessShareNeedTime; if (this.findGroupTime > 600) { this.findGroupTime = 600; } this.lastSuccessShareNeedTime = span; } } else if (this.shareSuccessCount > 1) { if (span < this.lastSuccessShareNeedTime + this.findGroupTime && this.failCount < 2) { this.showPoint_Done = false; if (LibData.getForce() == 1) { WeixinAPI.showModal({ title: "提示", content: "成功分享才有奖励~", showCancel: this.share_type, success: (res) => { if (res.confirm) { this.sharePoint(this.pointName, true, this.share_type, successCallBack, failCallBack, this.param); } else if (res.cancel) { this.sharePoint_fail(1, failCallBack); return; } } }); } } else { reward = true; this.lastSuccessShareNeedTime = span; } } } if (reward) { this.sharePoint_success(1, successCallBack); } else { this.sharePoint_fail(1, failCallBack); } } static sharePoint(name, isShare, type, success, fail = null, param = { type: "", img: null, title: null }) { if (this.showPoint_Done) return; this.showPoint_Done = true; this.pointName = name; this.param = param; this.share_type = type; Http.sharePoint(this.pointName + "-touch", 101); if (Consts.debug) { this.sharePoint_success(0, success); return; } if (LibData.getGameMode() == 0) { this.sharePoint_success(0, success); } else if (LibData.getGameMode() == 2) { console.log("视频"); this.showVideo(success, fail); } else { if (isShare) { console.log("分享"); this.share(success, fail, param.type, param.img, param.title); } else { console.log("视频"); this.showVideo(success, fail); } } } static sharePoint_success(type, success) { Http.sharePoint(this.pointName + "-success", 101); this.showPoint_Done = false; if (success) { success(); } if (type == 0) { } else if (type == 1) { ++this.shareSuccessCount; ++this.successCount; this.failCount = 0; } else if (type == 2) { ++this.successCount; } } static sharePoint_fail(type, fail) { Http.sharePoint(this.pointName + "-fail", 101); this.showPoint_Done = false; if (fail) { fail(); } if (type == 0) { } else if (type == 1) { ++this.failCount; } else if (type == 2) { } } static showVideo(success, fail = null) { let wx = window["wx"]; if (wx == null) { this.sharePoint_success(0, success); return; } let videoAd = WeixinAPI.createRewardedVideoAd({ adUnitId: Consts.videoId }); if (videoAd == null) { return; } this.video_num_statistics(); videoAd.load().then(() => { videoAd.show(); BannerAd.hideBannerAd(1); }); let closeCallBack = res => { Laya.timer.once(1000 * 10, this, () => { if (LibData.getBannerState()) { BannerAd.showBannerAd(); } }); videoAd.offClose(closeCallBack); if (res && res.isEnded || res === undefined) { this.sharePoint_success(2, success); } else { this.sharePoint_fail(2, fail); } }; videoAd.onClose(closeCallBack); videoAd.onError((res) => { if (res.errMsg != "can't invoke load() while video-ad is showed") { videoAd.offClose(closeCallBack); this.video_num_statistics_fail(res.errCode); if (LibData.getGameMode() == 1) { this.share(success, fail); } else { this.sharePoint_fail(2, fail); } } }); } static share(successCallBack, failCallBack = null, type = "", img = null, title = null) { let wx = window["wx"]; if (wx == null) { this.sharePoint_success(1, successCallBack); return; } this.shareTime = new Date().getTime(); this.successCallBack = successCallBack; this.failCallBack = failCallBack; if (LibData.getGameMode() == 3) { this.shareDone = false; Laya.timer.once(500, this, () => { if (!this.shareDone) { this.showVideo(successCallBack, failCallBack); } }); } let contents = DataEntity.shareContent[LibData.getGameMode() == 0 ? 0 : 1]; let content = contents; if (contents["length"]) { content = contents[Math.floor(Math.random() * contents["length"])]; } let query = "photo=" + LibData.getPhoto() + "&openid=" + LibData.getOpenid() + "&name=" + LibData.getNickname() + "&type=" + type + "&shareName=" + content.name; if (LibData.getInAppId() == 1) { query += "&inAppId=" + LibData.getInAppId(); } WeixinAPI.shareAppMessage({ title: title || content.title, imageUrl: img || content.image, query: query, }); } static setRankData(score) { let wx = window["wx"]; if (wx == null) return; WeixinAPI.setUserCloudStorage({ KVDataList: [{ key: 'score', value: '' + score }] }); } static navigateToMiniProgram(id) { WeixinAPI.navigateToMiniProgram({ appId: id, success: () => { Http.userCalcOut(id); } }); } static createFeedbackButton(x, y) { let wx = window["wx"]; if (wx == null) return; return WeixinAPI.createFeedbackButton({ type: 'image', text: '投诉', image: 'UI/feedback.png', style: { left: x === undefined ? 10 : x, top: y === undefined ? wx.getSystemInfoSync().windowHeight / 2 : y, width: 40, height: 40, lineHeight: 40, color: '#ffffff', textAlign: 'center', fontSize: 16, borderRadius: 4 } }); } static isShare() { return this.successCount % LibData.getShareDivVedio() > 0; } static getUserInfo(callBack, btnPng) { let wx = window["wx"]; if (wx == null) { callBack({ type: null }); return; } WeixinAPI.getSetting({ success: (res) => { if (res.authSetting['scope.userInfo']) { console.log("-> 已经授权"); wx.getUserInfo({ success: (res) => { LibData.setAuthorize(); res.userInfo.type = "authed"; callBack(res.userInfo); } }); } else { console.log("-> 没有授权"); let button = window["wx"].createUserInfoButton({ type: "image", image: btnPng, style: this.getAuthBtnRange() }); button.show(); button.onTap((res) => { if (res.errMsg == "getUserInfo:ok") { if (res.userInfo) { LibData.setNickname(res.userInfo.nickName); LibData.setPhoto(res.userInfo.avatarUrl); LibData.setAuthorize(); res.userInfo.type = "auth"; callBack(res.userInfo); } } else { callBack({ type: "authFail" }); } button.hide(); button.destroy(); }); } } }); } static getAuthBtnRange() { let wx = window["wx"]; if (wx == null) { return {}; } let wxSize = wx.getSystemInfoSync(); let wxDivDesign = wxSize.windowWidth / Laya.stage.designWidth; return { left: 372 * wxDivDesign, top: 877 * wxDivDesign + (Laya.stage.height - Laya.stage.designHeight) / 2 * wxDivDesign, width: 313 * wxDivDesign, height: 132 * wxDivDesign, }; } static showVideo_direct(name, success, fail = null) { let wx = window["wx"]; if (wx == null) { success(); return; } let videoAd = wx.createRewardedVideoAd({ adUnitId: Consts.videoId }); if (videoAd == null) { return; } videoAd.load().then(() => { videoAd.show(); BannerAd.hideBannerAd(1); }); let closeCallBack = res => { videoAd.offClose(closeCallBack); if (res && res.isEnded || res === undefined) { if (success) { success(); } } else { if (fail) { fail(); } } }; videoAd.onClose(closeCallBack); videoAd.onError((res) => { videoAd.offClose(closeCallBack); if (fail) { fail(); } }); } static showShare_direct(name) { let contents = DataEntity.shareContent[LibData.getGameMode() == 0 ? 0 : 1]; let content = contents; if (contents["length"]) { content = contents[Math.floor(Math.random() * contents["length"])]; } let query = "photo=" + LibData.getPhoto() + "&openid=" + LibData.getOpenid() + "&name=" + LibData.getNickname() + "&type=" + "" + "&shareName=" + content.name; if (LibData.getInAppId() == 1) { query += "&inAppId=" + LibData.getInAppId(); } WeixinAPI.shareAppMessage({ title: content.title, imageUrl: content.image, query: query, }); } static showInterstitialAd() { let wx = window["wx"]; if (wx == null) { return; } let interstitialAd = wx.createInterstitialAd({ adUnitId: Consts.screenId }); interstitialAd.show().catch((err) => { console.error(err); }); interstitialAd.onLoad(() => { }); interstitialAd.onError(err => { }); interstitialAd.onClose(res => { }); } static laya_to_wx_size(px) { let pixelRatio = 0; let wx = window["wx"]; if (wx == null) return; let winSize = wx.getSystemInfoSync(); if (Consts.width > Consts.height) { pixelRatio = Consts.height / winSize.windowHeight; } else { pixelRatio = Consts.width / winSize.windowWidth; } return px / pixelRatio; } static wx_to_laya_size(px) { let pixelRatio = 0; let wx = window["wx"]; if (wx == null) return; let winSize = wx.getSystemInfoSync(); if (Consts.width > Consts.height) { pixelRatio = Consts.height / winSize.windowHeight; } else { pixelRatio = Consts.width / winSize.windowWidth; } return px * pixelRatio; } static laya_to_wx_pos(x, y) { let _x = 0; let _y = 0; let _offset = 0; let wx = window["wx"]; let winSize = wx.getSystemInfoSync(); if (Consts.width > Consts.height) { _offset = (this.wx_to_laya_size(winSize.windowWidth) - Consts.width) / 2; _x = x + _offset; _y = y; } else { _offset = (this.wx_to_laya_size(winSize.windowHeight) - Consts.height) / 2; _x = x; _y = y + _offset; } return new Laya.Point(this.laya_to_wx_size(_x), this.laya_to_wx_size(_y)); } static video_num_statistics() { let video_num_timer = Data.getNumber("video_num_timer", 0); if (new Date().getTime() - video_num_timer > 24 * 60 * 60 * 1000) { Data.setNumber("video_num_index", 1); let date_timer = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0).getTime(); Data.setNumber("video_num_timer", date_timer); } else { Data.addNumber("video_num_index", 1); } if (Consts.ad_data_statistics) { let index = Data.getNumber("video_num_index", 1); let index_str = ("000" + index).substr(-3); Http.sharePoint("videoAD_refresh_" + index_str, 105); } } static video_num_statistics_fail(errCode) { if (!Consts.ad_data_statistics) return; let index = Data.getNumber("video_num_index", 1); let index_str = ("000" + (index + 1)).substr(-3); let point_str = "videoAD_err_" + errCode + "_" + index_str; if (Data.getString("videoAD_refresh_errS") != point_str) { Data.setString("videoAD_refresh_errS", point_str); Http.sharePoint(point_str, 105); } } static getLength(str) { let length = 0; let reg = /[\u4e00-\u9fa5]/; for (var i = 0; i < str.length; i++) { if (reg.test(str.charAt(i))) { length += 2; } else { length++; } } return length; } static warning_tips(str) { WeixinAPI.showModal({ title: "提示", content: str, showCancel: false, success: (res) => { } }); } } WXContro._layer = null; WXContro.shareTime = 0; WXContro.successCallBack = null; WXContro.failCallBack = null; WXContro.successCount = 1; WXContro.pointName = ""; WXContro.param = { type: null, img: null, title: null }; WXContro.lastSuccessShareNeedTime = 0; WXContro.findGroupTime = 0; WXContro.shareDone = true; WXContro.share_type = false; WXContro.showPoint_Done = false; WXContro.shareSuccessCount = 0; WXContro.failCount = 0; class Http { request(url, success, fail) { console.log("-> http request url:" + url); let http = new Laya.HttpRequest(); http.once(Laya.Event.PROGRESS, this, (res) => { }); http.once(Laya.Event.COMPLETE, this, (res) => { if (success) { success(res); } }); http.once(Laya.Event.ERROR, this, (res) => { if (fail) { fail(res); } }); http.send(url, null, 'get', 'text'); } static getGameData(callBack = null) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getGameData&version=" + Consts.version; new Http().request(url, (res) => { LibData.setGameData(res); console.log("GameData:" + res); if (callBack) { callBack(); } }); } static getSessionKey(code, callBack) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getSessionKey&appid=" + Consts.appId + "&secret=" + Consts.appSecret + "&js_code=" + code + "&grant_type=authorization_code"; new Http().request(url, (res) => { callBack(res); }); } static userCalcIn(res) { if (res == null || res.referrerInfo == null) { return; } if (res.scene && res.scene == 1037 && res.referrerInfo.appId) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=userCalc&type=1&appId=" + Consts.appId + "&relateAppId=" + res.referrerInfo.appId; new Http().request(url); } } static saveUser(enter_id, type, inAppId, scene, referrerInfo) { scene = scene || ""; let appId = ""; if (referrerInfo && referrerInfo.appId) { appId = referrerInfo.appId; } let url = Consts.host + "/game?appName=" + encodeURIComponent(Consts.appName) + "&action=saveUser&openid=" + encodeURIComponent(LibData.getOpenid()) + "&name=" + encodeURIComponent(LibData.getNickname()) + "&avatar=" + encodeURIComponent(LibData.getPhoto()) + "&level=" + encodeURIComponent(Data.getMaxScore()) + "&type=" + encodeURIComponent(scene) + "&appId=" + encodeURIComponent(appId) + "&inAppId=" + encodeURIComponent("1") + "&extra=" + encodeURIComponent(LibData.getExtraData()); if (enter_id == 0 && type == 0 && inAppId) { url += "&shareInAppId=" + encodeURIComponent("1"); } let aid = LibData.getAID(); if (enter_id == 0 && type == 0 && aid.length > 0) { url += "&aid=" + encodeURIComponent(aid); } new Http().request(url, (res) => { let data = res.replace(" ", ""); data = data.replace("\n", ""); LibData.setInAppId(res[0]); }); } static sharePoint(name, type) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=addGameCount&posName=" + name + "&type=" + type; new Http().request(url); } static userCalcOut(relateAppId) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=userCalc&type=0&appId=" + Consts.appId + "&relateAppId=" + relateAppId; new Http().request(url); } static getFlowIconData(callback = null) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getFlowIconData"; new Http().request(url, (res) => { let listData = []; let table = JSON.parse(res); for (let item of table) { let data = {}; data.appId = item.appId; data.appName = item.cnName; data.icon = item.cdnIcon; listData.push(data); } LibData.set_FlowIcon_Data(listData); callback(); }); } static enterGameByShare(openid) { let friendid = LibData.getOpenid(); let url = Consts.host + "/game?appName=" + Consts.appName + "&action=enterGameByShare&openid=" + openid + "&friendid=" + friendid + "&name=" + LibData.getNickname() + "&avatar=" + LibData.getPhoto(); new Http().request(url); } static getInviteFriends(callBack) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getInviteFriends&openid=" + LibData.getOpenid(); new Http().request(url, (friends) => { LibData.setFriendsData(friends); if (callBack) { callBack(LibData.getFriendsData()); } }); } static getRandomUser() { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getRandomUser&openid=" + LibData.getOpenid(); new Http().request(url, (res) => { let table = JSON.parse(res); if (table.name == "" || table.avatar == "" || table.openid == LibData.getOpenid()) { this.getRandomUser(); } else { LibData.setMatchUser(res); } }); } static getIp(callback) { let openId = LibData.getOpenid() || ""; let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getIp&openId=" + openId; console.log("-> http request url:" + url); new Http().request(url, (res) => { console.log("-> http request success:" + res); callback(res); }); } static getAddress(callback) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getAddress"; new Http().request(url, (res) => { console.log("-> getAddress:" + res); callback(res); }); } static getUsers(count) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getUsers&count=" + count; new Http().request(url, (res) => { LibData.setUsers(res); }); } static downloadData(table, success, fail) { let url = "http://39.97.229.203/api/app/numerical/json/" + Consts.constName + "_" + table + ".json"; new Http().request(url, (res) => { let json_table = JSON.parse(res); success(json_table); }, (res) => { fail(res); }); } static userGameDateCheck(enter_id, inAppId, scene, referrerInfo) { this.getGameUserData(enter_id, (type) => { this.saveUser(enter_id, type, inAppId, scene, referrerInfo); }); } static updateGameUserData() { let extra_str = LibData.getExtraData(); let extra_json = JSON.parse(extra_str); extra_json["T"] = LibData.getExtraT() + 1; extra_json["TT"] = LibData.getExtraTT(); if (WXContro.getLength(extra_str) > 1990) { WXContro.warning_tips("上传服务器数据长度超过了指定位数 上传失败~~~"); return; } this.getGameUserData(-1, (type) => { LibData.setExtraData(JSON.stringify(extra_json)); let url = Consts.host + "/game?appName=" + Consts.appName + "&action=updateUserInfo&openid=" + LibData.getOpenid() + "&level=" + Data.getMaxScore() + "&extra=" + encodeURIComponent(LibData.getExtraData()); new Http().request(url); }); } static getGameUserData(enter_id, call) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getUserInfo&openid=" + LibData.getOpenid(); new Http().request(url, (res) => { console.log("->extra_date:", res); let extra_server = JSON.parse(res).extra; let extra_local = JSON.parse(LibData.getExtraData()); if (!call) return; if (extra_server && extra_server.T) { let server_dateT = extra_server.T; let middle = new Date(2020, 4, 1, 0, 0).getTime(); if (extra_local["T"]) { let local_dateT = extra_local["T"]; if (local_dateT > middle && server_dateT > middle) { if (local_dateT < server_dateT) { extra_server.T = 1; extra_local = extra_server; } } else if (local_dateT < middle && server_dateT < middle) { if (local_dateT < server_dateT) { extra_local = extra_server; } } else if (local_dateT > middle && server_dateT < middle) { extra_local = extra_server; } } else { if (server_dateT > middle) { extra_server.T = 1; } extra_local = extra_server; } if (!extra_local["TT"]) { extra_local["TT"] = new Date(2020, 4, 1, 0, 0).getTime(); } LibData.setExtraData(JSON.stringify(extra_local)); call(1); LibData.setUserIdentity(1); } else { extra_local["T"] = 1; extra_local["TT"] = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0).getTime(); LibData.setExtraData(JSON.stringify(extra_local)); call(0); LibData.setUserIdentity(0); } this.setExtarT(); this.setUserType(); if (enter_id == 0) { EventHandler.getInstance().Emit("http_server_data"); } }, (res) => { if (enter_id == 0) { EventHandler.getInstance().Emit("http_server_data"); } }); } static setExtarT() { let extra_local = JSON.parse(LibData.getExtraData()); LibData.setExtraT(extra_local["T"]); } static setUserType() { let extra_local = JSON.parse(LibData.getExtraData()); let TT = extra_local["TT"]; if (new Date().getTime() - TT < 24 * 60 * 60 * 1000) { LibData.setUserType(0); } else { LibData.setUserType(1); } console.log(extra_local["TT"]); LibData.setExtraTT(extra_local["TT"]); } static getAllFlowIconData(callback_success = null, callback_fail = null) { let url = Consts.host + "/game?appName=" + Consts.appName + "&action=icons"; new Http().request(url, (res) => { let table = JSON.parse(res); callback_success(table); }, () => { callback_fail(); }); } } class Func { static substr(str, len, end = "") { if (!str || !len) { return ''; } let a = 0; var temp = ''; for (let i = 0; i < str.length; i++) { if (str.charCodeAt(i) > 255) { a += 2; } else { a++; } if (a > len) { break; } temp += str.charAt(i); } if (temp == str) { return str; } return temp + end; } static playButtonClick() { } static playSound(sound) { Laya.SoundManager.playSound(sound); } static playMusic(url, loops = 0, complete, startTime) { if (Laya.Browser.onWeiXin) { let wx = window["wx"]; this.bgm = wx.createInnerAudioContext(); this.bgm.autoplay = true; this.bgm.loop = true; this.bgm.src = url; this.bgm.play(); wx.onShow(function () { console.log("重新回到游戏"); Func.bgm.play(); }); } else { Laya.SoundManager.playMusic(url, loops, complete, startTime); } } static stopMusic() { let wx = window["wx"]; if (wx == null) { Laya.SoundManager.stopMusic(); return; } this.bgm.stop(); } static setMusicVolume(volume) { Laya.SoundManager.setMusicVolume(volume); } static getTimeStamp() { return Math.floor(new Date().getTime() / 1000); } static isOtherDay(timeStamp) { if (Math.floor(this.getTimeStamp() / 86400) > Math.floor(timeStamp / 86400)) { return true; } return false; } static getTableSize(map) { let size = 0; for (let i in map) { ++size; } return size; } static sharePoint(name, type, success, fail = null, isShare = null, params = { type: "", img: null, title: null }) { let share = isShare === null ? WXContro.isShare() : isShare; WXContro.sharePoint(name, share, type, success, fail, params); } static showVideo(name, success, fail) { WXContro.showVideo_direct(name, success, fail); } static showShare(name) { WXContro.showShare_direct(name); } static sharePointCount(name, type) { Http.sharePoint(name, type); } static downloadData(table, success, fail) { Http.downloadData(table, success, fail); } static updateGameUserData() { Http.updateGameUserData(); } } class MusicControl { constructor() { } static playBGMusic() { Func.playMusic(this.musicName.bgMusic, 0); } static btnClick() { this.playSound(this.musicName.btnClick, 1); } static gameFailed() { this.playSound(this.musicName.gameFailed, 1); Laya.SoundManager.setMusicVolume(0.3); Laya.timer.once(2400, this, function () { Laya.SoundManager.setMusicVolume(1); }); } static getCoins() { this.playSound(this.musicName.getCoins, 1); } static knifeAttackSun() { this.playSound(this.musicName.knifeAttackSun, 1); } static planetDie() { this.playSound(this.musicName.planetDie, 1); } static useProp() { this.playSound(this.musicName.useProp, 1); } static gameSuccess() { this.playSound(this.musicName.gameSuccess, 1); } static hitObstacle() { this.playSound(this.musicName.hitObstacle, 1); } static playMusic(musicPath, loops) { Laya.SoundManager.playMusic(musicPath, loops); } static playSound(musicPath, loops, completeHandler) { Laya.SoundManager.playSound(musicPath, loops, completeHandler); } } MusicControl.musicName = { "bgMusic": "music/bgMusic.mp3", "btnClick": "music/btnClick.mp3", "gameFailed": "music/gameFailed.mp3", "getCoins": "music/getCoins.mp3", "knifeAttackSun": "music/knifeAttackSun.mp3", "planetDie": "music/planetDie.mp3", "useProp": "music/useProp.wav", "gameSuccess": "music/gameSuccess.mp3", "hitObstacle": "music/hitObstacle.wav" }; class BtnEffectControl extends Laya.Component { constructor() { super(); Laya.timer.once(100, this, function () { let selfOwner = this.owner; selfOwner.on(Laya.Event.MOUSE_DOWN, selfOwner, function () { Laya.Tween.to(selfOwner, { scaleX: 0.8, scaleY: 0.8 }, 50); MusicControl.btnClick(); }); selfOwner.on(Laya.Event.MOUSE_UP, selfOwner, function () { Laya.Tween.to(selfOwner, { scaleX: 1, scaleY: 1 }, 600, Laya.Ease.backOut); }); selfOwner.on(Laya.Event.MOUSE_OUT, selfOwner, function () { Laya.Tween.to(selfOwner, { scaleX: 1, scaleY: 1 }, 600, Laya.Ease.backOut); }); }); } } var REG = Laya.ClassUtils.regClass; var ui; (function (ui) { var Dialogs; (function (Dialogs) { class Dialog_FreelyGetPropUI extends Laya.Dialog { constructor() { super(); } createChildren() { super.createChildren(); this.createView(Dialog_FreelyGetPropUI.uiView); } } Dialog_FreelyGetPropUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 19 }, { "type": "Sprite", "props": { "y": 278, "x": 95, "texture": "texture/Dialog_GetProp/dialogBG.png", "name": "bg" }, "compId": 8 }, { "type": "Button", "props": { "y": 850, "x": 360, "width": 320, "var": "btn_freeRevive", "stateNum": 1, "skin": "texture/Dialog_GetProp/btn_freeRevive.png", "pivotY": 60, "pivotX": 160, "name": "btn_freeRevive", "labelSize": 28, "labelPadding": "28", "labelColors": "#fff100", "labelBold": true, "label": "1/4", "height": 120 }, "compId": 10, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 20 }] }, { "type": "Text", "props": { "y": 665, "x": 0, "width": 720, "var": "text_propName", "text": "火箭", "name": "text_propName", "height": 40, "fontSize": 40, "color": "#ffe400", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 12 }, { "type": "Text", "props": { "y": 719, "x": 0, "width": 720, "var": "text_propInfo", "text": "可获得5个无撞击的无敌箭矢", "name": "text_propInfo", "height": 40, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 21 }, { "type": "Sprite", "props": { "y": 464, "x": 279, "width": 162, "var": "icon_prop", "texture": "texture/Dialog_GetProp/rocket.png", "name": "icon_prop", "height": 190 }, "compId": 13 }, { "type": "Text", "props": { "y": 932, "x": 296, "visible": false, "var": "btn_nextTime", "text": "下次再说", "name": "btn_nextTime", "fontSize": 32, "color": "#ffffff", "runtime": "laya.display.Text" }, "compId": 18 }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_GetProp/dialogBG.png", "texture/Dialog_GetProp/btn_freeRevive.png", "texture/Dialog_GetProp/rocket.png"], "loadList3D": [] }; Dialogs.Dialog_FreelyGetPropUI = Dialog_FreelyGetPropUI; REG("ui.Dialogs.Dialog_FreelyGetPropUI", Dialog_FreelyGetPropUI); class Dialog_GameOverUI extends Laya.Dialog { constructor() { super(); } createChildren() { super.createChildren(); this.createView(Dialog_GameOverUI.uiView); } } Dialog_GameOverUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 57 }, { "type": "Box", "props": { "y": 220, "x": 124, "var": "defeatTopUI", "name": "defeatTopUI" }, "compId": 30, "child": [{ "type": "Sprite", "props": { "x": 23, "texture": "texture/Dialog_LevelOver/light_defeat.png", "name": "light" }, "compId": 9, "child": [{ "type": "Sprite", "props": { "y": 185, "x": 94, "texture": "texture/Dialog_LevelOver/title_defeat.png", "name": "title" }, "compId": 8 }] }, { "type": "Box", "props": { "y": 366, "scaleY": 0.8, "scaleX": 0.8, "name": "blood" }, "compId": 20, "child": [{ "type": "Sprite", "props": { "texture": "texture/GameScene/progressBG_blood.png", "name": "bloodBG" }, "compId": 62 }, { "type": "Sprite", "props": { "y": 6, "x": 7, "width": 576, "var": "bloodProgressBar", "value": 0.01, "texture": "texture/GameScene/progressBar_blood.png", "name": "bloodProgressBar", "height": 20 }, "compId": 63, "child": [{ "type": "Panel", "props": { "y": 0, "x": 0, "width": 576, "var": "bloodBarMask", "renderType": "mask", "name": "bloodBarMask", "height": 20, "bgColor": "#000000" }, "compId": 64 }] }] }, { "type": "Box", "props": { "y": 422, "x": -124, "width": 720, "name": "coinAndBlood" }, "compId": 26, "child": [{ "type": "Text", "props": { "y": 6, "x": 581, "width": 91, "var": "text_bloodNum", "text": "11.44k", "strokeColor": "#e1a030", "stroke": 2, "pivotX": 91, "name": "text_bloodNum", "height": 30, "fontSize": 30, "color": "#ffffff", "bold": true, "align": "right", "runtime": "laya.display.Text" }, "compId": 21, "child": [{ "type": "Panel", "props": { "y": 15, "x": 0, "width": 170, "right": 91, "pivotY": 20, "pivotX": 170, "height": 40 }, "compId": 24, "child": [{ "type": "Sprite", "props": { "y": 0, "x": 0, "texture": "texture/GameScene/icon_blood.png" }, "compId": 65 }, { "type": "Text", "props": { "y": 8, "x": 55, "text": "剩余血量:", "fontSize": 24, "color": "#ffffff", "runtime": "laya.display.Text" }, "compId": 25 }] }] }, { "type": "Sprite", "props": { "y": 0, "x": 135, "var": "coinIcon", "texture": "texture/MainScene/TAB/icon_Coin.png", "scaleY": 0.28, "scaleX": 0.28, "name": "coinIcon" }, "compId": 22 }, { "type": "Text", "props": { "y": 6, "x": 185, "var": "text_coinNumFromCurLevel", "text": "9999", "strokeColor": "#e1a030", "stroke": 2, "name": "text_coinNumFromCurLevel", "fontSize": 30, "color": "#ffffff", "bold": true, "align": "left", "runtime": "laya.display.Text" }, "compId": 23 }] }, { "type": "Text", "props": { "y": 483, "x": -124.5, "width": 720, "var": "defeatReason", "text": "失败原因:碰到障碍物", "name": "defeatReason", "fontSize": 28, "color": "#ff0000", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 56 }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "visible": false, "var": "defeat_hasReviveChanceUI", "name": "defeat_hasReviveChanceUI", "height": 1280 }, "compId": 3, "child": [{ "type": "Text", "props": { "y": 626, "x": 0, "width": 720, "text": "复活后太阳血量减半并获得7个无敌火箭。", "name": "tip", "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 16, "child": [{ "type": "Text", "props": { "y": 35, "x": 0, "width": 720, "text": "还有机会减少太阳上的禁牌和火箭。", "name": "tip", "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 17 }, { "type": "Text", "props": { "y": -35, "x": 0, "width": 720, "text": "您获得一次复活机会,", "name": "tip", "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 15 }] }, { "type": "Button", "props": { "y": 837, "x": 360, "width": 328, "var": "btn_revive", "stateNum": 1, "skin": "texture/Dialog_LevelOver/btn_revive.png", "pivotY": 64, "pivotX": 164, "name": "btn_revive", "height": 128 }, "compId": 27, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 58 }] }, { "type": "Button", "props": { "y": 935, "x": 360, "width": 64, "var": "btn_giveUp", "stateNum": 1, "skin": "texture/Dialog_LevelOver/btn_giveUp.png", "pivotY": 16, "pivotX": 32, "name": "btn_giveUp", "height": 32 }, "compId": 28, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 59 }] }] }, { "type": "Box", "props": { "y": 757, "x": 166, "var": "receiveCoinUI", "name": "receiveCoinUI" }, "compId": 34, "child": [{ "type": "Text", "props": { "x": 128, "text": "您赚到了", "name": "tip", "fontSize": 32, "color": "#ffd972", "bold": true, "runtime": "laya.display.Text" }, "compId": 33 }, { "type": "Button", "props": { "y": 252, "x": 157, "visible": false, "var": "btn_threeTimesReceiving", "stateNum": 1, "skin": "texture/Dialog_LevelOver/btn_threeTimesReceiving.png", "pivotY": 64, "pivotX": 194, "name": "btn_threeTimesReceiving", "labelStrokeColor": "#996100", "labelStroke": 2, "labelSize": 38, "labelPadding": "5,70,20,50", "labelColors": "#ffffff", "labelBold": true }, "compId": 32, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 61 }] }, { "type": "Button", "props": { "y": 177.5, "x": 157, "var": "btn_receiveRightNow", "stateNum": 1, "skin": "texture/Dialog_LevelOver/btn_receiveRightNow.png", "pivotY": 69, "pivotX": 194, "name": "btn_receiveRightNow", "labelStrokeColor": "#996100", "labelStroke": 2, "labelSize": 38, "labelPadding": "7,70,20,50", "labelColors": "#ffffff", "labelBold": true, "label": "213.02K" }, "compId": 31 }] }, { "type": "Box", "props": { "y": 220, "x": 124, "var": "victoryTopUI", "name": "victoryTopUI" }, "compId": 35, "child": [{ "type": "Sprite", "props": { "x": 23, "texture": "texture/Dialog_LevelOver/light_victory.png", "name": "light" }, "compId": 36, "child": [{ "type": "Sprite", "props": { "y": 185, "x": 94, "texture": "texture/Dialog_LevelOver/title_victory.png", "name": "title" }, "compId": 37 }] }, { "type": "Sprite", "props": { "y": 319, "x": 121, "visible": false, "texture": "texture/MainScene/icon_strength.png", "name": "icon_strength" }, "compId": 52, "child": [{ "type": "Text", "props": { "y": 114, "x": 142, "var": "text_strengthNum", "text": "+5", "strokeColor": "#e1a030", "stroke": 2, "name": "text_strengthNum", "fontSize": 50, "color": "#ffffff", "bold": true, "runtime": "laya.display.Text" }, "compId": 53 }] }] }, { "type": "Box", "props": { "y": 166, "x": 0, "var": "publicUI", "name": "publicUI" }, "compId": 54, "child": [{ "type": "Text", "props": { "y": 343, "x": 360, "width": 60, "var": "text_levelNum", "text": "100", "strokeColor": "#e1a030", "stroke": 2, "pivotX": 30, "name": "text_levelNum", "height": 36, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 10, "child": [{ "type": "Panel", "props": { "y": 0, "x": -50, "width": 35, "var": "levelNum_left", "name": "levelNum_left", "height": 36 }, "compId": 11, "child": [{ "type": "Text", "props": { "y": 4, "x": 3, "text": "第", "fontSize": 28, "color": "#ffd972", "bold": true, "runtime": "laya.display.Text" }, "compId": 12 }] }, { "type": "Panel", "props": { "y": 0, "x": 70, "width": 35, "var": "levelNum_right", "name": "levelNum_right", "height": 36 }, "compId": 13, "child": [{ "type": "Text", "props": { "y": 4, "x": 3, "text": "关", "fontSize": 28, "color": "#ffd972", "bold": true, "runtime": "laya.display.Text" }, "compId": 14 }] }] }] }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_LevelOver/light_defeat.png", "texture/Dialog_LevelOver/title_defeat.png", "texture/GameScene/progressBG_blood.png", "texture/GameScene/progressBar_blood.png", "texture/GameScene/icon_blood.png", "texture/MainScene/TAB/icon_Coin.png", "texture/Dialog_LevelOver/btn_revive.png", "texture/Dialog_LevelOver/btn_giveUp.png", "texture/Dialog_LevelOver/btn_threeTimesReceiving.png", "texture/Dialog_LevelOver/btn_receiveRightNow.png", "texture/Dialog_LevelOver/light_victory.png", "texture/Dialog_LevelOver/title_victory.png", "texture/MainScene/icon_strength.png"], "loadList3D": [] }; Dialogs.Dialog_GameOverUI = Dialog_GameOverUI; REG("ui.Dialogs.Dialog_GameOverUI", Dialog_GameOverUI); class Dialog_GetStrengthUI extends Laya.Dialog { constructor() { super(); } createChildren() { super.createChildren(); this.createView(Dialog_GetStrengthUI.uiView); } } Dialog_GetStrengthUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 16 }, { "type": "Sprite", "props": { "y": 288, "x": 95, "texture": "texture/Dialog_CoinAndStrength/dialogBG.png", "name": "bg" }, "compId": 8 }, { "type": "Sprite", "props": { "y": 321, "x": 261, "texture": "texture/Dialog_CoinAndStrength/title_strengthRecovery.png", "name": "title" }, "compId": 9 }, { "type": "Button", "props": { "y": 797, "x": 360, "width": 330, "var": "btn_getStrength", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_getStrength.png", "pivotY": 63, "pivotX": 165, "name": "btn_getStrength", "labelSize": 28, "labelPadding": "30", "labelColors": "#fff100", "labelBold": true, "label": "30点体力", "height": 125 }, "compId": 11, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 17 }] }, { "type": "Button", "props": { "y": 916, "x": 360, "width": 129, "var": "btn_nextTime", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_nextTime.png", "pivotY": 15, "pivotX": 65, "name": "btn_nextTime", "height": 30 }, "compId": 12, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 18 }] }, { "type": "Text", "props": { "y": 677, "x": 358, "width": 267, "var": "tip", "text": "体力已经最满啦!", "pivotX": 133, "name": "tip", "height": 28, "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 13 }, { "type": "Sprite", "props": { "y": 440, "x": 256, "texture": "texture/MainScene/icon_strength.png", "name": "icon_strength" }, "compId": 15, "child": [{ "type": "Sprite", "props": { "y": 111, "x": 104, "width": 184, "visible": false, "var": "ring", "texture": "texture/Dialog_CoinAndStrength/ring.png", "pivotY": 92, "pivotX": 92, "name": "ring", "height": 184 }, "compId": 14 }] }, { "type": "Sprite", "props": { "y": 459, "x": 268, "texture": "texture/Dialog_CoinAndStrength/strengthRingBG.png", "name": "strengthRingBG" }, "compId": 21 }, { "type": "Sprite", "props": { "y": 552, "x": 360, "width": 184, "var": "strengthRingProgress", "pivotY": 92, "pivotX": 92, "name": "strengthRingProgress", "height": 184 }, "compId": 19, "child": [{ "type": "Sprite", "props": { "y": 92, "x": 92, "width": 184, "var": "strengthProgressMask", "texture": "texture/Dialog_CoinAndStrength/ring.png", "renderType": "mask", "pivotY": 92, "pivotX": 92, "name": "strengthProgressMask", "height": 184 }, "compId": 20 }] }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_CoinAndStrength/dialogBG.png", "texture/Dialog_CoinAndStrength/title_strengthRecovery.png", "texture/Dialog_CoinAndStrength/btn_getStrength.png", "texture/Dialog_CoinAndStrength/btn_nextTime.png", "texture/MainScene/icon_strength.png", "texture/Dialog_CoinAndStrength/ring.png", "texture/Dialog_CoinAndStrength/strengthRingBG.png"], "loadList3D": [] }; Dialogs.Dialog_GetStrengthUI = Dialog_GetStrengthUI; REG("ui.Dialogs.Dialog_GetStrengthUI", Dialog_GetStrengthUI); class Dialog_ReceiveCoinProfitUI extends Laya.Dialog { constructor() { super(); } createChildren() { super.createChildren(); this.createView(Dialog_ReceiveCoinProfitUI.uiView); } } Dialog_ReceiveCoinProfitUI.uiView = { "type": "Dialog", "props": { "width": 720, "mouseThrough": true, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 22 }, { "type": "Panel", "props": { "y": -140, "x": 0, "width": 720, "var": "touchArea", "name": "touchArea", "height": 1560 }, "compId": 20 }, { "type": "Sprite", "props": { "y": 288, "x": 95, "texture": "texture/Dialog_CoinAndStrength/dialogBG.png", "name": "bg" }, "compId": 7 }, { "type": "Sprite", "props": { "y": 321, "x": 191, "texture": "texture/Dialog_CoinAndStrength/title_profitCanBeReceived.png", "name": "title" }, "compId": 8 }, { "type": "Text", "props": { "y": 512, "x": 359, "width": 271, "var": "text_UpperLimitTime", "strokeColor": "#cc72ff", "stroke": 4, "pivotX": 135, "overflow": "visible", "name": "text_UpperLimitTime", "leading": 10, "height": 52, "fontSize": 42, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 15, "child": [{ "type": "Text", "props": { "y": 49, "x": -20, "visible": false, "text": "收益达到上限", "strokeColor": "#cc72ff", "stroke": 4, "name": "tip", "fontSize": 42, "color": "#ffffff", "bold": true, "runtime": "laya.display.Text" }, "compId": 14 }, { "type": "Text", "props": { "y": 0, "x": 176, "visible": false, "text": "后", "strokeColor": "#cc72ff", "stroke": 4, "name": "tip", "fontSize": 42, "color": "#ffffff", "bold": true, "runtime": "laya.display.Text" }, "compId": 12 }] }, { "type": "Button", "props": { "y": 825, "x": 341, "var": "btn_clickReceive", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_clickReceive.png", "pivotY": 70, "pivotX": 198, "name": "btn_clickReceive", "labelStrokeColor": "#996100", "labelStroke": 2, "labelSize": 38, "labelPadding": "-3,70,23,50", "labelFont": "Arial", "labelColors": "#ffffff", "labelBold": true }, "compId": 18, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 23 }, { "type": "Text", "props": { "y": 49, "x": 197, "width": 142, "var": "text_btn_clickReceive", "text": "111.11k", "strokeColor": "#996100", "stroke": 2, "pivotY": 19, "pivotX": 63, "name": "text_btn_clickReceive", "height": 38, "fontSize": 38, "font": "Arial", "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 25 }] }, { "type": "Button", "props": { "y": 886, "x": 341, "visible": false, "var": "btn_threeTimesReceive", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_threeTimesReceiving.png", "pivotY": 70, "pivotX": 198, "name": "btn_threeTimesReceive", "labelStrokeColor": "#996100", "labelStroke": 2, "labelSize": 38, "labelPadding": "-5,70,30,50", "labelFont": "Arial", "labelColors": "#ffffff", "labelBold": true }, "compId": 19, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 24 }, { "type": "Text", "props": { "y": 49, "x": 197, "width": 142, "var": "text_btn_threeTimesReceive", "text": "111.11k", "strokeColor": "#996100", "stroke": 2, "pivotY": 19, "pivotX": 63, "name": "text_btn_threeTimesReceive", "height": 38, "fontSize": 38, "font": "Arial", "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 26 }] }, { "type": "Text", "props": { "y": 621, "x": 145, "visible": false, "var": "tip_receiveLater", "text": "您已领取完,请稍后再领!", "name": "tip_receiveLater", "fontSize": 38, "color": "#ffffff", "runtime": "laya.display.Text" }, "compId": 21 }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_CoinAndStrength/dialogBG.png", "texture/Dialog_CoinAndStrength/title_profitCanBeReceived.png", "texture/Dialog_CoinAndStrength/btn_clickReceive.png", "texture/Dialog_CoinAndStrength/btn_threeTimesReceiving.png"], "loadList3D": [] }; Dialogs.Dialog_ReceiveCoinProfitUI = Dialog_ReceiveCoinProfitUI; REG("ui.Dialogs.Dialog_ReceiveCoinProfitUI", Dialog_ReceiveCoinProfitUI); class Dialog_SpeedUpCoinProfitUI extends Laya.Dialog { constructor() { super(); } createChildren() { super.createChildren(); this.createView(Dialog_SpeedUpCoinProfitUI.uiView); } } Dialog_SpeedUpCoinProfitUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 14 }, { "type": "Sprite", "props": { "y": 278, "x": 95, "texture": "texture/Dialog_CoinAndStrength/dialogBG.png", "name": "bg" }, "compId": 7 }, { "type": "Sprite", "props": { "y": 311, "x": 260, "texture": "texture/Dialog_CoinAndStrength/title_fasterReceiving.png", "name": "title" }, "compId": 9 }, { "type": "Sprite", "props": { "y": 477, "x": 284, "texture": "texture/MainScene/TAB/icon_Coin.png", "name": "coinIcon" }, "compId": 10 }, { "type": "Button", "props": { "y": 788, "x": 360, "width": 348, "var": "btn_threeTimesFaster", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_threeTimesFaster.png", "pivotY": 64, "pivotX": 174, "name": "btn_threeTimesFaster", "height": 128 }, "compId": 11, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 15 }] }, { "type": "Button", "props": { "y": 886, "x": 360, "width": 129, "var": "btn_nextTime", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_nextTime.png", "pivotY": 15, "pivotX": 65, "name": "btn_nextTime", "height": 30 }, "compId": 12, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 16 }] }, { "type": "Text", "props": { "y": 667, "x": 217, "text": "日常金币收益加速获取", "name": "tip", "fontSize": 28, "color": "#ffffff", "bold": true, "runtime": "laya.display.Text" }, "compId": 13 }, { "type": "Sprite", "props": { "y": 742, "x": 185.5, "visible": false, "var": "fasterCountTime_bg", "texture": "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/fasterCountTime_bg.png", "name": "fasterCountTime_bg" }, "compId": 19, "child": [{ "type": "Sprite", "props": { "y": 0, "x": 0, "width": 348, "texture": "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/fasterCountTime_bar.png", "name": "fasterCountTime_bar", "height": 92 }, "compId": 20, "child": [{ "type": "Sprite", "props": { "y": 0, "x": -174, "width": 348, "var": "mask_fasterCountTime", "texture": "texture/Public/mask.jpg", "renderType": "mask", "name": "mask", "height": 92 }, "compId": 21 }] }, { "type": "FontClip", "props": { "y": 13, "x": 14, "width": 321, "var": "fasterCountTime", "value": "04:45", "skin": "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/clip_num_fasterProfit.png", "sheet": "0123456789", "name": "fasterCountTime", "height": 35, "align": "center" }, "compId": 24 }, { "type": "Sprite", "props": { "y": 13, "x": 166, "texture": "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/maohao.png" }, "compId": 25 }] }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_CoinAndStrength/dialogBG.png", "texture/Dialog_CoinAndStrength/title_fasterReceiving.png", "texture/MainScene/TAB/icon_Coin.png", "texture/Dialog_CoinAndStrength/btn_threeTimesFaster.png", "texture/Dialog_CoinAndStrength/btn_nextTime.png", "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/fasterCountTime_bg.png", "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/fasterCountTime_bar.png", "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/clip_num_fasterProfit.png", "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/maohao.png"], "loadList3D": [] }; Dialogs.Dialog_SpeedUpCoinProfitUI = Dialog_SpeedUpCoinProfitUI; REG("ui.Dialogs.Dialog_SpeedUpCoinProfitUI", Dialog_SpeedUpCoinProfitUI); class Dialog_UnlockPlanetUI extends Laya.Dialog { constructor() { super(); } createChildren() { super.createChildren(); this.createView(Dialog_UnlockPlanetUI.uiView); } } Dialog_UnlockPlanetUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 13 }, { "type": "Sprite", "props": { "y": 278, "x": 95, "texture": "texture/Dialog_NewPlanet/dialogBG.png", "name": "bg" }, "compId": 7 }, { "type": "Button", "props": { "y": 886, "x": 360, "width": 334, "var": "btn_OK", "stateNum": 1, "skin": "texture/Dialog_NewPlanet/btn_OK.png", "pivotY": 67, "pivotX": 167, "name": "btn_OK", "height": 134 }, "compId": 8, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 14 }] }, { "type": "Text", "props": { "y": 669, "x": 0, "width": 720, "var": "planetName", "text": "水星", "name": "planetName", "fontSize": 40, "color": "#ffe400", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 5 }, { "type": "Text", "props": { "y": 724, "x": 0, "width": 720, "var": "planetSkill", "text": "可以为太阳加血", "name": "planetSkill", "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 4 }, { "type": "Box", "props": { "y": 549, "x": 360 }, "compId": 12, "child": [{ "type": "Sprite", "props": { "y": 0, "x": 0, "width": 240, "var": "planetIcon", "texture": "texture/Planet/Saturn.png", "pivotY": 81, "pivotX": 120, "name": "planetIcon", "height": 161 }, "compId": 11 }] }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_NewPlanet/dialogBG.png", "texture/Dialog_NewPlanet/btn_OK.png", "texture/Planet/Saturn.png"], "loadList3D": [] }; Dialogs.Dialog_UnlockPlanetUI = Dialog_UnlockPlanetUI; REG("ui.Dialogs.Dialog_UnlockPlanetUI", Dialog_UnlockPlanetUI); })(Dialogs = ui.Dialogs || (ui.Dialogs = {})); })(ui || (ui = {})); (function (ui) { class MainSceneUI extends Laya.Scene { constructor() { super(); } createChildren() { super.createChildren(); this.loadScene("MainScene"); } } ui.MainSceneUI = MainSceneUI; REG("ui.MainSceneUI", MainSceneUI); class RankUI extends Laya.View { constructor() { super(); } createChildren() { super.createChildren(); this.createView(RankUI.uiView); } } RankUI.uiView = { "type": "View", "props": { "y": 0, "x": 0, "width": 720, "mouseThrough": true, "height": 1280 }, "compId": 1, "child": [{ "type": "Box", "props": { "width": 720, "mouseThrough": true, "height": 1280, "centerY": 0, "centerX": 0 }, "compId": 78, "child": [{ "type": "Box", "props": { "y": 0, "x": 0, "width": 200, "visible": false, "var": "rankTop1", "height": 120 }, "compId": 47, "child": [{ "type": "Image", "props": { "y": 35, "x": 0, "visible": false, "var": "main_rankTop1", "skin": "rank/rect1.png", "sizeGrid": "20,20,20,20", "height": 83 }, "compId": 48, "child": [{ "type": "Text", "props": { "y": -18, "x": 35, "text": "查看完整排行榜>>", "fontSize": 15, "font": "SimHei", "color": "#ffffff", "runtime": "laya.display.Text" }, "compId": 49 }] }, { "type": "Box", "props": { "y": 39, "x": 0, "width": 190, "visible": false, "var": "sub_rankTop1", "height": 83 }, "compId": 50, "child": [{ "type": "Image", "props": { "y": 2, "x": 9, "width": 70, "skin": "rank/default.png", "name": "iconHead", "height": 70 }, "compId": 51 }, { "type": "Text", "props": { "y": 0, "x": 83, "wordWrap": true, "width": 99, "text": "虚位以待", "name": "nickName", "height": 53, "fontSize": 16, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 53 }, { "type": "Text", "props": { "y": 54, "x": 83, "width": 96, "text": "得分:0", "name": "txtExp", "height": 22, "fontSize": 15, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 54 }] }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 300, "visible": false, "var": "rankTop2", "height": 200 }, "compId": 55, "child": [{ "type": "Image", "props": { "y": 43, "x": 0, "visible": false, "var": "main_rankTop2", "skin": "rank/rect2.png" }, "compId": 56, "child": [{ "type": "Text", "props": { "y": 120, "x": 64, "text": "查看完整排行榜>>", "fontSize": 22, "font": "SimHei", "color": "#000000", "runtime": "laya.display.Text" }, "compId": 57 }] }, { "type": "Box", "props": { "y": 47, "x": -1, "width": 293, "visible": false, "var": "sub_rankTop2", "height": 135 }, "compId": 58, "child": [{ "type": "Image", "props": { "y": 11, "x": 186, "width": 90, "skin": "rank/default.png", "name": "iconHead", "height": 90 }, "compId": 59 }, { "type": "Text", "props": { "y": 39, "x": 13, "wordWrap": true, "width": 163, "text": "虚位以待", "name": "nickName", "height": 48, "fontSize": 20, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 60 }, { "type": "Text", "props": { "y": 89, "x": 20, "width": 148, "text": "得分:0", "name": "txtExp", "height": 22, "fontSize": 20, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 61 }, { "type": "Text", "props": { "y": 10, "x": 47, "width": 96, "text": "即将超越", "height": 27, "fontSize": 20, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 62 }] }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "visible": false, "var": "rankEnd1", "height": 1280 }, "compId": 63, "child": [{ "type": "Image", "props": { "width": 580, "visible": false, "var": "main_rankEnd1", "skin": "rank/rect2.png", "sizeGrid": "20,20,20,20", "centerY": 0, "centerX": 0 }, "compId": 64, "child": [{ "type": "Text", "props": { "y": 43, "x": 31, "width": 168, "text": "即将超越", "height": 54, "fontSize": 40, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 70 }] }, { "type": "Box", "props": { "width": 575, "visible": false, "var": "sub_rankEnd1", "height": 135, "centerY": 0, "centerX": 0 }, "compId": 66, "child": [{ "type": "Image", "props": { "width": 100, "skin": "rank/default.png", "name": "iconHead", "height": 100, "centerY": 0, "centerX": -22 }, "compId": 67 }, { "type": "Text", "props": { "y": 21, "x": 323, "wordWrap": true, "width": 246, "text": "虚位以待", "name": "nickName", "height": 70, "fontSize": 30, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 68 }, { "type": "Text", "props": { "y": 91, "x": 345, "width": 206, "text": "得分:0", "name": "txtExp", "height": 41, "fontSize": 30, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 69 }] }] }, { "type": "Box", "props": { "y": 194, "x": 604, "width": 173, "visible": false, "var": "rankRight", "height": 224 }, "compId": 71, "child": [{ "type": "Image", "props": { "y": 2, "x": 170, "visible": false, "var": "bgRankRight1", "skin": "rank/rect3.png", "scaleX": -1 }, "compId": 72, "child": [{ "type": "Image", "props": { "y": 4, "x": 76, "width": 50, "var": "rankRight1", "skin": "rank/default.png", "height": 50 }, "compId": 75 }] }, { "type": "Image", "props": { "y": 81, "x": 190, "visible": false, "var": "bgRankRight2", "skin": "rank/rect3.png", "scaleX": -1 }, "compId": 73, "child": [{ "type": "Image", "props": { "y": 4, "x": 76, "width": 50, "var": "rankRight2", "skin": "rank/default.png", "height": 50 }, "compId": 76 }] }, { "type": "Image", "props": { "y": 159, "x": 190, "visible": false, "var": "bgRankRight3", "skin": "rank/rect3.png", "scaleX": -1 }, "compId": 74, "child": [{ "type": "Image", "props": { "y": 4, "x": 76, "width": 50, "var": "rankRight3", "skin": "rank/default.png", "height": 50 }, "compId": 77 }] }] }, { "type": "Box", "props": { "y": 638, "width": 720, "visible": false, "var": "rankEnd2", "height": 229, "centerX": 0 }, "compId": 79, "child": [{ "type": "Image", "props": { "y": 33, "x": 155, "width": 100, "var": "rankEnd2Head1", "skin": "rank/default.png", "height": 100 }, "compId": 80, "child": [{ "type": "Text", "props": { "y": 107, "x": -51, "width": 206, "text": "虚位以待", "name": "name", "height": 23, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 81 }, { "type": "Text", "props": { "y": 136, "x": -51, "width": 206, "text": "得分:0", "name": "score", "height": 29, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 82 }] }, { "type": "Image", "props": { "y": 33, "x": 311, "width": 100, "var": "rankEnd2Head2", "skin": "rank/default.png", "height": 100 }, "compId": 86, "child": [{ "type": "Text", "props": { "y": 107, "x": -51, "width": 206, "text": "虚位以待", "name": "name", "height": 23, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 87 }, { "type": "Text", "props": { "y": 136, "x": -51, "width": 206, "text": "得分:0", "name": "score", "height": 29, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 88 }] }, { "type": "Image", "props": { "y": 33, "x": 467, "width": 100, "var": "rankEnd2Head3", "skin": "rank/default.png", "height": 100 }, "compId": 83, "child": [{ "type": "Text", "props": { "y": 107, "x": -51, "width": 206, "text": "虚位以待", "name": "name", "height": 23, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 84 }, { "type": "Text", "props": { "y": 136, "x": -51, "width": 206, "text": "得分:0", "name": "score", "height": 29, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 85 }] }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "visible": false, "var": "rankList", "mouseThrough": true, "height": 1280 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 76, "width": 560, "var": "main_rankList", "skin": "rank/bg.png", "height": 810, "centerX": 0 }, "compId": 3, "child": [{ "type": "Image", "props": { "y": 15, "x": 174, "skin": "rank/titleRank.png", "centerX": 0 }, "compId": 35 }, { "type": "Image", "props": { "y": 713, "x": 84, "var": "btnLeft", "skin": "rank/btnLeft.png" }, "compId": 43 }, { "type": "Image", "props": { "y": 713, "x": 380, "var": "btnRight", "skin": "rank/btnRight.png" }, "compId": 44 }, { "type": "Image", "props": { "y": 897, "x": 280, "width": 385, "var": "btnBack", "skin": "rank/button.png", "height": 120, "centerX": 0, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 45, "child": [{ "type": "Image", "props": { "skin": "rank/txtBack.png", "centerY": -12, "centerX": 0 }, "compId": 46 }] }, { "type": "Text", "props": { "y": 213, "x": 93, "text": "一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一", "name": "line", "runtime": "laya.display.Text" }, "compId": 12 }, { "type": "Text", "props": { "y": 325, "x": 93, "text": "一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一", "name": "line", "runtime": "laya.display.Text" }, "compId": 20 }, { "type": "Text", "props": { "y": 438, "x": 93, "text": "一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一", "name": "line", "runtime": "laya.display.Text" }, "compId": 27 }, { "type": "Text", "props": { "y": 550, "x": 93, "text": "一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一", "name": "line", "runtime": "laya.display.Text" }, "compId": 34 }] }, { "type": "Box", "props": { "y": 205, "x": 95, "width": 530, "var": "sub_rankList", "height": 434 }, "compId": 13, "child": [{ "type": "Box", "props": { "y": -7, "x": 0, "width": 530, "visible": false, "var": "rankCell0", "height": 100 }, "compId": 5, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 6 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": true, "skin": "rank/rank1.png", "name": "iconRank" }, "compId": 7 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 8 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "1", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 9 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 10 }] }, { "type": "Box", "props": { "y": 105, "x": 0, "width": 530, "visible": false, "var": "rankCell1", "height": 100 }, "compId": 14, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 15 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": true, "skin": "rank/rank2.png", "name": "iconRank" }, "compId": 16 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 17 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "2", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 18 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 19 }] }, { "type": "Box", "props": { "y": 218, "x": 0, "width": 530, "visible": false, "var": "rankCell2", "height": 100 }, "compId": 21, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 22 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": true, "skin": "rank/rank3.png", "name": "iconRank" }, "compId": 23 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 24 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "3", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 25 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 26 }] }, { "type": "Box", "props": { "y": 330, "x": 0, "width": 530, "visible": false, "var": "rankCell3", "height": 100 }, "compId": 28, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 29 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": false, "skin": "rank/rank1.png", "name": "iconRank" }, "compId": 30 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 31 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "4", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 32 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 33 }] }, { "type": "Box", "props": { "y": 463, "x": 0, "width": 530, "visible": false, "var": "rankSelf", "height": 100 }, "compId": 36, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 37 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": false, "skin": "rank/rank1.png", "name": "iconRank" }, "compId": 38 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 39 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "4", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 40 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 41 }] }] }] }] }], "loadList": ["rank/rect1.png", "rank/default.png", "rank/rect2.png", "rank/rect3.png", "rank/bg.png", "rank/titleRank.png", "rank/btnLeft.png", "rank/btnRight.png", "rank/button.png", "rank/txtBack.png", "rank/rank1.png", "rank/rank2.png", "rank/rank3.png"], "loadList3D": [] }; ui.RankUI = RankUI; REG("ui.RankUI", RankUI); class SunUI extends Laya.View { constructor() { super(); } createChildren() { super.createChildren(); this.createView(SunUI.uiView); } } SunUI.uiView = { "type": "View", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Box", "props": { "y": 411, "x": 360, "width": 350, "var": "sunNode", "pivotY": 175, "pivotX": 175, "name": "sunNode", "height": 350 }, "compId": 50, "child": [{ "type": "Box", "props": { "y": 175, "x": 175, "width": 350, "var": "sunAndKnifeNode", "pivotY": 175, "pivotX": 175, "name": "sunAndKnifeNode", "height": 350 }, "compId": 7, "child": [{ "type": "Sprite", "props": { "y": -90, "x": -90, "visible": false, "var": "sunShine", "texture": "texture/Sun/sunShine1.png", "name": "sunShine" }, "compId": 38 }, { "type": "Sprite", "props": { "y": -12, "x": -12, "texture": "texture/Sun/outerGrowOfSun.png", "name": "sunShineRing" }, "compId": 40 }, { "type": "Sprite", "props": { "y": 175, "x": 175, "width": 350, "var": "treeNode", "texture": "texture/Sun/sunBG_normal.png", "pivotY": 175, "pivotX": 175, "name": "treeNode", "height": 350 }, "compId": 27, "child": [{ "type": "Sprite", "props": { "y": 266, "x": 175, "width": 56, "visible": false, "texture": "texture/GameScene/obstacle.png", "pivotX": 28, "height": 111 }, "compId": 34 }] }, { "type": "Sprite", "props": { "y": 175, "x": 175, "width": 350, "var": "knifeNode", "texture": "texture/Sun/sunBG_normal.png", "pivotY": 175, "pivotX": 175, "name": "knifeNode", "height": 350 }, "compId": 3, "child": [{ "type": "Sprite", "props": { "y": 192, "x": 323, "visible": false, "texture": "texture/GameScene/rocket.png", "rotation": -83, "pivotX": 28 }, "compId": 81 }] }, { "type": "Sprite", "props": { "y": 174, "x": 174, "width": 445, "var": "sunBG", "texture": "texture/Sun/sunBG_normal.png", "pivotY": 194, "pivotX": 223, "name": "sunBG", "height": 387 }, "compId": 53 }, { "type": "Sprite", "props": { "y": 152.5, "x": 331.5, "width": 37, "visible": false, "texture": "texture/MainScene/btn_add.png", "name": "angle0Sign", "height": 45 }, "compId": 86 }] }, { "type": "Sprite", "props": { "y": 175, "x": 175, "var": "sunEmoji", "texture": "texture/Sun/biaoqing_kuqi.png", "pivotY": 175, "pivotX": 175, "name": "sunEmoji" }, "compId": 6 }, { "type": "Box", "props": { "y": 175, "x": 175, "width": 350, "var": "RiftNode", "pivotY": 175, "pivotX": 175, "name": "RiftNode", "height": 350 }, "compId": 55, "child": [{ "type": "Sprite", "props": { "y": 350, "x": 175, "width": 43, "visible": false, "texture": "texture/Effect/SunRift/Rift01_01.png", "rotation": 0, "pivotY": 114, "pivotX": 21.5, "height": 114 }, "compId": 56 }] }, { "type": "Sprite", "props": { "y": 330, "x": 175, "width": 56, "visible": false, "texture": "texture/GameScene/obstacle.png", "pivotX": 28, "height": 111 }, "compId": 82 }, { "type": "Text", "props": { "y": 41, "x": 109, "width": 132, "visible": false, "var": "text_sunRotation", "text": "999", "strokeColor": "#ffffff", "stroke": 3, "name": "text_sunRotation", "height": 48, "fontSize": 48, "color": "#ff0400", "align": "center", "runtime": "laya.display.Text" }, "compId": 84 }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "var": "planetOuterRingNode", "height": 1280 }, "compId": 51, "child": [{ "type": "Sprite", "props": { "y": 411, "x": 360, "width": 878, "var": "planetOuterRing", "texture": "texture/GameScene/outRing.png", "pivotY": 439, "pivotX": 439, "name": "planetOuterRing", "height": 878 }, "compId": 36 }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "var": "planetInnerRingNode", "height": 1280 }, "compId": 52, "child": [{ "type": "Sprite", "props": { "y": 411, "x": 360, "width": 588, "var": "planetInnerRing", "texture": "texture/GameScene/innerRing.png", "pivotY": 294, "pivotX": 294, "name": "planetInnerRing", "height": 588 }, "compId": 35 }] }, { "type": "Sprite", "props": { "y": 690, "x": 424, "width": 174, "visible": false, "texture": "texture/Planet/Jupiter.png", "rotation": 0, "pivotY": 88, "pivotX": 87, "height": 175 }, "compId": 48, "child": [{ "type": "Sprite", "props": { "y": 140, "x": 118, "width": 14, "visible": false, "texture": "texture/Effect/PlanetRift/Rift01.png", "rotation": -24, "pivotY": 43, "pivotX": 7, "height": 43 }, "compId": 60 }] }, { "type": "Sprite", "props": { "y": 400, "x": 360, "width": 328, "visible": false, "texture": "texture/Effect/ringEffect/add_blood.png", "pivotY": 164, "pivotX": 164, "height": 328 }, "compId": 63 }, { "type": "Box", "props": { "y": 411, "x": 360, "width": 405, "var": "shieldNode", "pivotY": 202, "pivotX": 203, "name": "shieldNode", "height": 403 }, "compId": 64 }, { "type": "Box", "props": { "width": 720, "var": "UINode", "name": "UINode", "height": 1280 }, "compId": 67, "child": [{ "type": "Panel", "props": { "y": 411, "x": 360, "width": 275, "var": "critNode", "pivotY": 110, "pivotX": 138, "name": "critNode", "height": 220 }, "compId": 80, "child": [{ "type": "Sprite", "props": { "y": 110, "x": 107, "width": 214, "var": "critBG", "texture": "texture/Effect/Crit/CritFire.png", "pivotY": 110, "pivotX": 107, "height": 220 }, "compId": 70 }, { "type": "Panel", "props": { "y": 60, "x": 0, "width": 128, "var": "critTextPanel", "height": 100 }, "compId": 73, "child": [{ "type": "Sprite", "props": { "y": 50, "x": 0, "width": 128, "texture": "texture/Effect/Crit/CritText.png", "pivotY": 28, "height": 56 }, "compId": 71 }] }, { "type": "Panel", "props": { "y": 60, "x": 128, "var": "critNumPanel", "name": "critNumPanel" }, "compId": 77, "child": [{ "type": "FontClip", "props": { "y": 8, "x": 0, "var": "critNum", "skin": "texture/Effect/Crit/clip_num_crit.png", "sheet": "0123456789", "name": "critNum" }, "compId": 79 }] }, { "type": "Panel", "props": { "y": 60, "x": 200, "width": 79, "var": "hpPanel" }, "compId": 74, "child": [{ "type": "Sprite", "props": { "y": 50, "x": 0, "width": 79, "texture": "texture/Effect/Crit/hp.png", "pivotY": 33, "height": 65 }, "compId": 76 }] }] }, { "type": "Box", "props": { "y": 411, "x": 0, "var": "normalNumBox", "pivotY": 42, "name": "normalNumBox", "height": 83 }, "compId": 89, "child": [{ "type": "FontClip", "props": { "x": 360, "visible": false, "var": "normalNum", "value": "0123", "skin": "texture/Effect/Crit/clip_num_crit.png", "sheet": "0123456789", "name": "normalNum", "height": 83 }, "compId": 94, "child": [{ "type": "Panel", "props": { "y": -8, "x": -60, "left": -60, "height": 83 }, "compId": 93, "child": [{ "type": "Sprite", "props": { "y": 0, "x": 0, "width": 44, "texture": "texture/Effect/Crit/symbol.png", "height": 83 }, "compId": 90 }] }, { "type": "Sprite", "props": { "y": 13.5, "x": -10, "visible": false, "texture": "texture/Effect/Crit/CritText.png" }, "compId": 98 }] }] }] }], "loadList": ["texture/Sun/sunShine1.png", "texture/Sun/outerGrowOfSun.png", "texture/Sun/sunBG_normal.png", "texture/GameScene/obstacle.png", "texture/GameScene/rocket.png", "texture/MainScene/btn_add.png", "texture/Sun/biaoqing_kuqi.png", "texture/Effect/SunRift/Rift01_01.png", "texture/GameScene/outRing.png", "texture/GameScene/innerRing.png", "texture/Planet/Jupiter.png", "texture/Effect/PlanetRift/Rift01.png", "texture/Effect/ringEffect/add_blood.png", "texture/Effect/Crit/CritFire.png", "texture/Effect/Crit/CritText.png", "texture/Effect/Crit/clip_num_crit.png", "texture/Effect/Crit/hp.png", "texture/Effect/Crit/symbol.png"], "loadList3D": [] }; ui.SunUI = SunUI; REG("ui.SunUI", SunUI); })(ui || (ui = {})); class AnimationControl { constructor() { } static playAnimation(aniConfPath, parent, posX, posY, interval, isLoop, pivotX, pivotY, callback, callbackDelay) { let ani = Laya.Pool.getItemByClass("EffectAnimation", Laya.Animation); parent.addChild(ani); ani.loadAtlas(aniConfPath); ani.interval = interval; ani.index = 1; ani.play(0, isLoop); ani.pivot(pivotX, pivotY); ani.pos(posX, posY); ani.scaleX = 2; ani.scaleY = 2; if (!isLoop) { let fun = function () { ani.removeSelf(); Laya.Pool.recover("EffectAnimation", ani); if (callback) { if (callbackDelay) { Laya.timer.once(callbackDelay, this, callback); } else { callback(); } } ani.off(Laya.Event.COMPLETE, this, fun); }; ani.on(Laya.Event.COMPLETE, this, fun); } return ani; } static playFingerAni() { let aniPath = "res/atlas/texture/Effect/Finger.atlas"; let pivotX = 0; let pivotY = 0; let posX = 0; let posY = 0; return AnimationControl.playAnimation(aniPath, Laya.stage, posX, posY, 150, true, pivotX, pivotY); } static sunLiquidAni(knife, parent, posX, posY) { let aniPath = ""; let num = 0; let pivotX = 0; let pivotY = 0; if (knife.isInvincible == false) { num = MainScene.gameControl.smallLiquiCount % 3 + 1; MainScene.gameControl.smallLiquiCount += 1; aniPath = "res/atlas/texture/Effect/SunLiquidSmall0" + num + ".atlas"; switch (num) { case 1: pivotX = 145; pivotY = 142; break; case 2: pivotX = 110; pivotY = 80; break; case 3: pivotX = 63; pivotY = 90; break; default: break; } } else { num = MainScene.gameControl.bigLiquiCount % 3 + 1; MainScene.gameControl.bigLiquiCount += 1; aniPath = "res/atlas/texture/Effect/SunLiquidBig0" + num + ".atlas"; switch (num) { case 1: pivotX = 185; pivotY = 127; break; case 2: pivotX = 190; pivotY = 122; break; case 3: pivotX = 182; pivotY = 137; break; default: break; } } return AnimationControl.playAnimation(aniPath, parent, posX, posY, 30, false, pivotX, pivotY, null); } static sunDieAni(callback, callbackDelay) { let aniPath = "res/atlas/texture/Effect/SunDieFlame.atlas"; let pivotX = 360 / 2; let pivotY = 330 / 2; let posX = MainScene.sun.sunNode.x; let posY = MainScene.sun.sunNode.y; return AnimationControl.playAnimation(aniPath, MainScene.sun, posX, posY, 30, false, pivotX, pivotY, callback, callbackDelay); } static reviveFireAni(callback, callbackDelay) { let aniPath = "res/atlas/texture/Effect/ReviveFire.atlas"; let pivotX = 230 / 2; let pivotY = 230 / 2; let posX = MainScene.sun.sunNode.x; let posY = MainScene.sun.sunNode.y; return AnimationControl.playAnimation(aniPath, MainScene.sun, posX, posY, 90, false, pivotX, pivotY, callback, callbackDelay); } static knifeFireAni(knife) { let aniPath = "res/atlas/texture/Effect/RocketFire.atlas"; let posX = knife.width / 2 - 5; let posY = knife.height - 8; let ani = new Laya.Animation(); ani.visible = true; ani.loadAtlas(aniPath); ani.interval = 30; ani.index = 1; ani.play(0, true); ani.pivot(47 / 2, 0); ani.pos(posX, posY); knife.addChild(ani); return ani; } static planetDieExplode(planet, completeEvent) { let aniPath = "res/atlas/texture/Effect/PlanetExplode.atlas"; let pivotX = 115 / 2; let pivotY = 105 / 2; let posX = planet.planetImg.x; let posY = planet.planetImg.y; Laya.Tween.to(planet.planetImg, { scaleX: 1.3, scaleY: 1.3, alpha: 0 }, 300); return AnimationControl.playAnimation(aniPath, planet.planetNode, posX, posY, 50, false, pivotX, pivotY, completeEvent); } static planetFireball(planet, aniConfPath) { let pivotX = 120 / 2; let pivotY = 310; let posX = 0; let posY = 0; let innerPos = new Laya.Point(MainScene.sun.planetInnerRing.x, MainScene.sun.planetInnerRing.y + MainScene.sun.planetInnerRing.height / 2); innerPos = MainScene.sun.planetInnerRingNode.localToGlobal(innerPos); let outerPos = new Laya.Point(MainScene.sun.planetOuterRing.x, MainScene.sun.planetOuterRing.y + MainScene.sun.planetOuterRing.height / 2); outerPos = MainScene.sun.planetOuterRingNode.localToGlobal(outerPos); if (planet.orbit == 0) { posX = innerPos.x; posY = innerPos.y; } else if (planet.orbit == 1) { posX = outerPos.x; posY = outerPos.y; } let ani = AnimationControl.playAnimation(aniConfPath, Laya.stage, posX, posY, 30, false, pivotX, pivotY, null); if (planet.orbit == 0) { ani.scaleX = 1.5; ani.scaleY = 1.5; } else if (planet.orbit == 1) { ani.scaleX = 2; ani.scaleY = 2; } ani.rotation = 0; } static blowUpObstacle(parent, fun) { let aniPath = "res/atlas/texture/Effect/Planet_Mars/BlowUpRocket.atlas"; let posX = parent.width / 2; let posY = parent.height - 10; let pivotX = 90 / 2; let pivotY = 90 / 2; let ani = AnimationControl.playAnimation(aniPath, parent, posX, posY, 50, false, pivotX, pivotY, fun); } static planet_Jupiter_addTree(parent) { let aniConfPath = "res/atlas/texture/Effect/Planet_Jupiter.atlas"; let posX = parent.width / 2; let posY = parent.height + 50; let pivotX = 105 / 2; let pivotY = 190 / 2; let ani = AnimationControl.playAnimation(aniConfPath, parent, posX, posY, 30, false, pivotX, pivotY, null); ani.scaleY = -2; } static knifeABumpedObjB(ObjB, objBType, finishEvent) { let redTwinklePath = ""; switch (objBType) { case 0: redTwinklePath = "texture/GameScene/redTwinkle.png"; break; case 1: redTwinklePath = "texture/GameScene/redTwinkle_propRocket.png"; break; case 2: redTwinklePath = "texture/GameScene/redTwinkle_tree.png"; break; default: break; } let sp_redTwinkle = new Laya.Sprite(); sp_redTwinkle.loadImage(redTwinklePath); ObjB.addChild(sp_redTwinkle); sp_redTwinkle.pivot(sp_redTwinkle.width / 2, sp_redTwinkle.height / 2); sp_redTwinkle.pos(ObjB.width / 2, ObjB.height / 2); let count = 0; let fun = function () { if (count < 6) { if (count % 2 == 0) { sp_redTwinkle.visible = false; } else { sp_redTwinkle.visible = true; } count += 1; } else { if (finishEvent) finishEvent(); Laya.timer.clear(this, fun); sp_redTwinkle.removeSelf; sp_redTwinkle.destroy(); } }; Laya.timer.loop(80, this, fun); } static screenShake(shakeValue, tag) { let screen = MainScene.instance.SceneBox; screen.pivot(screen.width / 2, screen.height / 2); screen.pos(Laya.stage.width / 2, Laya.stage.height / 2); let pos1 = [Laya.stage.width / 2, Laya.stage.height / 2]; let random1 = this.getRandomPos([3 * shakeValue, 8 * shakeValue], [10 * shakeValue, 20 * shakeValue]); let random2 = [-random1[0], -random1[1]]; Laya.Tween.to(screen, { x: pos1[0] + random1[0], y: pos1[1] + random1[1] }, 50, null, Laya.Handler.create(this, function () { Laya.Tween.to(screen, { x: pos1[0] + random2[0], y: pos1[1] + random2[1] }, 50, null, Laya.Handler.create(this, function () { Laya.Tween.to(screen, { x: pos1[0], y: pos1[1] }, 50); })); })); if (shakeValue > 1 && tag != 1) { let newTag = 1; Laya.timer.once(200, this, function () { this.screenShake(shakeValue, newTag); }); } } static getRandomPos(xRange, yRange) { let xMin = xRange[0]; let xMax = xRange[1]; let randomX = Math.random() * (xMax - xMin) + xMin; let randomXCoefficient = Math.round(Math.random()) * 2 - 1; let yMin = xRange[0]; let yMax = xRange[1]; let randomY = Math.random() * (yMax - yMin) + yMin; let randomYCoefficient = Math.round(Math.random()) * 2 - 1; let randomPos = [randomX * randomXCoefficient, randomY * randomYCoefficient]; return randomPos; } static playAddBloodNumAni(addNum) { let instance = MainScene.instance; let addBloodText = instance.text_addBloodNum; addBloodText.text = "+" + addNum; let point = new Laya.Point(instance.iconHeart.x + instance.iconHeart.width / 2, instance.iconHeart.y + instance.iconHeart.height / 2); let protoPos = instance.iconHeart.localToGlobal(point); let parent = addBloodText.parent; protoPos = instance.gameUI.globalToLocal(protoPos); let protoY = protoPos.y; addBloodText.pos(protoPos.x, protoPos.y); addBloodText.alpha = 0; addBloodText.scale(0.7, 0.7); addBloodText.y = protoY + 20; Laya.Tween.to(addBloodText, { alpha: 1, scaleX: 1, scaleY: 1, y: protoPos.y }, 650, Laya.Ease.linearIn, Laya.Handler.create(this, function () { Laya.Tween.to(addBloodText, { alpha: 0, y: protoPos.y - 20 }, 350); })); } static btnClickAni(btn) { btn.scale(0.8, 0.8); Laya.Tween.to(btn, { scaleX: 1, scaleY: 1 }, 600, Laya.Ease.backOut); } static startGameBtnAni() { MainScene.instance.btn_startGame.visible = false; let startBtnSP = MainScene.instance.startBtnSP; let strengthSP = MainScene.instance.strengthSPUnderStartGame; let posTP = [MainScene.instance.btn_startGame.x, MainScene.instance.btn_startGame.y]; let posSP = new Laya.Point(MainScene.instance.icon_strength.width / 2, MainScene.instance.icon_strength.height / 2); posSP = MainScene.instance.icon_strength.localToGlobal(posSP); posSP = MainScene.instance.homeUI.globalToLocal(posSP); startBtnSP.pivot(startBtnSP.width / 2, startBtnSP.height / 2); startBtnSP.pos(posTP[0], posTP[1]); startBtnSP.scale(1, 1); startBtnSP.visible = true; startBtnSP.alpha = 1; Laya.Tween.to(startBtnSP, { scaleX: 0, scaleY: 0 }, 500); MainScene.gameControl.updateHomeUI(); AnimationControl.homeUIMoveOut(); } static homeUIMoveOut() { let instance = MainScene.instance; let moveDist = 1000; let moveTime = 500; Laya.Tween.to(instance.topUI, { y: -moveDist }, moveTime); Laya.Tween.to(instance.bottomUI, { y: moveDist }, moveTime); Laya.Tween.to(instance.leftUI, { x: -moveDist }, moveTime); Laya.Tween.to(instance.rightUI, { x: moveDist }, moveTime); } static gameUIMoveIn(callback) { let instance = MainScene.instance; instance.gameUI.visible = true; let moveDist = 1000; let moveTime = 800; instance.gameLeftUI.x = -moveDist; instance.gameRightUI.x = moveDist; instance.gameTopUI.y = -moveDist; let aaa = Laya.Tween.to(instance.gameTopUI, { y: 0 }, moveTime, Laya.Ease.linearNone, Laya.Handler.create(this, function (res) { if (callback) { callback(); } })); Laya.Tween.to(instance.gameLeftUI, { x: 0 }, moveTime); Laya.Tween.to(instance.gameRightUI, { x: 0 }, moveTime); } static playIconPlusAni(planet, imgPath) { let startPoint = new Laya.Point(planet.iconPlanetSkill.x, planet.iconPlanetSkill.y); let coinsNumRange = [5, 7]; let coinsNum = Math.floor(Math.random() * (coinsNumRange[1] - coinsNumRange[0])) + coinsNumRange[0]; let MP = [0, 0]; MP[0] = Math.random() * MP[0] + startPoint.x; MP[1] = Math.random() * MP[1] + startPoint.y; for (let i = 0; i < coinsNum; i++) { let effect = new EffectImg(); effect.SP = [startPoint.x, startPoint.y]; effect.MP = [MP[0], MP[1]]; effect.showPlanetIconAni(imgPath, planet); } } static playCoinsFlyAni(startPoint, targetPoint) { let imgPath = "texture/MainScene/TAB/icon_Coin.png"; let coinsNumRange = [15, 25]; let coinsNum = Math.floor(Math.random() * (coinsNumRange[1] - coinsNumRange[0])) + coinsNumRange[0]; for (let i = 0; i < coinsNum; i++) { let effect = new EffectImg(); effect.size(62, 62); let MP = [500, 500]; MP[0] = Math.random() * MP[0] + startPoint.x; MP[1] = Math.random() * MP[1] + startPoint.y; effect.SP = [startPoint.x, startPoint.y]; effect.MP = [MP[0], MP[1]]; effect.TP = [targetPoint.x, targetPoint.y]; effect.showSpreadToGatherAni(imgPath); } } static playStrengthFlyAni(startPoint, targetPoint) { let imgPath = "texture/MainScene/TAB/icon_strength.png"; let coinsNum = 5; for (let i = 0; i < coinsNum; i++) { let effect = new EffectImg(); effect.size(87 * 0.8, 101 * 0.8); let MP = [0, 0]; MP[0] = Math.random() * MP[0] + startPoint.x; MP[1] = Math.random() * MP[1] + startPoint.y; effect.SP = [startPoint.x, startPoint.y]; effect.MP = [MP[0], MP[1]]; effect.TP = [targetPoint.x, targetPoint.y]; effect.speed = 0.013; effect.showSpreadToGatherAni(imgPath); } } static playCritNumAni(hpNum, parent, pos, scale) { let sp_critFire = Laya.Pool.getItemByClass("sp_critFire", Laya.Sprite); sp_critFire.loadImage("texture/Effect/Crit/CritFire.png"); let sp_critSymbol = Laya.Pool.getItemByClass("sp_critSymbol", Laya.Sprite); sp_critSymbol.loadImage("texture/Effect/Crit/CritText.png"); let clip_num_crit = Laya.Pool.getItemByClass("clip_num_crit", Laya.FontClip); clip_num_crit.skin = "texture/Effect/Crit/clip_num_crit.png"; clip_num_crit.sheet = "0123456789"; clip_num_crit.value = hpNum; sp_critFire.scale(scale, scale); let sp_hp = Laya.Pool.getItemByClass("sp_hp", Laya.Sprite); sp_hp.loadImage("texture/Effect/Crit/hp.png"); Laya.timer.once(100, this, function () { clip_num_crit.pivot(clip_num_crit.width / 2, clip_num_crit.height / 2); clip_num_crit.addChild(sp_critSymbol); sp_critSymbol.x = -sp_critSymbol.width; parent.addChild(sp_critFire); sp_critFire.pivot(sp_critFire.width / 2, sp_critFire.height / 2); sp_critFire.pos(pos[0] + 30, pos[1] + 50); sp_critFire.addChild(clip_num_crit); clip_num_crit.pos(sp_critFire.width / 2, sp_critFire.height / 2); clip_num_crit.addChild(sp_hp); sp_hp.x = clip_num_crit.width; sp_critFire.alpha = 0; Laya.Tween.to(sp_critFire, { y: pos[1], alpha: 1 }, 150, Laya.Ease.linearIn, Laya.Handler.create(this, function () { Laya.timer.once(500, this, function () { Laya.Tween.to(sp_critFire, { alpha: 0 }, 100); }); Laya.Tween.to(sp_critFire, { y: pos[1] - 50 }, 600, null, Laya.Handler.create(this, function () { sp_critSymbol.removeSelf(); Laya.Pool.recover("sp_symbol", sp_critSymbol); clip_num_crit.removeSelf(); Laya.Pool.recover("clip_num_crit", clip_num_crit); sp_critFire.removeSelf(); Laya.Pool.recover("sp_critFire", sp_critFire); sp_hp.removeSelf(); Laya.Pool.recover("sp_hp", sp_hp); })); })); }); } static playSubBloodNumAni(hpNum, parent, pos, scale) { let sp_symbol = Laya.Pool.getItemByClass("sp_symbol", Laya.Sprite); sp_symbol.loadImage("texture/Effect/Crit/symbol.png"); let clip_num_normal = Laya.Pool.getItemByClass("clip_num_normal", Laya.FontClip); clip_num_normal.skin = "texture/Effect/Crit/clip_num_crit.png"; clip_num_normal.sheet = "0123456789"; clip_num_normal.value = hpNum; clip_num_normal.scale(scale, scale); Laya.timer.once(100, this, function () { clip_num_normal.pivotX = clip_num_normal.width / 2; clip_num_normal.addChild(sp_symbol); sp_symbol.x = -sp_symbol.width; parent.addChild(clip_num_normal); clip_num_normal.pos(pos[0], pos[1] + 50); clip_num_normal.alpha = 0; Laya.Tween.to(clip_num_normal, { y: pos[1], alpha: 1 }, 150, Laya.Ease.linearIn, Laya.Handler.create(this, function () { Laya.timer.once(500, this, function () { Laya.Tween.to(clip_num_normal, { alpha: 0 }, 100); }); Laya.Tween.to(clip_num_normal, { y: pos[1] - 50 }, 600, null, Laya.Handler.create(this, function () { sp_symbol.removeSelf(); Laya.Pool.recover("sp_symbol", sp_symbol); clip_num_normal.removeSelf(); Laya.Pool.recover("clip_num_normal", clip_num_normal); })); })); }); } static playJump(posX, posY) { let aniPath = "res/atlas/texture/aniJump.atlas"; let pivotX = 0; let pivotY = 0; return AnimationControl.playAnimation(aniPath, Laya.stage, posX, posY, 40, true, pivotX, pivotY); } } class EffectImg extends Laya.Sprite { constructor() { super(...arguments); this.t = 0; this.curP = [0, 0]; this.SP = [0, 0]; this.MP = [0, 0]; this.TP = [0, 0]; this.tRandom = 0; this.speed = 0.01; } showPlanetIconAni(imgPath, planet) { let texture = Laya.loader.getRes(imgPath); this.texture = texture; this.planet = planet; this.planet.addChild(this); this.pos(this.SP[0], this.SP[1]); this.zOrder += 200; this.scaleX = 1; this.scaleY = 1; this.curP = [this.SP[0], this.SP[1]]; this.tRandom = Math.random() * 0.01; Laya.timer.frameLoop(1, this, this.timer_planetIconAni); } timer_planetIconAni() { let targetPoint = new Laya.Point(MainScene.sun.sunNode.x, MainScene.sun.sunNode.y); targetPoint = MainScene.sun.localToGlobal(targetPoint); targetPoint = this.planet.globalToLocal(targetPoint); let TP = [targetPoint.x, targetPoint.y]; if (this.t + 0.01 > 1) { this.removeSelf(); this.destroy(); Laya.timer.clear(this, this.timer_planetIconAni); return; } ; this.t += (0.013 + this.tRandom); this.scaleX = 1 - this.t / 3; this.scaleY = 1 - this.t / 3; this.alpha = Math.ceil(1 - this.t); this.curP[0] = Math.pow((1 - this.t), 2) * this.SP[0] + 2 * this.t * (1 - this.t) * this.MP[0] + Math.pow(this.t, 2) * TP[0]; this.curP[1] = Math.pow((1 - this.t), 2) * this.SP[1] + 2 * this.t * (1 - this.t) * this.MP[1] + Math.pow(this.t, 2) * TP[1]; this.pos(this.curP[0], this.curP[1]); } showSpreadToGatherAni(imgPath) { let texture = Laya.loader.getRes(imgPath); this.texture = texture; Laya.stage.addChild(this); this.pos(this.SP[0], this.SP[1]); this.zOrder += 200; this.scaleX = 1; this.scaleY = 1; this.curP = [this.SP[0], this.SP[1]]; this.tRandom = Math.random() * 0.01; Laya.timer.frameLoop(1, this, this.timer_SpreadToGather); } timer_SpreadToGather() { if (this.t + 0.01 > 1) { this.removeSelf(); this.destroy(); Laya.timer.clear(this, this.timer_SpreadToGather); return; } ; this.t += (this.speed + this.tRandom); if (this.t >= 0.5) { this.scaleX -= 0.01; this.scaleY -= 0.01; } this.curP[0] = Math.pow((1 - this.t), 2) * this.SP[0] + 2 * this.t * (1 - this.t) * this.MP[0] + Math.pow(this.t, 2) * this.TP[0]; this.curP[1] = Math.pow((1 - this.t), 2) * this.SP[1] + 2 * this.t * (1 - this.t) * this.MP[1] + Math.pow(this.t, 2) * this.TP[1]; this.pos(this.curP[0], this.curP[1]); } } class MathTool { static currencyUnit(num) { if (num != 0 && !num) return "num_null"; let currency = num.toString(); let length = currency.length; if (length <= 3) { return currency; } let units = ['', 'k', 'm', 'b', 't']; let letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; for (let i = 0; i < 4; i++) { if (i < 3) { for (let j = 0; j < letters.length; j++) { units.push(letters[i] + letters[j]); } } else { for (let j = 0; j < 13; j++) { units.push(letters[i] + letters[j]); } } } let times = Math.floor((length - 1) / 3); let remainder = length % 3; remainder = remainder == 0 ? 3 : remainder; let unit = ''; for (let i = 0; i < remainder; i++) { unit += currency[i]; } unit += '.'; unit += currency[remainder]; unit += currency[remainder + 1]; unit += units[times]; return unit; } static shuffle(arr) { let m = arr.length; while (m > 1) { let index = Math.floor(Math.random() * m--); [arr[m], arr[index]] = [arr[index], arr[m]]; } return arr; } static secendToHour(timeNum) { let hour = Math.floor(timeNum / 3600); let minute = Math.floor((timeNum - hour * 3600) / 60); let second = Math.floor(timeNum % 60); let str_hour = (hour >= 10) ? (hour + "") : (hour > 0 ? ("0" + hour) : "00"); let str_minute = (minute >= 10) ? (minute + "") : (minute > 0 ? ("0" + minute) : "00"); let str_second = (second >= 10) ? (second + "") : (second > 0 ? ("0" + second) : "00"); let str = str_hour + ":" + str_minute + ":" + str_second; return str; } static angleBePositive(angle) { let aangle = angle % 360; if (aangle < 0) { aangle += 360; } return aangle; } static checkAngleIsInRange(angle, range) { let min = range[0]; let max = range[1]; if (min > max) { max += 360; } if (angle >= min && angle <= max) { return true; } else { return false; } } } class GameOverPage extends ui.Dialogs.Dialog_GameOverUI { constructor() { super(); this.isSuccessful = false; this.stayTime = 1300; this.init(); } init() { this.btn_threeTimesReceiving.on(Laya.Event.MOUSE_DOWN, this, this.onThreeTimesReceivingClick); this.btn_revive.on(Laya.Event.MOUSE_DOWN, this, this.onReviveClick); this.btn_giveUp.on(Laya.Event.MOUSE_DOWN, this, this.onGiveUpClick); let ahitArea = new Laya.HitArea(); let agraphics = new Laya.Graphics(); agraphics.drawRect(-10, -10, this.btn_giveUp.width + 20, this.btn_giveUp.height + 20, "#ff9900"); ahitArea.hit = agraphics; this.btn_giveUp.hitArea = ahitArea; } show_failedRevive() { this.defeatTopUI.visible = true; this.defeat_hasReviveChanceUI.visible = true; this.receiveCoinUI.visible = false; this.victoryTopUI.visible = false; this.refreshPage(); this.isSuccessful = false; this.btn_giveUp.visible = false; Laya.timer.once(3000, this, function () { this.btn_giveUp.visible = true; }); } show_failedRePlay() { this.defeatTopUI.visible = true; this.defeat_hasReviveChanceUI.visible = false; this.receiveCoinUI.visible = true; this.victoryTopUI.visible = false; this.refreshPage(); this.isSuccessful = false; MainScene.instance.updateGameState(4); Laya.timer.once(this.stayTime, this, this.onReceiveRightNowClick); } show_success() { this.defeatTopUI.visible = false; this.defeat_hasReviveChanceUI.visible = false; this.receiveCoinUI.visible = true; this.victoryTopUI.visible = true; this.refreshPage(); this.isSuccessful = true; MainScene.instance.updateGameState(4); Laya.timer.once(this.stayTime, this, this.onReceiveRightNowClick); } refreshPage() { let coinStr = MathTool.currencyUnit(MainScene.gameControl.coinNumFromCurLevel); this.btn_receiveRightNow.label = coinStr; this.text_coinNumFromCurLevel.text = coinStr; let bloodStr = MathTool.currencyUnit(MainScene.sun.curBlood); this.text_bloodNum.text = bloodStr; this.text_levelNum.text = MainScene.gameControl.curLevel + ""; this.text_levelNum.pivotX = this.text_levelNum.width / 2; this.text_levelNum.x = 360; this.levelNum_left.x = -(this.text_levelNum.pivotX + 10); this.levelNum_right.x = this.text_levelNum.width + 10; this.bloodBarMask.x = -(this.bloodBarMask.width * (1 - MainScene.sun.curBlood / MainScene.sun.totalBlood)); MainScene.gameControl.updateGameUI(); this.show(); } onReceiveRightNowClick() { Func.sharePointCount("threeTimesReceiveLevelCoins-close", 101); MainScene.gameControl.addCoins(MainScene.gameControl.coinNumFromCurLevel); if (this.isSuccessful) { MainScene.gameControl.recoverEnergies(5, 1); } this.gameover(); let startPoint = new Laya.Point(this.btn_receiveRightNow.width / 2, this.btn_receiveRightNow.height / 2); startPoint = this.btn_receiveRightNow.localToGlobal(startPoint); let iconCoin = MainScene.instance.icon_coin_homeLeftTop; let targetPoint = new Laya.Point(iconCoin.width / 2 + 1000, iconCoin.height / 2); targetPoint = iconCoin.localToGlobal(targetPoint); targetPoint.x = 42; AnimationControl.playCoinsFlyAni(startPoint, targetPoint); } onThreeTimesReceivingClick() { Func.sharePoint("threeTimesReceiveLevelCoins", false, this.onShare_threeTimesReceiving); Func.sharePointCount("threeTimesReceiveLevelCoins-open", 101); } onShare_threeTimesReceiving() { MainScene.gameControl.addCoins(MainScene.gameControl.coinNumFromCurLevel * 3); let self = MainScene.instance.gameOverUI; if (self.isSuccessful) { MainScene.gameControl.recoverEnergies(5, 1); } self.gameover(); let startPoint = new Laya.Point(Laya.stage.width / 2, Laya.stage.height / 2); let iconCoin = MainScene.instance.icon_coin_homeLeftTop; let targetPoint = new Laya.Point(iconCoin.width / 2 + 1000, iconCoin.height / 2); targetPoint = iconCoin.localToGlobal(targetPoint); targetPoint.x = 42; AnimationControl.playCoinsFlyAni(startPoint, targetPoint); } onReviveClick() { Func.sharePoint("revive", false, this.onShare_revive); Func.sharePointCount("revive-open", 101); BannerAd.hideBannerAd(); } onShare_revive() { MainScene.instance.gameOverUI.close(); MainScene.gameControl.revive(); MainScene.instance.updateGameState(2); } onGiveUpClick() { Func.sharePointCount("revive-close", 101); this.show_failedRePlay(); BannerAd.hideBannerAd(); } gameover() { if (MainScene.gameControl.getMaxLevel() > 1) { MainScene.gameControl.levelOver(); MainScene.sun.sunIdle(); MainScene.gameControl.levelStartInGame(); } else { MainScene.instance.returnHome(); } this.close(); } } class SkeletonControl { constructor() { } static initTemplet() { SkeletonControl.templet_addBlood = new Laya.Templet(); SkeletonControl.templet_addBlood.loadAni("dragonBone/addBlood/add_blood.sk"); SkeletonControl.templet_addBlood.on(Laya.Event.ERROR, this, this.onError); SkeletonControl.templet_sheild = new Laya.Templet(); SkeletonControl.templet_sheild.loadAni("dragonBone/shield/hudun.sk"); SkeletonControl.templet_sheild.on(Laya.Event.ERROR, this, this.onError); } static onError() { console.log("parse error"); } static playAddBloodAni() { let sk; sk = Laya.Pool.getItemByCreateFun("dbsk_add_blood", function () { return this.templet_addBlood.buildArmature(0); }, this); sk.pos(MainScene.sun.minSunPoint.x, MainScene.sun.minSunPoint.y - MainScene.sun.sunNode.height); sk.scale(2, 2); sk.showSkinByIndex(1); sk.play(0, true); MainScene.instance.effectBox.addChild(sk); let fun = function () { sk.removeSelf(); Laya.Pool.recover("dbsk_add_blood", sk); sk.off(Laya.Event.STOPPED, sk, fun); }; Laya.timer.once(1500, this, fun); } static playAddShieldAni(planet) { if (!MainScene.gameControl.isStartGame) return; let sP = planet.localToGlobal(new Laya.Point(0, 0)); let mP = [MainScene.sun.minSunPoint.x, MainScene.sun.minSunPoint.y - MainScene.sun.sunNode.height / 2]; let sk = Laya.Pool.getItemByCreateFun("hudun", function () { return this.templet_sheild.buildArmature(0); }, this); sk.alpha = 1; sk.pos(sP.x, sP.y); sk.scale(2, 2); sk.showSkinByIndex(1); sk.play(SkeletonControl.shieldAniName.greenlight, false); Laya.stage.addChild(sk); Laya.Tween.to(sk, { x: mP[0], y: mP[1] }, 300, null, Laya.Handler.create(this, function () { if (!MainScene.gameControl.isStartGame) { SkeletonControl.clearSheildAni(); } ; sk.removeSelf(); MainScene.sun.shieldNode.addChild(sk); sk.pos(MainScene.sun.shieldNode.width / 2, MainScene.sun.shieldNode.height / 2); let fun = function () { if (!MainScene.gameControl.isStartGame) { SkeletonControl.clearSheildAni(); } ; if (SkeletonControl.shieldSK) { sk.off(Laya.Event.STOPPED, sk, fun); Laya.Pool.recover("hudun", sk); } else { SkeletonControl.shieldSK = sk; sk.off(Laya.Event.STOPPED, sk, fun); let fun2 = function () { if (!MainScene.gameControl.isStartGame) { SkeletonControl.clearSheildAni(); } ; sk.off(Laya.Event.STOPPED, sk, fun2); sk.play(SkeletonControl.shieldAniName.hudun, true, true, 400, 2100); }; sk.on(Laya.Event.STOPPED, sk, fun2); sk.play(SkeletonControl.shieldAniName.hudun, false); } }; sk.on(Laya.Event.STOPPED, sk, fun); sk.play(SkeletonControl.shieldAniName.greenlight_expand, false); })); } static clearSheildAni() { let sk = this.shieldSK; if (!sk) return; Laya.Tween.to(sk, { alpha: 0 }, 300, null, Laya.Handler.create(this, function () { sk.removeSelf(); Laya.Pool.recover("hudun", sk); this.shieldSK = null; })); } static playSubBloodAni(callback) { let sk; sk = Laya.Pool.getItemByCreateFun("hudun", function () { return this.templet_sheild.buildArmature(0); }, this); sk.alpha = 1; sk.pos(MainScene.sun.minSunPoint.x, MainScene.sun.minSunPoint.y - MainScene.sun.sunNode.height / 2); sk.scale(2, 2); sk.showSkinByIndex(1); sk.play(SkeletonControl.shieldAniName.red_light, false); Laya.stage.addChild(sk); let fun = function () { if (callback) callback(); sk.removeSelf(); Laya.Pool.recover("hudun", sk); sk.off(Laya.Event.STOPPED, sk, fun); }; sk.on(Laya.Event.STOPPED, sk, fun); } } SkeletonControl.shieldAniName = { "greenlight": "1_greenlight", "greenlight_expand": "2_greenlight_expand", "hudun": "3_hudun", "red_light": "red_light" }; class FreelyGetPropPage extends ui.Dialogs.Dialog_FreelyGetPropUI { constructor() { super(); this.freelyChance = { "rocketChance": 4, "slowDownChance": 4, "subBloodChance": 4 }; this.btn_freeRevive.on(Laya.Event.MOUSE_DOWN, this, this.onClick_btn_freeRevive); this.btn_nextTime.on(Laya.Event.MOUSE_DOWN, this, this.onClick_btn_nextTime); } init() { this.freelyChance.rocketChance = 4; this.freelyChance.slowDownChance = 4; this.freelyChance.subBloodChance = 4; } onClick_btn_freeRevive() { let gameControl = MainScene.gameControl; switch (this.propType) { case 0: Func.sharePoint("freeProp", false, this.onShare_addProp_rocket); Func.sharePointCount("freeProp-open", 101); break; case 1: Func.sharePoint("freeProp", false, this.onShare_addProp_slowDown); Func.sharePointCount("freeProp-open", 101); break; case 2: Func.sharePoint("freeProp", false, this.onShare_addProp_subBlood); Func.sharePointCount("freeProp-open", 101); break; default: break; } this.close(); } onShare_addProp_rocket() { MainScene.instance.dialog_freelyGetProp.freelyChance.rocketChance -= 1; MainScene.gameControl.usingProp_rocket(); MusicControl.useProp(); } onShare_addProp_slowDown() { MainScene.instance.dialog_freelyGetProp.freelyChance.slowDownChance -= 1; MainScene.gameControl.usingProp_slowDown(); MusicControl.useProp(); } onShare_addProp_subBlood() { MainScene.instance.dialog_freelyGetProp.freelyChance.subBloodChance -= 1; SkeletonControl.playSubBloodAni(MainScene.gameControl.usingProp_subBlood); MusicControl.useProp(); } onClick_btn_nextTime() { this.close(); Func.sharePointCount("freeProp-close", 101); } showDialog(propType) { this.setPropType(propType); this.btn_nextTime.visible = false; Laya.timer.once(2000, this, this.hideBtnNextTime); super.show(); } hideBtnNextTime() { this.btn_nextTime.visible = true; } close() { Laya.timer.clear(this, this.hideBtnNextTime); super.close(); } setPropType(propType) { this.propType = propType; switch (propType) { case 0: this.text_propName.text = "火箭"; this.icon_prop.loadImage("texture/Dialog_GetProp/rocket.png"); this.btn_freeRevive.label = this.freelyChance.rocketChance + "/4"; this.text_propInfo.text = "可获得5个无撞击的无敌箭矢"; break; case 1: this.text_propName.text = "减速"; this.icon_prop.loadImage("texture/Dialog_GetProp/slowDown.png"); this.btn_freeRevive.label = this.freelyChance.slowDownChance + "/4"; this.text_propInfo.text = "降低病毒的转动速度"; break; case 2: this.text_propName.text = "减血"; this.icon_prop.loadImage("texture/Dialog_GetProp/subBlood.png"); this.btn_freeRevive.label = this.freelyChance.subBloodChance + "/4"; this.text_propInfo.text = "可使病毒的血量减半"; break; default: break; } } } class RANK_TYPE { } RANK_TYPE.LIST = "rankList"; RANK_TYPE.TOP1 = "rankTop1"; RANK_TYPE.TOP2 = "rankTop2"; RANK_TYPE.END1 = "rankEnd1"; RANK_TYPE.END2 = "rankEnd2"; RANK_TYPE.RIGHT = "rankRight"; class MyWXOpenContro extends Laya.WXOpenDataViewer { constructor() { super(); this.is_refresh = false; this.refresh_rate = 0; this.sharedCanvas = null; this.fresh_Loop = function () { if (this.is_refresh == true) { this.texture.bitmap.loadImageSource(this.sharedCanvas); } }; this.fresh_one = function () { if (window['wx'] && this.sharedCanvas) { Laya.timer.once(1000, this, () => { this.texture.bitmap.loadImageSource(this.sharedCanvas); }); } }; } onEnable() { let wx = window['wx']; if (wx) { this.sharedCanvas = wx.getOpenDataContext().canvas; if (this.sharedCanvas) { this.sharedCanvas.width = Consts.width; this.sharedCanvas.height = Consts.height; Laya.timer.frameLoop(5, this, this.fresh_Loop); } } } onDisable() { } } class RankDlg extends ui.RankUI { constructor() { super(); this.sharedTexture = null; this.frameIndex = 0; this.showRanks = {}; this.wxOpenDataViewer = null; this.platformBoxUI = null; this.is_show_list = false; RankDlg.thiz = this; this.btnBack.on(Laya.Event.CLICK, this, () => { console.log("返回点击事件"); this.rankList.visible = false; this.is_show_list = false; RankDlg.list_mask.visible = false; RankDlg.hide(RANK_TYPE.LIST); }); this.btnLeft.on(Laya.Event.CLICK, this, () => { let wx = window["wx"]; if (wx != null) { RankDlg.thiz.wxOpenDataViewer.postMsg({ cmd: "left" }); } }); this.btnRight.on(Laya.Event.CLICK, this, () => { let wx = window["wx"]; if (wx != null) { RankDlg.thiz.wxOpenDataViewer.postMsg({ cmd: "right" }); } }); this.rankTop1.on(Laya.Event.CLICK, this, () => { RankDlg.show(RANK_TYPE.LIST); }); this.rankTop2.on(Laya.Event.CLICK, this, () => { RankDlg.show(RANK_TYPE.LIST); }); this.rankRight.on(Laya.Event.CLICK, this, () => { RankDlg.show(RANK_TYPE.LIST); }); } isUpdate() { for (let key in this.showRanks) { if (this.showRanks[key]) { return true; } } return false; } static init(layer) { if (RankDlg.thiz == null) { this.init_mask(layer); let dlg = new RankDlg(); dlg.zOrder = 0; layer.addChild(dlg); RankDlg.thiz.platformBoxUI = layer; if (RankDlg.thiz.wxOpenDataViewer == null) { RankDlg.thiz.wxOpenDataViewer = new MyWXOpenContro(); RankDlg.thiz.wxOpenDataViewer.width = Consts.width; RankDlg.thiz.wxOpenDataViewer.height = Consts.height; RankDlg.thiz.wxOpenDataViewer.x = 0; RankDlg.thiz.wxOpenDataViewer.y = 0; RankDlg.thiz.wxOpenDataViewer.mouseEnabled = false; RankDlg.thiz.wxOpenDataViewer.mouseThrough = true; RankDlg.thiz.wxOpenDataViewer.zOrder = 999; RankDlg.thiz.platformBoxUI.addChild(RankDlg.thiz.wxOpenDataViewer); RankDlg.thiz.wxOpenDataViewer.is_refresh = false; } } } static init_mask(layer) { this.list_mask = new Laya.Image(); this.list_mask.size(1600, 1600); this.list_mask.anchorX = 0.5; this.list_mask.anchorY = 0.5; this.list_mask.skin = "UI/mask.png"; this.list_mask.pos(Consts.width / 2, Consts.height / 2); layer.addChild(this.list_mask); this.list_mask.visible = false; } func(type) { this.showRanks[type] = true; Laya.timer.once(3000, this, () => { if (type == RANK_TYPE.LIST) { if (this.rankList.visible) { this.showRanks[type] = true; } else { this.showRanks[type] = false; } } else { this.showRanks[type] = false; } }); } static show(type, score) { WXContro.setRankData(Data.getMaxScore()); let wx = window["wx"]; if (wx == null) return; RankDlg.thiz.platformBoxUI.visible = true; RankDlg.thiz.wxOpenDataViewer.postMsg({ cmd: "show", type: type, curScore: score === undefined ? Data.getMaxScore() : score, openid: LibData.getOpenid() }); if (type == RANK_TYPE.LIST) { this.thiz[type].visible = true; this.thiz.mouseThrough = false; this.thiz.showRanks[type] = true; this.thiz.is_show_list = true; this.list_mask.visible = true; } else if (type == RANK_TYPE.TOP1) { this.thiz[type].visible = true; this.thiz.func(type); if (!this.thiz.is_show_list) { this.list_mask.visible = false; } } else if (type == RANK_TYPE.TOP2) { this.thiz[type].visible = true; this.thiz.func(type); if (!this.thiz.is_show_list) { this.list_mask.visible = false; } } else if (type == RANK_TYPE.END1) { this.thiz.func(type); } else if (type == RANK_TYPE.END2) { this.thiz.func(type); this.list_mask.visible = false; } else if (type == RANK_TYPE.RIGHT) { this.thiz[type].visible = true; this.list_mask.visible = false; this.thiz.func(type); } Laya.timer.clear(this, this.show_schedule_callback); Laya.timer.clear(this, this.hide_schedule_callback); RankDlg.thiz.wxOpenDataViewer.is_refresh = true; if (type == RANK_TYPE.TOP2 || type == RANK_TYPE.TOP1) { RankDlg.thiz.wxOpenDataViewer.is_refresh = false; RankDlg.thiz.wxOpenDataViewer.fresh_one(); } else { Laya.timer.once(1500, this, this.show_schedule_callback); } } static hide(type) { let wx = window["wx"]; if (wx != null) { this.list_mask.visible = false; Laya.timer.clear(this, this.show_schedule_callback); Laya.timer.clear(this, this.hide_schedule_callback); RankDlg.thiz.wxOpenDataViewer.is_refresh = true; Laya.timer.once(1500, this, this.hide_schedule_callback); RankDlg.thiz.wxOpenDataViewer.postMsg({ cmd: "hide", type: type }); if (type == RANK_TYPE.LIST) { this.thiz.mouseThrough = true; } this.thiz[type].visible = false; this.thiz.func(type); } } static show_schedule_callback() { if (this.thiz.is_show_list == false) { RankDlg.thiz.wxOpenDataViewer.is_refresh = false; } else { RankDlg.thiz.wxOpenDataViewer.is_refresh = true; } } static hide_schedule_callback() { RankDlg.thiz.wxOpenDataViewer.is_refresh = false; } } RankDlg.thiz = null; RankDlg.list_mask = null; class Task { static init() { var wx = window["wx"]; if (wx) { var onShow = (res) => { console.log("task start"); if (res.scene == 1037 && res.query.in == Consts.appId && !this.started) { this.started = true; this.query = res.query; } if (this.started) { this.startTime = Date.now(); Laya.timer.clearAll(this); Laya.timer.once(Math.max(res.query.time * 1000 - this.lastTime, 0), this, () => { this.completed = true; this.complete(); }); } }; onShow(wx.getLaunchOptionsSync()); wx.onShow(onShow); wx.onHide((res) => { if (this.completed) { return; } if (this.started) { Laya.timer.clearAll(this); this.lastTime += Date.now() - this.startTime; } }); } } static complete() { let t = Date.now(); let url = Consts.host + '/task?action=complete' + '&name=' + this.query.appName + '&id=' + this.query.openid + '&t=' + t + "&appid=" + this.query.in + '&s=' + md5('&ytDuy1-c&,19_' + t + 'complete' + this.query.appName + this.query.openid); new Laya.HttpRequest().send(url); } } Task.lastTime = 0; Task.startTime = 0; Task.started = false; Task.completed = false; function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } function cmn(q, a, b, x, s, t) { return safe_add(rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b); } function ff(a, b, c, d, x, s, t) { return cmn((b & c) | ((~b) & d), a, b, x, s, t); } function gg(a, b, c, d, x, s, t) { return cmn((b & d) | (c & (~d)), a, b, x, s, t); } function hh(a, b, c, d, x, s, t) { return cmn(b ^ c ^ d, a, b, x, s, t); } function ii(a, b, c, d, x, s, t) { return cmn(c ^ (b | (~d)), a, b, x, s, t); } function coreMD5(x) { var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for (var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = ff(a, b, c, d, x[i + 0], 7, -680876936); d = ff(d, a, b, c, x[i + 1], 12, -389564586); c = ff(c, d, a, b, x[i + 2], 17, 606105819); b = ff(b, c, d, a, x[i + 3], 22, -1044525330); a = ff(a, b, c, d, x[i + 4], 7, -176418897); d = ff(d, a, b, c, x[i + 5], 12, 1200080426); c = ff(c, d, a, b, x[i + 6], 17, -1473231341); b = ff(b, c, d, a, x[i + 7], 22, -45705983); a = ff(a, b, c, d, x[i + 8], 7, 1770035416); d = ff(d, a, b, c, x[i + 9], 12, -1958414417); c = ff(c, d, a, b, x[i + 10], 17, -42063); b = ff(b, c, d, a, x[i + 11], 22, -1990404162); a = ff(a, b, c, d, x[i + 12], 7, 1804603682); d = ff(d, a, b, c, x[i + 13], 12, -40341101); c = ff(c, d, a, b, x[i + 14], 17, -1502002290); b = ff(b, c, d, a, x[i + 15], 22, 1236535329); a = gg(a, b, c, d, x[i + 1], 5, -165796510); d = gg(d, a, b, c, x[i + 6], 9, -1069501632); c = gg(c, d, a, b, x[i + 11], 14, 643717713); b = gg(b, c, d, a, x[i + 0], 20, -373897302); a = gg(a, b, c, d, x[i + 5], 5, -701558691); d = gg(d, a, b, c, x[i + 10], 9, 38016083); c = gg(c, d, a, b, x[i + 15], 14, -660478335); b = gg(b, c, d, a, x[i + 4], 20, -405537848); a = gg(a, b, c, d, x[i + 9], 5, 568446438); d = gg(d, a, b, c, x[i + 14], 9, -1019803690); c = gg(c, d, a, b, x[i + 3], 14, -187363961); b = gg(b, c, d, a, x[i + 8], 20, 1163531501); a = gg(a, b, c, d, x[i + 13], 5, -1444681467); d = gg(d, a, b, c, x[i + 2], 9, -51403784); c = gg(c, d, a, b, x[i + 7], 14, 1735328473); b = gg(b, c, d, a, x[i + 12], 20, -1926607734); a = hh(a, b, c, d, x[i + 5], 4, -378558); d = hh(d, a, b, c, x[i + 8], 11, -2022574463); c = hh(c, d, a, b, x[i + 11], 16, 1839030562); b = hh(b, c, d, a, x[i + 14], 23, -35309556); a = hh(a, b, c, d, x[i + 1], 4, -1530992060); d = hh(d, a, b, c, x[i + 4], 11, 1272893353); c = hh(c, d, a, b, x[i + 7], 16, -155497632); b = hh(b, c, d, a, x[i + 10], 23, -1094730640); a = hh(a, b, c, d, x[i + 13], 4, 681279174); d = hh(d, a, b, c, x[i + 0], 11, -358537222); c = hh(c, d, a, b, x[i + 3], 16, -722521979); b = hh(b, c, d, a, x[i + 6], 23, 76029189); a = hh(a, b, c, d, x[i + 9], 4, -640364487); d = hh(d, a, b, c, x[i + 12], 11, -421815835); c = hh(c, d, a, b, x[i + 15], 16, 530742520); b = hh(b, c, d, a, x[i + 2], 23, -995338651); a = ii(a, b, c, d, x[i + 0], 6, -198630844); d = ii(d, a, b, c, x[i + 7], 10, 1126891415); c = ii(c, d, a, b, x[i + 14], 15, -1416354905); b = ii(b, c, d, a, x[i + 5], 21, -57434055); a = ii(a, b, c, d, x[i + 12], 6, 1700485571); d = ii(d, a, b, c, x[i + 3], 10, -1894986606); c = ii(c, d, a, b, x[i + 10], 15, -1051523); b = ii(b, c, d, a, x[i + 1], 21, -2054922799); a = ii(a, b, c, d, x[i + 8], 6, 1873313359); d = ii(d, a, b, c, x[i + 15], 10, -30611744); c = ii(c, d, a, b, x[i + 6], 15, -1560198380); b = ii(b, c, d, a, x[i + 13], 21, 1309151649); a = ii(a, b, c, d, x[i + 4], 6, -145523070); d = ii(d, a, b, c, x[i + 11], 10, -1120210379); c = ii(c, d, a, b, x[i + 2], 15, 718787259); b = ii(b, c, d, a, x[i + 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return [a, b, c, d]; } function binl2hex(binarray) { var hex_tab = "0123456789abcdef"; var str = ""; for (var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) + hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF); } return str; } function str2binl(str) { var nblk = ((str.length + 8) >> 6) + 1; var blks = new Array(nblk * 16); for (var i = 0; i < nblk * 16; i++) blks[i] = 0; for (var i = 0; i < str.length; i++) blks[i >> 2] |= (str.charCodeAt(i) & 0xFF) << ((i % 4) * 8); blks[i >> 2] |= 0x80 << ((i % 4) * 8); blks[nblk * 16 - 2] = str.length * 8; return blks; } function md5(str) { return binl2hex(coreMD5(str2binl(str))); } class PlatfromContro { static init() { this.layer(); Task.init(); WXContro.init(this._layer); } static layer() { this._layer = new Laya.Box(); this._layer.width = Consts.width; this._layer.height = Consts.height; this._layer.mouseThrough = true; this._layer.addComponent(Laya.Widget); let widget = this._layer.getComponent(Laya.Widget); widget.centerX = 0; widget.centerY = 0; this._layer.zOrder = 999; Laya.stage.addChild(this._layer); } static init_rank() { let wx = window["wx"]; if (wx) { RankDlg.init(this._layer); } } static init_banner() { BannerAd.init(this._layer); FlowIconMgr.init({ x: 620, y: 200, layer: this._layer }, FlowIconMgr.TYPE_V); } static reset_feedbackBt_pos(x, y) { if (this.feedbackButton) { let pos = WXContro.laya_to_wx_pos(x, y); console.log(pos); this.feedbackButton.style.top = pos.y; this.feedbackButton.style.left = pos.x; } } static show_feedbackButton() { this.feedbackButton.show(); } static hide_feedbackButton() { this.feedbackButton.hide(); } static reset_FlowIconMgr_pos(x, y) { FlowIconMgr.reset_FlowIconMgr_pos(x, y); } static init_http_call(call) { EventHandler.getInstance().addEvent("http_server_data", this, () => { if (call) { call(); } }); } static hideBanner() { BannerAd.hideBannerAd(); } static displayBanner() { BannerAd.showBannerAd(); } } PlatfromContro._layer = null; PlatfromContro.feedbackButton = null; class WebView { static initGame() { uni.postMessage({ data: { funName: "gameInit", gameData: {} } }); } static uploadInfo(gameScore, gameTime, calorieBurned) { uni.postMessage({ data: { funName: "uploadInfo", gameData: { gameScore: gameScore, gameTime: gameTime, calorieBurned: calorieBurned } } }); } static getAiInfo() { uni.postMessage({ data: { funName: "aiRandomInfo", gameData: {} } }); } static getFruitInfo(calorie) { uni.postMessage({ data: { funName: "fruitInfo", gameData: { calorie: calorie } } }); } static onBindBoxingPost() { uni.postMessage({ data: { funName: "bindHitBoxingPost", gameData: {} } }); } static closeGame() { uni.postMessage({ data: { funName: "closeGame", gameData: {} } }); } static onAddQuitModalListener() { uni.postMessage({ data: { funName: "addQuitModal", gameData: {} } }); } } WebView.EVENT = { onGameInit: "onGameInit", onUploadInfo: "onUploadInfo", onAiRandomInfo: "onAiRandomInfo", onFruitInfo: "onFruitInfo", onDeviceUpdateData: "onDeviceUpdateData", onDeviceState: "onDeviceState", onDeviceClose: "onDeviceClose", onBoxingPostHit: "onBoxingPostHit", onQuit: "onQuit", onQuitModal: "onQuitModal" }; window.onWebViewMessage = (data) => { console.log("onWebViewMessage-->", data); EventHandler.getInstance().Emit(data.funName, data.gameData); }; class APPControl { constructor() { this.hitCD = 0; } static getInstance() { if (this._instance == null) { this._instance = new APPControl(); } return this._instance; } init() { EventHandler.getInstance().addEvent(WebView.EVENT.onGameInit, this, this.onInitGame); EventHandler.getInstance().addEvent(WebView.EVENT.onAiRandomInfo, this, this.onGetAiInfo); EventHandler.getInstance().addEvent(WebView.EVENT.onBoxingPostHit, this, this.onBoxingPostHit); EventHandler.getInstance().addEvent(WebView.EVENT.onDeviceUpdateData, this, this.onDeviceUpdateData); EventHandler.getInstance().addEvent(WebView.EVENT.onQuitModal, this, this.onQuitModal); WebView.initGame(); WebView.onAddQuitModalListener(); WebView.onBindBoxingPost(); } initGame() { console.log("initGame"); } getAiInfo() { console.log("getAiInfo"); } onInitGame(gameData) { console.log("onInitGame", gameData); } onGetAiInfo(gameData) { console.log("onGetAiInfo", gameData); } onGetFruitInfo(gameData) { console.log("onGetFruitInfo", gameData); } onDeviceUpdateData(gameData) { console.log("onDeviceUpdateData", gameData); } onBoxingPostHit(gameData) { console.log("打击cd时间", this.hitCD); if (this.hitCD != 0) return; this.hitCD = 1; Laya.timer.once(100, this, function () { this.hitCD = 0; }); console.log("onBoxingPostHit", gameData); let state = MainScene.instance.gameState; switch (state) { case 1: MainScene.instance.onStartGameClick(); break; case 2: MainScene.gameControl.onGameStageClick(); break; default: break; } } onQuitModal(gameData) { if (gameData.data.confirm) { WebView.closeGame(); } console.log("onQuitModal", gameData); } } APPControl._instance = null; class MainScene extends ui.MainSceneUI { constructor() { super(); this.gameState = 1; this.tag_knifeSystem = 0; this.tag_critSystem = 0; this.tag_coinSystem = 0; MainScene.instance = this; Laya.stage.scaleMode = Laya.Stage.SCALE_FIXED_WIDTH; this.SceneBox.pivotY = this.SceneBox.height / 2; this.SceneBox.y = Laya.stage.height / 2; PlatfromContro.init(); Laya.stage.on(Laya.Event.MOUSE_MOVE, this, function () { this.mousePos.text = Laya.stage.mouseX + "," + Laya.stage.mouseY; }); APPControl.getInstance().init(); } onEnable() { this.init(); this.btn_startGame.on(Laya.Event.MOUSE_DOWN, this, this.onStartGameClick); this.btn_knifeSystem.on(Laya.Event.MOUSE_DOWN, this, this.onKnifeSystemClick); this.btn_critSystem.on(Laya.Event.MOUSE_DOWN, this, this.onCritSystemClick); this.btn_coinSystem.on(Laya.Event.MOUSE_DOWN, this, this.onCoinSystemClick); this.btn_knifeUpgradeNumNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onKnifeUpgradeNumNeedCoinsClick); this.btn_knifeUpgradeAttackNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onKnifeUpgradeAttackNeedCoinsClick); this.btn_critUpgradeAttackNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onCritUpgradeAttackNeedCoinsClick); this.btn_critUpgradeChanceNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onCritUpgradeChanceNeedCoinsClick); this.btn_coinUpgradeValueNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onCoinUpgradeValueNeedCoinsClick); this.btn_coinUpgradeProfitNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onCoinUpgradeProfitNeedCoinsClick); this.btn_addCoin.on(Laya.Event.MOUSE_DOWN, this, this.onAddCoinClick); this.btn_addStrength.on(Laya.Event.MOUSE_DOWN, this, this.onAddStrengthClick); this.coinProfit.on(Laya.Event.MOUSE_DOWN, this, this.onCoinProfitClick); this.dialog_getStrength.btn_nextTime.on(Laya.Event.MOUSE_DOWN, this, this.onDialogGetStrength_NextTimeClick); this.dialog_getStrength.btn_getStrength.on(Laya.Event.MOUSE_DOWN, this, this.onDialogGetStrength_GetStrengthClick); this.dialog_receiveCoinProfit.touchArea.on(Laya.Event.MOUSE_DOWN, this, this.onDialogReceiveCoinProfit_TouchAreaClick); this.dialog_receiveCoinProfit.btn_clickReceive.on(Laya.Event.MOUSE_DOWN, this, this.onDialogReceiveCoinProfit_ReceiveClick); this.dialog_receiveCoinProfit.btn_threeTimesReceive.on(Laya.Event.MOUSE_DOWN, this, this.onDialogReceiveCoinProfit_ThreeTimesReceiveClick); this.dialog_speedUpCoinProfit.btn_threeTimesFaster.on(Laya.Event.MOUSE_DOWN, this, this.onDialogSpeedUpCoinProfit_ThreeTimesFasterClick); this.dialog_speedUpCoinProfit.btn_nextTime.on(Laya.Event.MOUSE_DOWN, this, this.onDialogSpeedUpCoinProfit_NextTimeClick); this.dialog_unlockPlanet.btn_OK.on(Laya.Event.MOUSE_DOWN, this, this.onDialog_UnloackPlanet_OKClick); this.btn_rank.on(Laya.Event.MOUSE_DOWN, this, this.onRankClick); let ahitArea = new Laya.HitArea(); let agraphics = new Laya.Graphics(); agraphics.drawRect(-10, -10, this.dialog_getStrength.btn_nextTime.width + 20, this.dialog_getStrength.btn_nextTime.height + 20, "#ff9900"); ahitArea.hit = agraphics; this.dialog_getStrength.btn_nextTime.hitArea = ahitArea; let ahitArea2 = new Laya.HitArea(); let agraphics2 = new Laya.Graphics(); agraphics2.drawRect(-10, -10, this.dialog_speedUpCoinProfit.btn_nextTime.width + 20, this.dialog_speedUpCoinProfit.btn_nextTime.height + 20, "#ff9900"); ahitArea2.hit = agraphics2; this.dialog_speedUpCoinProfit.btn_nextTime.hitArea = ahitArea2; this.prop_rocket.visible = false; this.prop_slowDown.visible = false; this.prop_subBlood.visible = false; this.btn_testPrint.visible = false; this.btn_addStrength.visible = false; this.btn_addCoin.visible = false; this.strengthSPUnderStartGame.visible = false; let jumpPoint = this.btn_startGame.localToGlobal(new Laya.Point()); this.jumpAni = AnimationControl.playJump(jumpPoint.x, jumpPoint.y); this.jumpAni.visible = false; this.jumpAni.zOrder = 5000; this.showHomeUI(); this.btn_returnHome.x -= 10; this.btn_returnHome.y += 10; this.btn_returnHome.on(Laya.Event.MOUSE_DOWN, this, this.returnHome); } init() { MusicControl.playBGMusic(); let performanceTag = false; this.btn_showPerformance.on(Laya.Event.MOUSE_DOWN, this, function () { if (performanceTag) { Laya.Stat.hide(); performanceTag = false; } else { Laya.Stat.show(0, 100); performanceTag = true; } }); this.gameOverUI = new GameOverPage(); this.showBG(); this.closeMask(); this.dialog_speedUpCoinProfit = new ui.Dialogs.Dialog_SpeedUpCoinProfitUI(); this.dialog_getStrength = new ui.Dialogs.Dialog_GetStrengthUI(); this.dialog_receiveCoinProfit = new ui.Dialogs.Dialog_ReceiveCoinProfitUI(); this.dialog_freelyGetProp = new FreelyGetPropPage(); this.dialog_unlockPlanet = new ui.Dialogs.Dialog_UnlockPlanetUI(); this.touchArea.on(Laya.Event.MOUSE_DOWN, this, this.onTouchAreaClick); this.text_addBloodNum.alpha = 0; this.tipBox.visible = false; this.tipBoxMask.blendMode = "destination-out"; this.tipMaskSprite.cacheAs = "bitmap"; this.tipBoxMask.width = this.btn_knifeSystem.width; this.tipBoxMask.height = this.btn_knifeSystem.height; this.tipBoxMask.pivot(this.tipBoxMask.width / 2, this.tipBoxMask.height / 2); } updateGameState(gameState) { this.gameState = gameState; let jumpPoint; switch (gameState) { case 1: jumpPoint = this.btn_startGame.localToGlobal(new Laya.Point()); this.jumpAni.pos(jumpPoint.x + 200, jumpPoint.y - 80); this.jumpAni.visible = true; break; case 5: jumpPoint = this.dialog_unlockPlanet.btn_OK.localToGlobal(new Laya.Point()); this.jumpAni.pos(jumpPoint.x, jumpPoint.y); this.jumpAni.visible = true; default: this.jumpAni.visible = false; break; } } onTouchAreaClick() { this.closeKnifeSystemUI(); this.closeCritSystemUI(); this.closeCoinSystemUI(); } showMask() { MainScene.instance.maskBox.visible = true; } closeMask() { MainScene.instance.maskBox.visible = false; } showBG() { let bgArr = []; let minY = -1000; let totalHeight = 0; let maxY = 0; for (let i = 0; i < 5; i++) { let url = "texture/BG/BG" + (i + 1) + ".jpg"; let bgSprite = new Laya.Sprite(); bgSprite.loadImage(url, Laya.Handler.create(this, () => { this.bg.addChild(bgSprite); totalHeight += bgSprite.height; let posY = minY + i * 1000; bgSprite.y = posY; bgArr.push(bgSprite); if (i == 4) { let starsBrighter = this.starsBrighter; let stars = new Laya.Sprite(); stars.loadImage("texture/BG/BG_stars.png"); this.starsBrighter.addChild(stars); let starsAni_hide = function () { Laya.Tween.to(stars, { alpha: 0.1 }, 2000, Laya.Ease.linearIn, Laya.Handler.create(this, starsAni_display)); Laya.Tween.to(starsBrighter, { alpha: 1 }, 500); }; let starsAni_display = function () { Laya.Tween.to(stars, { alpha: 1 }, 1000, Laya.Ease.linearIn, Laya.Handler.create(this, starsAni_hide)); Laya.Tween.to(starsBrighter, { alpha: 0.3 }, 1000); }; starsAni_hide(); let halation = new Laya.Sprite(); halation.loadImage("texture/BG/BG_halation.png"); this.bgBox.addChild(halation); let BG_planet1 = new Laya.Sprite(); BG_planet1.loadImage("texture/BG/BG_planet1.png"); this.bgBox.addChild(BG_planet1); BG_planet1.pos(0, 344); let planet1Ani_moveUp = function () { Laya.Tween.to(BG_planet1, { y: BG_planet1.y + 50 }, 10000, Laya.Ease.linearIn, Laya.Handler.create(this, planet1Ani_moveDown)); }; let planet1Ani_moveDown = function () { Laya.Tween.to(BG_planet1, { y: BG_planet1.y - 50 }, 10000, Laya.Ease.linearIn, Laya.Handler.create(this, planet1Ani_moveUp)); }; planet1Ani_moveUp(); let BG_planet2 = new Laya.Sprite(); BG_planet2.loadImage("texture/BG/BG_planet2.png"); this.bgBox.addChild(BG_planet2); BG_planet2.pos(618, 484); let planet2Ani_moveUp = function () { Laya.Tween.to(BG_planet2, { y: BG_planet2.y + 50 }, 10000, Laya.Ease.linearIn, Laya.Handler.create(this, planet2Ani_moveDown)); }; let planet2Ani_moveDown = function () { Laya.Tween.to(BG_planet2, { y: BG_planet2.y - 50 }, 10000, Laya.Ease.linearIn, Laya.Handler.create(this, planet2Ani_moveUp)); }; planet2Ani_moveUp(); maxY = bgSprite.y + bgSprite.height; Laya.timer.frameLoop(1, this, function () { for (let i = 0; i < bgArr.length; i++) { let speed = 2; bgArr[i].y += speed; if (bgArr[i].y >= maxY) { bgArr[i].y = -1000 + speed; } } }); } })); } } onStartGameClick() { MainScene.gameControl.levelStart(); } onKnifeSystemClick() { if (MainScene.gameControl.getMaxLevel() == 0) return; if (this.tag_knifeSystem == 0) { this.showKnifeSystemUI(); } else { this.closeKnifeSystemUI(); } } onCritSystemClick() { if (this.tag_critSystem == 0) { this.showCritSystemUI(); } else { this.closeCritSystemUI(); } } onCoinSystemClick() { if (this.tag_coinSystem == 0) { this.showCoinSystemUI(); } else { this.closeCoinSystemUI(); } } onKnifeUpgradeNumNeedCoinsClick() { MainScene.gameControl.upGradeKnifeNum(); } onKnifeUpgradeAttackNeedCoinsClick() { MainScene.gameControl.upGradeKnifeAttack(); } onCritUpgradeAttackNeedCoinsClick() { MainScene.gameControl.upGradeCritAttack(); } onCritUpgradeChanceNeedCoinsClick() { MainScene.gameControl.upGradeCritChance(); } onCoinUpgradeValueNeedCoinsClick() { MainScene.gameControl.upGradeCoinValue(); } onCoinUpgradeProfitNeedCoinsClick() { MainScene.gameControl.upGradeCoinProfit(); } onAddCoinClick() { if (MainScene.gameControl.maxLevel < 5) { let text = new Laya.Text(); text.text = "金币收益还未解锁"; this.text_holdCoinsNum.addChild(text); text.pos(220, text.height / 2); text.fontSize = 28; text.color = "#ffffff"; Laya.timer.once(1000, this, function () { text.destroy(); }); } else { this.dialog_speedUpCoinProfit.show(); } } onAddStrengthClick() { this.dialog_getStrength.show(); } onCoinProfitClick() { this.dialog_receiveCoinProfit.show(); let coinStr = MathTool.currencyUnit(this.coinDailyIncomeControl.availableIncome); this.dialog_receiveCoinProfit.text_btn_clickReceive.text = coinStr; let coinStr3 = MathTool.currencyUnit(this.coinDailyIncomeControl.availableIncome * 3); this.dialog_receiveCoinProfit.text_btn_threeTimesReceive.text = coinStr3; } onRankClick() { RankDlg.show(RANK_TYPE.LIST, MainScene.gameControl.maxLevel); } onRocketClick() { MainScene.gameControl.onRocketClick(); } onSlowDownClick() { MainScene.gameControl.onSlowDownClick(); } onSubBloodClick() { MainScene.gameControl.onSubBloodClick(); } onDialogGetStrength_NextTimeClick() { Func.sharePointCount("getStrength-close", 101); this.dialog_getStrength.close(); } onDialogGetStrength_GetStrengthClick() { Func.sharePoint("getStrength", false, this.onShare_getStrength); Func.sharePointCount("getStrength-open", 101); } onShare_getStrength() { MainScene.gameControl.recoverEnergies(30, 1); MainScene.instance.dialog_getStrength.close(); MainScene.gameControl.updateHomeUI(); } onDialogReceiveCoinProfit_TouchAreaClick() { this.dialog_receiveCoinProfit.close(); } onDialogReceiveCoinProfit_ReceiveClick() { if (this.coinDailyIncomeControl.availableIncome >= this.coinDailyIncomeControl.incomeAtLeast) { Func.sharePointCount("threeTimesReceiveProfit-close", 101); this.dialog_receiveCoinProfit.close(); MainScene.gameControl.receiveCoinDailyIncome(this.coinDailyIncomeControl.availableIncome); this.coinDailyIncomeControl.restartTimer_updateProfitCountDown(); this.coinIncomeProgress.value = 0; let startPoint = new Laya.Point(Laya.stage.width / 2, Laya.stage.height / 2); let iconCoin = MainScene.instance.icon_coin_homeLeftTop; let targetPoint = new Laya.Point(iconCoin.width / 2, iconCoin.height / 2); targetPoint = iconCoin.localToGlobal(targetPoint); targetPoint.x = 42; AnimationControl.playCoinsFlyAni(startPoint, targetPoint); } else { this.dialog_receiveCoinProfit.tip_receiveLater.visible = true; Laya.timer.once(2000, this, function () { this.dialog_receiveCoinProfit.tip_receiveLater.visible = false; }); } } onDialogReceiveCoinProfit_ThreeTimesReceiveClick() { if (this.coinDailyIncomeControl.availableIncome >= this.coinDailyIncomeControl.incomeAtLeast) { Func.sharePoint("threeTimesReceiveProfit", false, this.onShare_threeTimesReceive); Func.sharePointCount("threeTimesReceiveProfit-open", 101); } else { this.dialog_receiveCoinProfit.tip_receiveLater.visible = true; Laya.timer.once(2000, this, function () { this.dialog_receiveCoinProfit.tip_receiveLater.visible = false; }); } } onShare_threeTimesReceive() { let self = MainScene.instance; self.dialog_receiveCoinProfit.close(); MainScene.gameControl.receiveCoinDailyIncome(self.coinDailyIncomeControl.availableIncome * 3); self.coinDailyIncomeControl.restartTimer_updateProfitCountDown(); self.coinIncomeProgress.value = 0; let startPoint = new Laya.Point(Laya.stage.width / 2, Laya.stage.height / 2); let iconCoin = MainScene.instance.icon_coin_homeLeftTop; let targetPoint = new Laya.Point(iconCoin.width / 2, iconCoin.height / 2); targetPoint = iconCoin.localToGlobal(targetPoint); targetPoint.x = 42; AnimationControl.playCoinsFlyAni(startPoint, targetPoint); } onDialogSpeedUpCoinProfit_ThreeTimesFasterClick() { Func.sharePoint("threeTimesFasterProfit", false, this.onShare_ThreeTimesFaster); Func.sharePointCount("threeTimesFasterProfit-open", 101); } onShare_ThreeTimesFaster() { MainScene.instance.coinDailyIncomeControl.ProfitFasterCountDown = 5 * 60; MainScene.instance.coinDailyIncomeControl.threeTimesFaster(); MainScene.instance.dialog_speedUpCoinProfit.close(); MainScene.instance.coinDailyIncomeControl.saveLastFasterStartTime(); } onDialogSpeedUpCoinProfit_NextTimeClick() { Func.sharePointCount("threeTimesFasterProfit-close", 101); this.dialog_speedUpCoinProfit.close(); } onDialog_UnloackPlanet_OKClick() { this.dialog_unlockPlanet.close(); } showGameUI() { this.gameUI.visible = true; this.homeUI.visible = false; } showHomeUI() { MainScene.instance.updateGameState(1); this.gameUI.visible = false; this.homeUI.visible = true; this.leftUI.pos(0, 0); this.rightUI.pos(0, 0); this.topUI.pos(0, 0); this.bottomUI.pos(0, 150); this.btn_startGame.visible = true; this.btn_knifeSystem.skin = "texture/MainScene/TAB/btn_rocket_unchecked.png"; this.btn_critSystem.skin = "texture/MainScene/TAB/btn_crit_unchecked.png"; this.btn_coinSystem.skin = "texture/MainScene/TAB/btn_coin_unchecked.png"; } showKnifeSystemUI() { this.tag_knifeSystem = 1; this.knifeSystemUI.visible = true; this.btn_knifeSystem.skin = "texture/MainScene/TAB/btn_rocket_checked.png"; this.closeCritSystemUI(); this.closeCoinSystemUI(); } closeKnifeSystemUI() { this.tag_knifeSystem = 0; this.knifeSystemUI.visible = false; this.btn_knifeSystem.skin = "texture/MainScene/TAB/btn_rocket_unchecked.png"; } showCritSystemUI() { this.tag_critSystem = 1; if (MainScene.gameControl.maxLevel >= 10) { this.critSystemUI.visible = true; this.bubble_crit.visible = false; } else { this.critSystemUI.visible = false; this.bubble_crit.visible = true; } this.btn_critSystem.skin = "texture/MainScene/TAB/btn_crit_checked.png"; this.closeKnifeSystemUI(); this.closeCoinSystemUI(); } closeCritSystemUI() { this.tag_critSystem = 0; this.critSystemUI.visible = false; this.bubble_crit.visible = false; this.btn_critSystem.skin = "texture/MainScene/TAB/btn_crit_unchecked.png"; } showCoinSystemUI() { this.tag_coinSystem = 1; if (MainScene.gameControl.maxLevel >= 20) { this.coinSystemUI.visible = true; this.bubble_coin.visible = false; } else { this.coinSystemUI.visible = false; this.bubble_coin.visible = true; } this.btn_coinSystem.skin = "texture/MainScene/TAB/btn_coin_checked.png"; this.closeKnifeSystemUI(); this.closeCritSystemUI(); } closeCoinSystemUI() { this.tag_coinSystem = 0; this.coinSystemUI.visible = false; this.bubble_coin.visible = false; this.btn_coinSystem.skin = "texture/MainScene/TAB/btn_coin_unchecked.png"; } returnHome() { MainScene.instance.updateGameState(1); MainScene.gameControl.levelOver(); MainScene.instance.showHomeUI(); MainScene.gameControl.updateHomeUI(); MainScene.gameControl.checkNewPlayer(); MainScene.sun.sunIdle(); } } class Sun extends ui.SunUI { constructor() { super(); this.totalBlood = 100; this.curBlood = 100; this.sunRotateDirection = 1; this.sunRotateSpeed = 0; this.sunRotateSpeedInit = 0; this.sunLastTime = 0; this.shieldBlood = 0; this.innerRotateDirection = 1; this.innerRotateSpeed = 0; this.outerRotateDirection = 1; this.outerRotateSpeed = 0; this.breatheTag = 0; this.sunScaleAni = null; this.bindedRiftArr = []; this.riftInfo = [ { "rotation": 0, "pointX": 0, "pointY": 0 } ]; this.angleArr = []; Laya.loader.load("res/atlas/texture/Effect/ringEffect.atlas", Laya.Handler.create(this, () => { })); Laya.loader.load("res/atlas/texture/Effect/SunRift.atlas"); Laya.timer.once(100, this, function () { this.saveRiftInfo(); }); } levelInit() { this.riftInfo = []; this.saveRiftInfo(); this.bindedRiftArr = []; for (let i = 0; i < 6; i++) { let rift = Laya.Pool.getItemByClass("Rift", Laya.Sprite); rift.visible = false; this.bindedRiftArr.push(rift); this.RiftNode.addChild(rift); } this.breatheTag = 1; if (this.sunScaleAni) Laya.Tween.clear(this.sunScaleAni); this.sunScaleAni = Laya.Tween.to(this.sunNode, { scaleX: 1, scaleY: 1, y: 411 }, 500, Laya.Ease.linearIn, Laya.Handler.create(this, function () { this.breatheTag = 0; if (!this.ringAni) this.initRingAni(); if (!this.knifeBindPoint) { let aPoint = new Laya.Point(this.sunNode.x, this.sunNode.y + 150); this.knifeBindPoint = this.localToGlobal(aPoint); this.minSunPoint = new Laya.Point(this.sunNode.width / 2, this.sunNode.height); this.minSunPoint = this.sunNode.localToGlobal(this.minSunPoint); } if (!MainScene.gameControl.minKnifeY) { MainScene.gameControl.saveMinPointY(); } MainScene.gameControl.launchRocketTag = 0; let knife = MainScene.gameControl.createKnife(); })); Laya.Tween.to(MainScene.instance.bg, { scaleX: 1.2, scaleY: 1.2 }, 500); Laya.Tween.to(MainScene.instance.starsBrighter, { scaleX: 1.2, scaleY: 1.2 }, 500); Laya.Tween.to(MainScene.instance.bgBox, { scaleX: 1.1, scaleY: 1.1 }, 500); this.sunRotateSpeed = this.sunRotateSpeedInit = this.getConsumedTime(); this.sunAndKnifeNode.pivotX = this.sunAndKnifeNode.width / 2; this.sunAndKnifeNode.pivotY = this.sunAndKnifeNode.height / 2; this.sunLastTime = Laya.Browser.now(); Laya.timer.clear(this, this.sunRotate); Laya.timer.frameLoop(1, this, this.sunRotate); let blood = 4 * Math.pow((MainScene.gameControl.curLevel), 3) + 20 * (Math.pow(MainScene.gameControl.curLevel, 2)) + 100; this.curBlood = this.totalBlood = Math.floor(blood); this.updateUI(); this.critNode.alpha = 0; } sunIdle() { this.clearRift(); this.planetInnerRingNode.visible = false; this.planetOuterRingNode.visible = false; this.planetInnerRingNode.alpha = 0; this.planetOuterRingNode.alpha = 0; this.breatheTag = 1; if (this.sunScaleAni) Laya.Tween.clear(this.sunScaleAni); this.sunNode.scale(0.7, 0.7); this.sunNode.y = 630; this.breatheTag = 0; this.sunRotateSpeed = this.sunRotateSpeedInit = this.getConsumedTime(); this.sunAndKnifeNode.pivotX = this.sunAndKnifeNode.width / 2; this.sunAndKnifeNode.pivotY = this.sunAndKnifeNode.height / 2; this.sunLastTime = Laya.Browser.now(); Laya.timer.clear(this, this.sunRotate); Laya.timer.frameLoop(1, this, this.sunRotate); let blood = 4 * Math.pow((MainScene.gameControl.curLevel), 3) + 20 * (Math.pow(MainScene.gameControl.curLevel, 2)) + 100; this.curBlood = this.totalBlood = Math.floor(blood); this.updateUI(); this.switchEmoji(0); this.critNode.alpha = 0; PlatfromContro.displayBanner(); MainScene.instance.bg.scale(1, 1); MainScene.instance.starsBrighter.scale(1, 1); MainScene.instance.bgBox.scale(1, 1); } getConsumedTime() { let levelNum = MainScene.gameControl.curLevel; let consumedTime = 0; if (levelNum <= 10) { consumedTime = 5; } else if (levelNum >= 11 && levelNum <= 30) { consumedTime = 4.5; } else if (levelNum >= 31 && levelNum <= 50) { consumedTime = 4; } else if (levelNum >= 51 && levelNum <= 80) { consumedTime = 3.75; } else if (levelNum >= 81 && levelNum <= 110) { consumedTime = 3.5; } else if (levelNum >= 111 && levelNum <= 150) { consumedTime = 3.25; } else if (levelNum >= 151) { consumedTime = 3; } return consumedTime; } sunRotate() { let interval = Laya.Browser.now() - this.sunLastTime; this.sunAndKnifeNode.rotation += 360 / this.sunRotateSpeed / 1000 * interval * this.sunRotateDirection; if (this.sunAndKnifeNode.rotation <= -360 || this.sunAndKnifeNode.rotation >= 360) { this.sunAndKnifeNode.rotation = 0; } this.sunLastTime = Laya.Browser.now(); if (this.text_sunRotation) { this.text_sunRotation.text = Math.floor(this.sunAndKnifeNode.rotation) + ""; } } subBlood(subNum) { let leftoverNeedSubBlood = 0; if (this.shieldBlood > 0) { if (this.shieldBlood >= subNum) { this.shieldBlood -= subNum; } else { this.shieldBlood = 0; this.stopShieldAni(); leftoverNeedSubBlood = subNum - this.shieldBlood; } } else { leftoverNeedSubBlood = subNum; } if (this.curBlood > 0) { this.curBlood -= leftoverNeedSubBlood; this.curBlood = Math.ceil(this.curBlood); if (this.curBlood < 0) { this.curBlood = 0; } } this.updateUI(); this.checkBlood(); } addBlood(addNum) { if (this.curBlood + addNum > this.totalBlood) { this.curBlood = Math.ceil(this.totalBlood); } else { this.curBlood = Math.ceil(this.curBlood + addNum); } this.updateUI(); } updateUI() { let instance = MainScene.instance; let bloodBar = instance.bloodProgressBar; let bloodMask = instance.bloodBarMask; let shieldBar = instance.shieldProgressBar; let shieldMask = instance.shieldBarMask; instance.bloodBarMask.x = -(bloodMask.width * (1 - this.curBlood / this.totalBlood)); let bloodStr = MathTool.currencyUnit(this.curBlood); let text_bloodNum = MainScene.instance.text_bloodNum; text_bloodNum.text = bloodStr; text_bloodNum.pivotX = text_bloodNum.width; if (this.shieldBlood > 0) { shieldBar.visible = true; if (this.shieldBlood + this.curBlood >= this.totalBlood) { shieldBar.x = bloodBar.x + (bloodBar.width - shieldBar.width); shieldMask.x = shieldBar.width * (1 - this.shieldBlood / (this.totalBlood * 0.2)); } else { shieldBar.x = bloodBar.x + (bloodMask.x + bloodBar.width); shieldMask.x = -shieldBar.width * (1 - this.shieldBlood / (this.totalBlood * 0.2)); } } else { shieldBar.visible = false; } } checkBlood() { let percent = this.getPercentOfBlood(); if (percent < 0.2 && percent > 0) { this.switchEmoji(4); ; } if (this.curBlood > 0) { return true; } else { return false; } } addShield(shieldBlood) { this.shieldBlood = shieldBlood; this.updateUI(); } getPercentOfBlood() { let blood = this.curBlood; let totalBlood = this.totalBlood; let percent = blood / totalBlood; return percent; } switchEmoji(emojiType) { MainScene.gameControl.attackSunTime = Laya.Browser.now(); let emojiPath = ""; let sunBGPath = ""; let sunShinePath = ""; switch (emojiType) { case 0: emojiPath = "texture/Sun/biaoqing_tiaoxin.png"; sunBGPath = "texture/Sun/sunBG_normal.png"; sunShinePath = "texture/Sun/sunShine1.png"; break; case 1: emojiPath = "texture/Sun/biaoqing_baonu.png"; sunBGPath = "texture/Sun/sunBG_normal.png"; sunShinePath = "texture/Sun/sunShine1.png"; break; case 2: emojiPath = "texture/Sun/biaoqing_kuqi.png"; sunBGPath = "texture/Sun/sunBG_normal.png"; sunShinePath = "texture/Sun/sunShine1.png"; break; case 3: emojiPath = "texture/Sun/biaoqing_wuliao.png"; sunBGPath = "texture/Sun/sunBG_normal.png"; sunShinePath = "texture/Sun/sunShine1.png"; break; case 4: emojiPath = "texture/Sun/biaoqing_jingkong.png"; sunBGPath = "texture/Sun/sunBG_jingkong.png"; sunShinePath = "texture/Sun/sunShine1.png"; break; case 5: emojiPath = "texture/Sun/biaoqing_chaoxiao.png"; sunBGPath = "texture/Sun/sunBG_normal.png"; sunShinePath = "texture/Sun/sunShine1.png"; break; case 6: emojiPath = "texture/Sun/biaoqing_kaixin.png"; sunBGPath = "texture/Sun/sunBG_normal.png"; sunShinePath = "texture/Sun/sunShine1.png"; break; case 7: emojiPath = "texture/Sun/biaoqing_shuai.png"; sunBGPath = "texture/Sun/sunBG_shuai.png"; sunShinePath = "texture/Sun/sunShine2.png"; break; default: break; } this.sunEmoji.loadImage(emojiPath); this.sunShine.loadImage(sunShinePath); } saveRiftInfo() { this.riftInfo = []; this.angleArr = []; let angle2To3Arr_left = [150, 210]; let angle2To3Arr_right = [30, 330]; let angle2To3Arr = [angle2To3Arr_left, angle2To3Arr_right]; let angle4To6Arr_left = [120, 180, 240]; let angle4To6Arr_right = [0, 60, 300]; let angle4To6Arr = []; let angle1 = 90; let randomDir2 = Math.round(Math.random()); let randomIndex2 = Math.round(Math.random()); let randomIndex3 = Math.round(Math.random()); let angle2 = angle2To3Arr[randomDir2][randomIndex2]; let angle3 = angle2To3Arr[(randomDir2 + 1) % 2][randomIndex3]; angle4To6Arr_left.push(angle2To3Arr[randomDir2][(randomIndex2 + 1) % 2]); angle4To6Arr_right.push(angle2To3Arr[(randomDir2 + 1) % 2][(randomIndex3 + 1) % 2]); angle4To6Arr.push(angle4To6Arr_left, angle4To6Arr_right); let randomDir4 = Math.round(Math.random()); let randomIndex4 = Math.floor(Math.random() * 4); let angle4 = angle4To6Arr[randomDir4][randomIndex4]; let randomIndex5 = Math.floor(Math.random() * 4); let angle5 = angle4To6Arr[(randomDir4 + 1) % 2][randomIndex5]; angle4To6Arr[(randomDir4 + 1) % 2].splice(randomIndex5, 1); let randomIndex6 = Math.floor(Math.random() * 3); let angle6 = angle4To6Arr[(randomDir4 + 1) % 2][randomIndex6]; this.angleArr.push(angle1, angle2, angle3, angle4, angle5, angle6); this.riftInfo.length = this.angleArr.length; let r = MainScene.sun.sunNode.width / 2; for (let i = 0; i < this.angleArr.length; i++) { let ariftInfo = { "rotation": 0, "pointX": 0, "pointY": 0 }; let angle = this.angleArr[i]; let radian = Math.PI / 180 * angle; let pointX = Math.cos(radian) * r; let pointY = Math.sin(radian) * r; ariftInfo.pointX = pointX; ariftInfo.pointY = pointY; let rotation = angle - 90; if (rotation < 0) { rotation += 360; } ariftInfo.rotation = rotation; this.riftInfo[i] = ariftInfo; } } getRiftInfo() { let bloodPercentage = this.curBlood / this.totalBlood * 100; let ariftInfo = { "rotation": 0, "pointX": 0, "pointY": 0, "riftUrl": "", "bindRiftArrIndex": 0 }; let briftInfo; if (bloodPercentage >= 90) { return; } else if (bloodPercentage < 90 && bloodPercentage >= 80) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift01_01.png"; ariftInfo.bindRiftArrIndex = 0; briftInfo = this.riftInfo[0]; } else if (bloodPercentage > 70) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift02_01.png"; ariftInfo.bindRiftArrIndex = 1; briftInfo = this.riftInfo[1]; } else if (bloodPercentage > 60) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift03_01.png"; ariftInfo.bindRiftArrIndex = 2; briftInfo = this.riftInfo[2]; } else if (bloodPercentage > 50) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift01_02.png"; ariftInfo.bindRiftArrIndex = 0; briftInfo = this.riftInfo[0]; } else if (bloodPercentage > 45) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift04.png"; ariftInfo.bindRiftArrIndex = 3; briftInfo = this.riftInfo[3]; } else if (bloodPercentage > 40) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift03_02.png"; ariftInfo.bindRiftArrIndex = 2; briftInfo = this.riftInfo[2]; } else if (bloodPercentage > 30) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift02_02.png"; ariftInfo.bindRiftArrIndex = 1; briftInfo = this.riftInfo[1]; } else if (bloodPercentage > 20) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift05.png"; ariftInfo.bindRiftArrIndex = 4; briftInfo = this.riftInfo[4]; } else if (bloodPercentage > 15) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift01_03.png"; ariftInfo.bindRiftArrIndex = 0; briftInfo = this.riftInfo[0]; } else if (bloodPercentage > 10) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift06.png"; ariftInfo.bindRiftArrIndex = 5; briftInfo = this.riftInfo[5]; } else if (bloodPercentage > 5) { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift03_03.png"; ariftInfo.bindRiftArrIndex = 2; briftInfo = this.riftInfo[2]; } else { ariftInfo.riftUrl = "texture/Effect/SunRift/Rift02_03.png"; ariftInfo.bindRiftArrIndex = 1; briftInfo = this.riftInfo[1]; } ariftInfo.pointX = briftInfo.pointX; ariftInfo.pointY = briftInfo.pointY; ariftInfo.rotation = briftInfo.rotation; return ariftInfo; } addRift() { let ariftInfo = this.getRiftInfo(); if (!ariftInfo) return; let rift = this.bindedRiftArr[ariftInfo.bindRiftArrIndex]; rift.texture = Laya.loader.getRes(ariftInfo.riftUrl); let pivotX = rift.width / 2; let pivotY = rift.height; rift.pivotX = pivotX; rift.pivotY = pivotY; rift.pos(ariftInfo.pointX + this.RiftNode.width / 2, ariftInfo.pointY + this.RiftNode.height / 2); rift.rotation = ariftInfo.rotation; rift.visible = true; } clearRift() { for (let i = 0; i < this.bindedRiftArr.length; i++) { this.bindedRiftArr[i].removeSelf(); Laya.Pool.recover("Rift", this.bindedRiftArr[i]); } } initRingAni() { let sun = MainScene.sun; if (!sun.ringAni_addBlood) { sun.ringAni_addBlood = new Laya.Animation(); sun.ringAni_addBlood.loadAnimation("Animation/shoot_blood.ani"); sun.addChild(sun.ringAni_addBlood); sun.ringAni_addBlood.pos(sun.sunNode.x, sun.sunNode.y); sun.ringAni_addBlood.visible = false; } if (!sun.ringAni_fast) { sun.ringAni_fast = new Laya.Animation(); sun.ringAni_fast.loadAnimation("Animation/shoot_blood.ani"); sun.addChild(sun.ringAni_fast); sun.ringAni_fast.pos(sun.sunNode.x, sun.sunNode.y); sun.ringAni_fast.visible = false; } } gameover_clearAnimation() { MainScene.sun.ringAni_addBlood.visible = false; MainScene.sun.ringAni_fast.visible = false; } playRingAniFast(aniName, loop) { if (!MainScene.gameControl.isStartGame) return; this.ringAni_fast.visible = true; this.ringAni_fast.play(0, loop, aniName); } stopShieldAni() { SkeletonControl.clearSheildAni(); } } class MyConsts { } MyConsts.treeThorough = 20; MyConsts.knifeToSunCenter = 150; MyConsts.animationName = { "addBlood": "blood", "fast": "fast", }; MyConsts.imgPath = { "iconPlus": "res/atlas/texture/Effect/Planet_Mercury.png", "iconFast": "res/atlas/texture/Effect/Planet_Saturn.png", }; MyConsts.growSystemGradeLimit = { "knifeNum": 50, "knifeAttack": 500, "critChance": 150, "critAttack": 50, "coinValue": 500, "coinProfit": 999 }; class Knife extends Laya.Sprite { constructor() { super(); this.isBindSun = false; this.attack = 0; this.attackInit = 0; this.bindToSunTween = null; this.isInvincible = false; this.isBindToPlanet = false; this.textID = new Laya.Text(); this.textID.color = "#ffff00"; this.textID.fontSize = 30; this.textID.bold = true; this.textID.stroke = 2; this.textID.strokeColor = "#ffffff"; this.textID.pos(28, 150); this.textID.visible = false; this.knifeImg = new Laya.Sprite(); this.addChild(this.knifeImg); this.knifeID = Laya.Browser.now() + "" + Math.floor(Math.random() * 1000); let str = this.knifeID ? this.knifeID : "nnnnull"; str = str.substr(str.length - 5, 5); this.textID.text = str; } init() { this.isBindSun = false; this.rotation = 0; this.knifeImg.texture = Laya.loader.getRes("texture/GameScene/rocket.png"); this.attack = this.attackInit = MainScene.gameControl.knifeInfo.knifeAttack; this.isBindToPlanet = false; this.width = this.knifeImg.width; this.height = this.knifeImg.height; this.addChild(this.textID); this.knifeImg.alpha = 1; this.knifeImg.pos(0, 0); this.alpha = 1; } knifeBindToSun() { if (this.isBindSun == false) { let gameControl = MainScene.gameControl; let num1 = 0; let tp = new Laya.Point(MainScene.sun.sunNode.x, MainScene.sun.sunNode.y + MyConsts.knifeToSunCenter); tp = MainScene.sun.localToGlobal(tp); tp = MainScene.instance.KnifeBox.globalToLocal(tp); this.bindToSunTween = Laya.Tween.to(this, { y: tp.y - num1 }, 50, Laya.Ease.linearIn, Laya.Handler.create(this, function () { this.isBindSun = true; let par = this.parent ? this.parent.name : "noParent"; if (this.isBindToPlanet) { this.stopTweenToSun(this); return; } MusicControl.knifeAttackSun(); let bcollision = false; bcollision = this.checkCollision_knife(this); if (bcollision) return; bcollision = this.checkCollision_tree(this); if (bcollision) return; let knifeP = new Laya.Point(this.x, this.y); knifeP = MainScene.instance.KnifeBox.localToGlobal(knifeP); knifeP = MainScene.sun.knifeNode.globalToLocal(knifeP); MainScene.sun.knifeNode.addChild(this); this.pos(knifeP.x, knifeP.y); this.rotation = -MainScene.sun.sunAndKnifeNode.rotation; let effectPoint = MainScene.sun.minSunPoint; if (MainScene.sun.shieldBlood <= 0) { AnimationControl.sunLiquidAni(this, Laya.stage, effectPoint.x, effectPoint.y); } gameControl.curKnifeArrivedSun(this); let percent = MainScene.sun.getPercentOfBlood(); if (gameControl.isStartGame) { if (percent > 0.5) { MainScene.sun.switchEmoji(1); } else if (percent > 0.2) { MainScene.sun.switchEmoji(2); } else if (percent > 0) { MainScene.sun.switchEmoji(4); } gameControl.attackSunTime = Laya.Browser.now(); } if (this.fireAni) { this.fireAni.visible = false; } if (this.isInvincible) { AnimationControl.screenShake(3); } else { AnimationControl.screenShake(1); } let par2 = this.parent ? this.parent.name : "noParent"; })); Laya.timer.loop(1, this, this.checkCollision_outerPlanet, [this]); Laya.timer.loop(1, this, this.checkCollision_innerPlanet, [this]); Laya.timer.loop(1, this, this.checkCollision_knife, [this]); Laya.timer.loop(1, this, this.checkCollision_tree, [this]); } } stopTweenToSun(knife) { Laya.Tween.clear(knife.bindToSunTween); } playKnifeBounceAni() { Laya.Tween.to(this, { x: 1000, y: 1500, rotation: 360 }, 200); } updateTexture() { let imgPath = ""; if (this.isInvincible) { imgPath = "texture/GameScene/invincibleRocket.png"; } else { imgPath = "texture/GameScene/rocket.png"; } this.knifeImg.loadImage(imgPath); this.width = this.knifeImg.width; this.height = this.knifeImg.height; this.pivotX = this.width / 2; if (this.fireAni) { let posX = this.width / 2 - 5; let posY = this.height - 8; this.fireAni.pos(posX, posY); } } checkCollision_knife(curKnife) { let gameControl = MainScene.gameControl; if (!gameControl.isStartGame) { this.clearCheckCollision(); this.removeSelf(); Laya.Pool.recover("Knife", this); return; } let sun = MainScene.sun.sunAndKnifeNode; if (curKnife.y > gameControl.minKnifeY) return; if (gameControl.bindToSunKnifeArr.length < 1) return; for (let i = 0; i < gameControl.bindToSunKnifeArr.length; i++) { let targetCheckKnife = gameControl.bindToSunKnifeArr[i]; let targetKnifeRotation = (sun.rotation + targetCheckKnife.rotation) % 360; let collisionAngle = 10; if ((targetKnifeRotation >= -collisionAngle && targetKnifeRotation <= collisionAngle) || (targetKnifeRotation >= (360 - collisionAngle)) || (targetKnifeRotation <= -360 + collisionAngle)) { if (curKnife.isInvincible) { return; } else { MusicControl.hitObstacle(); this.clearCheckCollision(); curKnife.stopTweenToSun(curKnife); curKnife.playKnifeBounceAni(); let type = 0; if (targetCheckKnife.isInvincible) type = 1; gameControl.stopGame(); AnimationControl.knifeABumpedObjB(targetCheckKnife, type, function () { MainScene.gameControl.levelFailed(); MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭与太阳上的火箭发生了碰撞"; }); return true; } } } } checkCollision_tree(curKnife) { let gameControl = MainScene.gameControl; if (!gameControl.isStartGame) { this.clearCheckCollision(); this.removeSelf(); Laya.Pool.recover("Knife", this); return; } let sun = MainScene.sun.sunAndKnifeNode; if (curKnife.y > gameControl.minKnifeY) return; if (gameControl.bindToSunTreeArr.length < 1) return; for (let i = 0; i < gameControl.bindToSunTreeArr.length; i++) { let targetCheckTree = gameControl.bindToSunTreeArr[i]; let targetTreeRotation = (sun.rotation + targetCheckTree.rotation) % 360; let collisionAngle = 10; if ((targetTreeRotation >= -collisionAngle && targetTreeRotation <= collisionAngle) || (targetTreeRotation <= 360 && targetTreeRotation >= (360 - collisionAngle)) || (targetTreeRotation <= (-360 + collisionAngle) && targetTreeRotation >= -360)) { if (curKnife.isInvincible) { targetCheckTree.removeSelf(); Laya.Pool.recover("Tree", targetCheckTree); MainScene.gameControl.bindToSunTreeArr.splice(i, 1); return; } else { MusicControl.hitObstacle(); this.clearCheckCollision(); if (MainScene.sun.sunRotateDirection == -1) { } curKnife.stopTweenToSun(curKnife); curKnife.playKnifeBounceAni(); gameControl.stopGame(); AnimationControl.knifeABumpedObjB(targetCheckTree, 2, function () { MainScene.gameControl.levelFailed(); MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭与太阳上的禁牌发生了碰撞"; }); return true; } } } } checkCollision_innerPlanet(curKnife) { let gameControl = MainScene.gameControl; if (!MainScene.gameControl.isStartGame) { this.clearCheckCollision(); this.removeSelf(); Laya.Pool.recover("Knife", this); return; } if (curKnife.y > gameControl.minInnerY) return; if (gameControl.innerPlanets.length < 1) return; for (let i = 0; i < gameControl.innerPlanets.length; i++) { let targetCheckPlanet = gameControl.innerPlanets[i]; let targetPlanetRotation = targetCheckPlanet.angle; if ((targetPlanetRotation >= 80 && targetPlanetRotation <= 100) || (targetPlanetRotation >= -280 && targetPlanetRotation <= -260)) { this.clearCheckCollision(); let r = 60; let global_planetPoint = targetCheckPlanet.localToGlobal(new Laya.Point(0, 0)); let x_D_value = Laya.stage.width / 2 - global_planetPoint.x; let x_D_abs = Math.abs(x_D_value); let riftPos = [Laya.stage.width / 2, 0]; if (x_D_abs == 0) { riftPos[1] = gameControl.minInnerY; } else { let y_pow_2 = Math.pow(r, 2) - Math.pow(x_D_abs, 2); let y = Math.sqrt(y_pow_2); riftPos[1] = global_planetPoint.y + y; if (targetCheckPlanet.planetType == 4) { riftPos[0] += 5; riftPos[1] -= 10; } } let riftPoint = targetCheckPlanet.planetImg.globalToLocal(new Laya.Point(riftPos[0], riftPos[1])); let sinA = x_D_value / r; let radianA = Math.asin(sinA); let angleA = radianA * (180 / Math.PI); curKnife.isBindToPlanet = true; curKnife.stopTweenToSun(curKnife); targetCheckPlanet.planetImg.addChild(curKnife); curKnife.pos(riftPoint.x, riftPoint.y); curKnife.rotation = -targetCheckPlanet.planetImg.rotation; Laya.Tween.to(curKnife.knifeImg, { alpha: 0 }, 500); Laya.timer.once(500, gameControl, function () { curKnife.alpha = 0; curKnife.removeSelf(); Laya.Pool.recover("Knife", curKnife); }, [curKnife]); if (curKnife.fireAni) { curKnife.fireAni.visible = false; } curKnife.knifeImg.y -= 20; if (gameControl.knifeRestNum > 0 || gameControl.propInvincibleRocketNum > 0) { } else { gameControl.levelFailed(); MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭已用完"; } targetCheckPlanet.onPlanetHit(); let pos = [0, -43]; let knifeAttack = gameControl.checkKnifeCrit(curKnife, targetCheckPlanet.planetNode, pos, 0.5); targetCheckPlanet.subBlood(knifeAttack); let isAlive = targetCheckPlanet.checkBlood(); if (!isAlive) { let fun = function () { targetCheckPlanet.removeSelf(); Laya.Pool.recover("Planet", targetCheckPlanet); Laya.timer.clear(targetCheckPlanet, targetCheckPlanet.rotate); }; MainScene.gameControl.innerPlanets.splice(i, 1); targetCheckPlanet.die(fun, 0); let addCoinNum = 1.5 * 2 * (Math.pow(MainScene.gameControl.curLevel, 2) + 2 * MainScene.gameControl.curLevel + MainScene.gameControl.coinInfo.coinValue); MainScene.gameControl.coinNumFromCurLevel += Math.floor(addCoinNum); MainScene.gameControl.updateGameUI(); } return; } } } checkCollision_outerPlanet(curKnife) { let gameControl = MainScene.gameControl; if (!gameControl.isStartGame) { this.clearCheckCollision(); this.removeSelf(); Laya.Pool.recover("Knife", this); return; } let targetOuterPlanetMinY = MainScene.sun.sunNode.y + MainScene.sun.planetOuterRing.height / 2 + 43; if (curKnife.y > gameControl.minOuterY) return; if (gameControl.outerPlanets.length < 1) return; for (let i = 0; i < gameControl.outerPlanets.length; i++) { let targetCheckPlanet = gameControl.outerPlanets[i]; let targetPlanetRotation = targetCheckPlanet.angle; if ((targetPlanetRotation >= 80 && targetPlanetRotation <= 100) || (targetPlanetRotation >= -280 && targetPlanetRotation <= -260)) { this.clearCheckCollision(); let r = 60; let global_planetPoint = targetCheckPlanet.localToGlobal(new Laya.Point(0, 0)); let x_D_value = Laya.stage.width / 2 - global_planetPoint.x; let x_D_abs = Math.abs(x_D_value); let riftPos = [Laya.stage.width / 2, 0]; if (x_D_abs == 0) { riftPos[1] = gameControl.minInnerY; } else { let y_pow_2 = Math.pow(r, 2) - Math.pow(x_D_abs, 2); let y = Math.sqrt(y_pow_2); riftPos[1] = global_planetPoint.y + y; if (targetCheckPlanet.planetType == 4) { riftPos[0] += 5; riftPos[1] -= 10; } } let riftPoint = targetCheckPlanet.planetImg.globalToLocal(new Laya.Point(riftPos[0], riftPos[1])); let sinA = x_D_value / r; let radianA = Math.asin(sinA); let angleA = radianA * (180 / Math.PI); curKnife.isBindToPlanet = true; curKnife.stopTweenToSun(curKnife); targetCheckPlanet.planetImg.addChild(curKnife); curKnife.pos(riftPoint.x, riftPoint.y); curKnife.rotation = -targetCheckPlanet.planetImg.rotation; Laya.Tween.to(curKnife.knifeImg, { alpha: 0 }, 500); Laya.timer.once(500, gameControl, function () { curKnife.alpha = 0; curKnife.removeSelf(); Laya.Pool.recover("Knife", curKnife); }, [curKnife]); if (curKnife.fireAni) { curKnife.fireAni.visible = false; } curKnife.knifeImg.y -= 20; if (gameControl.knifeRestNum > 0 || gameControl.propInvincibleRocketNum > 0) { } else { gameControl.levelFailed(); MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭已用完"; } targetCheckPlanet.onPlanetHit(); let pos = [0, -43]; let knifeAttack = gameControl.checkKnifeCrit(curKnife, targetCheckPlanet.planetNode, pos, 0.5); targetCheckPlanet.subBlood(knifeAttack); let isAlive = targetCheckPlanet.checkBlood(); if (!isAlive) { let fun = function () { targetCheckPlanet.removeSelf(); Laya.Pool.recover("Planet", targetCheckPlanet); Laya.timer.clear(targetCheckPlanet, targetCheckPlanet.rotate); }; MainScene.gameControl.outerPlanets.splice(i, 1); targetCheckPlanet.die(fun, 0); let addCoinNum = 1.5 * 2 * (Math.pow(MainScene.gameControl.curLevel, 2) + 2 * MainScene.gameControl.curLevel + MainScene.gameControl.coinInfo.coinValue); MainScene.gameControl.coinNumFromCurLevel += Math.floor(addCoinNum); MainScene.gameControl.updateGameUI(); } return; } } } clearCheckCollision() { Laya.timer.clear(this, this.checkCollision_innerPlanet); Laya.timer.clear(this, this.checkCollision_outerPlanet); Laya.timer.clear(this, this.checkCollision_knife); Laya.timer.clear(this, this.checkCollision_tree); } } class Tree extends Laya.Sprite { constructor() { super(); this.init(); } init() { this.rotation = 0; this.texture = Laya.loader.getRes("texture/GameScene/obstacle.png"); this.width = this.texture.width; this.height = this.texture.height; this.pivotX = this.width / 2; this.x = 0; this.y = 0; this.textID_tree = new Laya.Text(); this.textID_tree.color = "#FF0000"; this.textID_tree.fontSize = 30; this.textID_tree.bold = true; this.textID_tree.stroke = 2; this.textID_tree.strokeColor = "#ffffff"; this.textID_tree.pos(this.width / 2, this.height / 2); this.addChild(this.textID_tree); this.textID_tree.visible = false; } } class MyDispatcher { constructor() { } } MyDispatcher.eventDispatcher = new Laya.EventDispatcher(); MyDispatcher.Emit = function (InName, agv) { MyDispatcher.eventDispatcher.event(InName, agv); }; MyDispatcher.AddNotice = function (InName, caller, listener, arg) { MyDispatcher.eventDispatcher.on(InName, caller, listener, (arg == null) ? null : ([arg])); }; MyDispatcher.RemoveNotice = function (InName, caller, listener) { MyDispatcher.eventDispatcher.off(InName, caller, listener); }; class Planet extends Laya.Box { constructor() { super(); this.angle = 0; this.radian = 0; this.planetBreatheTime = 0; this.skillCountDownTime = 0; this.bindedRiftArr = []; this.planetNode = new Laya.Box(); this.planetImg = new Laya.Sprite(); this.iconSkillNode = new Laya.Box(); this.addChild(this.planetNode); this.planetNode.addChild(this.planetImg); this.addChild(this.iconSkillNode); this.textID = new Laya.Text(); this.textID.color = "#FF0000"; this.textID.fontSize = 30; this.textID.bold = true; this.textID.stroke = 2; this.textID.strokeColor = "#ffffff"; this.textID.visible = false; } planetInit() { if (this.bindedRiftArr.length > 0) { let arrLength = this.bindedRiftArr.length; for (let i = 0; i < arrLength; i++) { let rift = this.bindedRiftArr[0]; rift.removeSelf(); this.bindedRiftArr.splice(0, 1); } } let random = Math.floor(Math.random() * 10000); this.planetID = Laya.Browser.now() + random; this.dieNotice = this.planetID + "Die"; console.log("行星初始化,type==", this.planetType, "dieNotice===", this.dieNotice, "轨道", this.orbit); this.hitNotice = this.planetID + "Hit"; this.planetImg.rotation = 0; this.planetImg.alpha = 1; this.planetImg.scale(1, 1); let date = new Date(); this.addChild(this.textID); Laya.timer.frameLoop(1, this, function () { if (this.textID) { this.textID.text = Math.floor(this.angle); } }); switch (this.planetType) { case 0: this.init_Mercury(); break; case 1: this.init_Venus(); break; case 2: this.init_Mars(); break; case 3: this.init_Jupiter(); break; case 4: this.init_Saturn(); break; default: break; } this.planetImg.pivotX = this.planetImg.width / 2; this.planetImg.pivotY = this.planetImg.height / 2; this.revolveCenter = [MainScene.sun.planetInnerRing.x, MainScene.sun.planetInnerRing.y]; this.lastTime = Laya.Browser.now(); Laya.timer.frameLoop(1, this, this.Revolve); this.selfRotateSpeed = 1; this.selfRotateDirection = 1; if (this.orbit == 0) { this.revolveSpeed = this.revolveSpeedInner; } else { this.revolveSpeed = this.revolveSpeedOuter; } this.revolveSpeedInit = this.revolveSpeed; this.planetBreatheTime = 2000; } init_Mercury() { this.blood = MainScene.sun.totalBlood * (1 / 15); this.planetImg.loadImage("texture/Planet/Mercury.png"); let skillPath = "res/atlas/texture/Effect/Planet_Mercury.png"; let pos = [20, -10]; this.addSkillImg(skillPath, pos); let aMercurySkill = function () { if (!MainScene.gameControl.isStartGame) { return; } let sun = MainScene.sun; let sunCurBlood = sun.curBlood; let sunTotalBlood = sun.totalBlood; let addNum = 5 * MainScene.gameControl.curLevel; if (sunCurBlood < sunTotalBlood && sunCurBlood > 0) { if (sunCurBlood + addNum > sunTotalBlood) { addNum = sunTotalBlood - sunCurBlood; } sun.addBlood(addNum); AnimationControl.playIconPlusAni(this, MyConsts.imgPath.iconPlus); Laya.timer.once(1000, this, function () { if (!MainScene.gameControl.isStartGame) { return; } SkeletonControl.playAddBloodAni(); AnimationControl.playAddBloodNumAni(addNum); }); } }; Laya.timer.loop(3000, this, aMercurySkill); let MercuryDie = function () { Laya.timer.clear(this, aMercurySkill); MyDispatcher.RemoveNotice(this.dieNotice, this, MercuryDie); }; MyDispatcher.AddNotice(this.dieNotice, this, MercuryDie, null); this.revolveSpeedInner = 2 * Math.PI / 5 / 1000; this.revolveSpeedOuter = 2 * Math.PI / 8 / 1000; } init_Venus() { this.blood = MainScene.sun.totalBlood * (1 / 20); this.planetImg.loadImage("texture/Planet/Venus.png"); let VenusDie = function () { MyDispatcher.RemoveNotice(this.dieNotice, this, VenusDie); if (!MainScene.gameControl.isStartGame) return; MainScene.sun.addShield(MainScene.sun.totalBlood * 0.2); Laya.timer.once(250, this, function () { SkeletonControl.playAddShieldAni(this); }); }; MyDispatcher.AddNotice(this.dieNotice, this, VenusDie, null); this.revolveSpeedInner = 2 * Math.PI / 8 / 1000; this.revolveSpeedOuter = 2 * Math.PI / 10 / 1000; } init_Mars() { this.blood = MainScene.sun.totalBlood * (1 / 7); this.planetImg.loadImage("texture/Planet/Mars.png"); let MarsDie = function () { MyDispatcher.RemoveNotice(this.dieNotice, this, MarsDie); MyDispatcher.RemoveNotice(this.hitNotice, this, MarsHit); if (!MainScene.gameControl.isStartGame) return; Laya.timer.once(250, this, function () { AnimationControl.planetFireball(this, "res/atlas/texture/Effect/Planet_Mars/fireball.atlas"); let num = Math.ceil(MainScene.gameControl.bindToSunKnifeArr.length / 2); MainScene.gameControl.removeKnifeFromSun(num); }); }; MyDispatcher.AddNotice(this.dieNotice, this, MarsDie, null); let MarsHit = function () { let num = 1; MainScene.gameControl.removeTreeFromSun(num); }; MyDispatcher.AddNotice(this.hitNotice, this, MarsHit, null); this.revolveSpeedInner = 2 * Math.PI / 4 / 1000; this.revolveSpeedOuter = 2 * Math.PI / 6 / 1000; } init_Jupiter() { this.blood = MainScene.sun.totalBlood * (1 / 10); this.planetImg.loadImage("texture/Planet/Jupiter.png"); let skillPath = "res/atlas/texture/Planet/other.png"; let pos = [-50, 20]; this.addSkillImg(skillPath, pos); this.skillCountDownTime = 0; Laya.timer.loop(100, this, this.timerJupiterSkill); let JupiterDie = function () { MyDispatcher.RemoveNotice(this.dieNotice, this, JupiterDie); Laya.timer.clear(this, this.timerJupiterSkill); }; MyDispatcher.AddNotice(this.dieNotice, this, JupiterDie, null); this.revolveSpeedInner = 2 * Math.PI / 5 / 1000; this.revolveSpeedOuter = 2 * Math.PI / 8 / 1000; } init_Saturn() { this.blood = MainScene.sun.totalBlood * (1 / 10); this.planetImg.loadImage("texture/Planet/Saturn.png"); let skillPath = "res/atlas/texture/Effect/Planet_Saturn.png"; let pos = [15, 5]; this.addSkillImg(skillPath, pos); this.iconPlanetSkill.width = 72 * 0.6; this.iconPlanetSkill.height = 102 * 0.6; let SaturnSkillStartTime = Laya.Browser.now() / 1000; let aSaturnSkill = function () { let resetSpeed = function () { MainScene.gameControl.SaturnSkillTag = 0; let slowDownTag = MainScene.gameControl.slowDownTag; switch (slowDownTag) { case 0: MainScene.sun.sunRotateSpeed = MainScene.sun.sunRotateSpeedInit; break; case 1: MainScene.sun.sunRotateSpeed = 10; break; default: break; } }; if (!MainScene.gameControl.isStartGame) { return; } if (MainScene.gameControl.SaturnSkillTag == 1) { return; } MainScene.sun.sunRotateSpeed = MainScene.sun.sunRotateSpeed * 0.5; MainScene.gameControl.SaturnSkillTag = 1; let skillTime = 4000; let effectTag = 0; let effectTime = 0; for (let i = 0; i < 3; i++) { effectTime = 4000 / 3 * i; Laya.timer.once(effectTime, this, function () { if (!MainScene.gameControl.isStartGame) return; AnimationControl.playIconPlusAni(this, MyConsts.imgPath.iconFast); Laya.timer.once(600, this, function () { if (!MainScene.gameControl.isStartGame) { return; } MainScene.sun.playRingAniFast(MyConsts.animationName.fast, false); }); }); } Laya.timer.once(skillTime, this, resetSpeed); }; Laya.timer.loop(12000, this, aSaturnSkill); let SaturnDie = function () { Laya.timer.clear(this, aSaturnSkill); MyDispatcher.RemoveNotice(this.dieNotice, this, SaturnDie); MyDispatcher.RemoveNotice(this.hitNotice, this, SaturnHit); MainScene.gameControl.SaturnSkillTag = 0; }; MyDispatcher.AddNotice(this.dieNotice, this, SaturnDie, null); let SaturnHit = function () { MainScene.sun.sunRotateDirection = -MainScene.sun.sunRotateDirection; }; MyDispatcher.AddNotice(this.hitNotice, this, SaturnHit, null); this.revolveSpeedInner = 2 * Math.PI / 8 / 1000; this.revolveSpeedOuter = 2 * Math.PI / 10 / 1000; } timerJupiterSkill() { if (!MainScene.gameControl.isStartGame) { return; } this.skillCountDownTime += 100; if (this.skillCountDownTime >= 10000) { let gameControl = MainScene.gameControl; if (gameControl.bindToSunTreeArr.length >= 24) return; let aa = 15 * 3 / 2; let JupiterAngle = this.angle; let min = MathTool.angleBePositive(JupiterAngle - aa); let max = MathTool.angleBePositive(JupiterAngle + aa); let range = [min, max]; let sunRotation = MathTool.angleBePositive(MainScene.sun.sunAndKnifeNode.rotation); let existingRotationArr = gameControl.getTreeExistingRotation(); let blankPoints = gameControl.getAllBlankPoints(gameControl.allTreePoints, existingRotationArr); let blankPointClosest = this.getClosestPointFromArr(JupiterAngle, blankPoints); if (blankPointClosest) { let treeRotation = MathTool.angleBePositive(blankPointClosest.rotation); let arrAngle = sunRotation + treeRotation + 90; arrAngle = MathTool.angleBePositive(arrAngle); let b = MathTool.checkAngleIsInRange(arrAngle, range); if (b) { this.skillCountDownTime = 0; gameControl.addTree(blankPointClosest); } } } } getClosestPointFromArr(numA, pointArr) { let DValue = 360; let point = { "x": 0, "y": 0, "rotation": 0 }; let anumA = MathTool.angleBePositive(numA); let sunRotation = MathTool.angleBePositive(MainScene.sun.sunAndKnifeNode.rotation); for (let i = 0; i < pointArr.length; i++) { let apoint = pointArr[i]; let treeRotation = MathTool.angleBePositive(apoint.rotation); let arrAngle = sunRotation + treeRotation + 90; arrAngle = MathTool.angleBePositive(arrAngle); let aa = Math.abs(arrAngle - anumA); if (aa < DValue) { DValue = aa; point.x = apoint.x; point.y = apoint.y; point.rotation = apoint.rotation; } } return point; } addSkillImg(imgPath, pos) { this.iconPlanetSkill = new Laya.Sprite(); this.iconPlanetSkill.loadImage(imgPath); this.iconSkillNode.addChild(this.iconPlanetSkill); this.iconPlanetSkill.pos(pos[0], pos[1]); } planetBreathe() { Laya.Tween.to(this, { scaleX: 0.8, scaleY: 0.8 }, this.planetBreatheTime / 2, Laya.Ease.linearIn, Laya.Handler.create(this, function () { Laya.Tween.to(this, { scaleX: 1, scaleY: 1 }, this.planetBreatheTime / 2, Laya.Ease.linearIn); })); } subBlood(subNum) { if (this.blood - subNum >= 0) { this.blood -= subNum; } else { this.blood = 0; } } checkBlood() { if (this.blood > 0) { return true; } else { return false; } } die(fun, dieReason) { this.blood = 0; let planetB = MainScene.gameControl.planetBReplaceA(this); if (planetB) { planetB.visible = false; Laya.timer.loop(10000, planetB, function () { planetB.visible = true; }); } if (dieReason == 0) { AnimationControl.planetDieExplode(this, fun); MusicControl.planetDie(); } this.removeSkillIcon(); MyDispatcher.Emit(this.dieNotice, null); } removeSkillIcon() { if (this.iconPlanetSkill) this.iconPlanetSkill.removeSelf(); } onPlanetHit() { MyDispatcher.Emit(this.hitNotice, null); } Revolve() { let interval = Laya.Browser.now() - this.lastTime; this.radian += (this.revolveSpeed * interval * this.revolvedirection); this.x = this.revolveCenter[0] + Math.cos(this.radian) * this.revolveCenterDistance * 1; this.y = this.revolveCenter[1] + Math.sin(this.radian) * this.revolveCenterDistance * 1; this.angle = Math.floor((this.radian / (Math.PI / 180)) % 360); this.lastTime = Laya.Browser.now(); } rotate() { this.planetImg.rotation += this.selfRotateSpeed * this.selfRotateDirection; if (this.planetImg.rotation <= -360 || this.planetImg.rotation >= 360) { this.planetImg.rotation = 0; } } addRift(pos, rotation) { if (this.blood <= 0) return; let rift = Laya.Pool.getItemByClass("Rift", Laya.Sprite); let random = Math.ceil(Math.random() * 3); rift.loadImage("texture/Effect/PlanetRift/Rift0" + random + ".png"); rift.pivotX = rift.texture.width / 2; rift.pivotY = rift.texture.height; rift.pos(pos[0], pos[1]); rift.rotation = rotation; this.planetImg.addChild(rift); this.bindedRiftArr.push(rift); } } class CoinDailyIncomeControl { constructor() { this.timerInterval = 100; this.fasterTag = 0; this.incomeNormalInterval = 30; this.incomeFasterInterval = 10; this.incomeAtLeast = 100; this.incomeTimeAtMost = 3 * 60 * 60; this.incomeFasterTimeAtMost = 5 * 60; this.fasterInit(); } fasterInit() { let lastOfflineTime = MainScene.gameControl.lastGameOfflineTime; let lastFasterStartTime = this.getLastFasterStartTime(); if (lastFasterStartTime > 0) { this.ProfitFasterCountDown = this.incomeFasterTimeAtMost - Math.floor((lastOfflineTime - lastFasterStartTime) / 1000); if (this.ProfitFasterCountDown < 0) { this.ProfitFasterCountDown = 0; } } else { this.ProfitFasterCountDown = 0; } if (this.ProfitFasterCountDown > 0) { this.threeTimesFaster(); } } init() { let onceProfit = this.getOnceIncome(); let lastOfflineTime = MainScene.gameControl.lastGameOfflineTime; if (lastOfflineTime == 0) lastOfflineTime = Laya.Browser.now(); let curTime = Laya.Browser.now(); let offlineTimeTotal = Math.round((curTime - lastOfflineTime) / 1000); let lastNormalStartTime = this.getLastNormalStartTime(); if (lastNormalStartTime > 0) { this.ProfitCountDown = this.incomeTimeAtMost - Math.floor((lastOfflineTime - lastNormalStartTime) / 1000); } else { this.ProfitCountDown = this.incomeTimeAtMost; this.saveLastNormalStartTime(); } if (this.ProfitCountDown < 0) { this.ProfitCountDown = 0; } let lastFasterStartTime = this.getLastFasterStartTime(); if (lastFasterStartTime > 0) { this.ProfitFasterCountDown = this.incomeFasterTimeAtMost - Math.floor((lastOfflineTime - lastFasterStartTime) / 1000); if (this.ProfitFasterCountDown < 0) { this.ProfitFasterCountDown = 0; } } else { this.ProfitFasterCountDown = 0; } if (this.ProfitFasterCountDown < 0) { this.ProfitFasterCountDown = 0; } this.availableIncome = this.getAvailableIncomeData(); if (!this.availableIncome) { this.saveAvailableIncomeData(0); } if (this.ProfitCountDown <= offlineTimeTotal) { if (this.ProfitFasterCountDown <= this.ProfitCountDown) { let offlineFasterProfitTime = this.ProfitFasterCountDown; let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval); let offlineFasterProfit = onceProfit * a; this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit); let offlineNormalProfitTime = this.ProfitCountDown - offlineFasterProfitTime; let b = Math.floor(offlineNormalProfitTime / this.incomeNormalInterval); let offlineNormalProfit = onceProfit * b; this.saveAvailableIncomeData(this.availableIncome + offlineNormalProfit); this.ProfitCountDown = 0; this.ProfitFasterCountDown = 0; } else { let offlineFasterProfitTime = this.ProfitCountDown; let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval); let offlineFasterProfit = onceProfit * a; this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit); this.ProfitFasterCountDown = this.ProfitFasterCountDown - this.ProfitCountDown; this.ProfitCountDown = 0; } } else { if (this.ProfitFasterCountDown <= this.ProfitCountDown) { if (this.ProfitFasterCountDown > offlineTimeTotal) { let offlineFasterProfitTime = offlineTimeTotal; let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval); let offlineFasterProfit = onceProfit * a; this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit); this.ProfitCountDown -= offlineTimeTotal; this.ProfitFasterCountDown -= offlineTimeTotal; } else { let offlineFasterProfitTime = this.ProfitFasterCountDown; let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval); let offlineFasterProfit = onceProfit * a; this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit); let offlineNormalProfitTime = offlineTimeTotal - offlineFasterProfitTime; let b = Math.floor(offlineNormalProfitTime / this.incomeNormalInterval); let offlineNormalProfit = onceProfit * b; this.saveAvailableIncomeData(this.availableIncome + offlineNormalProfit); this.ProfitCountDown -= offlineTimeTotal; this.ProfitFasterCountDown = 0; } } else { let offlineFasterProfitTime = offlineTimeTotal; let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval); let offlineFasterProfit = onceProfit * a; this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit); this.ProfitCountDown -= offlineTimeTotal; this.ProfitFasterCountDown -= offlineTimeTotal; } } this.updateDialogIncomeUI(); this.startTimer_updateProfitCountDown(); this.updateIncomeMostProgressUI(); } startTimer_updateProfitCountDown() { Laya.timer.loop(1000, this, this.timer_updateProfitCountDown); if (this.fasterTag == 0) { Laya.timer.loop(this.incomeNormalInterval * 1000, this, this.timer_addIncome); this.playRingAni(this.incomeNormalInterval, 0); } } stopTimer_updateProfitCountDown() { Laya.timer.clear(this, this.timer_updateProfitCountDown); Laya.timer.clear(this, this.timer_addIncome); } restartTimer_updateProfitCountDown() { this.ProfitCountDown = this.incomeTimeAtMost; this.stopTimer_updateProfitCountDown(); this.saveAvailableIncomeData(0); this.startTimer_updateProfitCountDown(); this.saveLastNormalStartTime(); } playRingAni(curInterval, elapsedTime) { Laya.timer.clear(this, this.timer_updateRingProgress); this.curInterval = curInterval * 1000; this.elapsedTime = elapsedTime * 1000; this.timerInterval = 100; Laya.timer.loop(this.timerInterval, this, this.timer_updateRingProgress); } timer_updateRingProgress() { if (this.ProfitCountDown <= 0) { Laya.timer.clear(this, this.timer_updateRingProgress); MainScene.instance.profitProgress.graphics.clear(); MainScene.instance.profitProgress.graphics.drawPie(38, 38, 38, 270, 270 + 360, "#fed20f"); } else { this.elapsedTime += this.timerInterval; let percent = (this.elapsedTime % this.curInterval) / this.curInterval; let angle = 360 * percent; MainScene.instance.profitProgress.graphics.clear(); MainScene.instance.profitProgress.graphics.drawPie(38, 38, 38, 270, 270 + angle, "#fed20f"); } } timer_updateProfitCountDown() { let dialog = MainScene.instance.dialog_receiveCoinProfit; if (this.ProfitCountDown > 0) { this.ProfitCountDown -= 1; } else { dialog.text_UpperLimitTime.text = "\n收益已达上限!"; this.ProfitCountDown = 0; this.stopTimer_updateProfitCountDown(); return; } let hour = Math.floor(this.ProfitCountDown / 3600); let minute = Math.floor((this.ProfitCountDown - hour * 3600) / 60); let second = Math.floor(this.ProfitCountDown % 60); let str_hour = (hour >= 10) ? (hour + "") : (hour > 0 ? ("0" + hour) : "00"); let str_minute = (minute >= 10) ? (minute + "") : (minute > 0 ? ("0" + minute) : "00"); let str_second = (second >= 10) ? (second + "") : (second > 0 ? ("0" + second) : "00"); let str = str_hour + ":" + str_minute + ":" + str_second; if (hour > 0 || minute > 0 || second > 0) { dialog.text_UpperLimitTime.text = " " + str + "后\n" + "收益达到上限"; } } threeTimesFaster() { this.fasterTag = 1; Laya.timer.clear(this, this.timer_addIncome); let adialog = MainScene.instance.dialog_speedUpCoinProfit; adialog.fasterCountTime_bg.visible = true; adialog.btn_threeTimesFaster.visible = false; let amask = adialog.mask_fasterCountTime; let maskW = amask.width; amask.x -= maskW; let interval = this.incomeFasterInterval; let totalTime = this.ProfitFasterCountDown; let lastedTime = this.incomeFasterTimeAtMost - totalTime; let nextProfitTime = totalTime % interval > 0 ? totalTime % interval + lastedTime : interval + lastedTime; this.playRingAni(nextProfitTime - lastedTime, 0); let countNum = totalTime; let timer_threeTimesFaster = function () { if (countNum <= 0) { this.fasterTag = 0; Laya.timer.clear(this, timer_threeTimesFaster); if (MainScene.gameControl.maxLevel >= 20) { Laya.timer.loop(this.incomeNormalInterval * 1000, this, this.timer_addIncome); this.playRingAni(this.incomeNormalInterval, 0); } adialog.fasterCountTime_bg.visible = false; adialog.btn_threeTimesFaster.visible = true; } else { countNum -= 1; let fasterTime = this.incomeFasterTimeAtMost - countNum; let percent = countNum / this.incomeFasterTimeAtMost; amask.x = maskW * (-percent); adialog.fasterCountTime.value = this.secendToHour(countNum); if (fasterTime >= nextProfitTime) { if (MainScene.gameControl.maxLevel >= 20) { this.timer_addIncome(); } nextProfitTime += interval; this.playRingAni(interval, 0); } } }; Laya.timer.loop(1000, this, timer_threeTimesFaster); } secendToHour(timeNum) { let hour = Math.floor(timeNum / 3600); let minute = Math.floor((timeNum - hour * 3600) / 60); let second = Math.floor(timeNum % 60); let str_hour = (hour >= 10) ? (hour + "") : (hour > 0 ? ("0" + hour) : ""); let str_minute = (minute >= 10) ? (minute + "") : (minute > 0 ? ("0" + minute) : "00"); let str_second = (second >= 10) ? (second + "") : (second > 0 ? ("0" + second) : "00"); let str = str_minute + ":" + str_second; return str; } timer_addIncome() { let onceIncome = this.getOnceIncome(); this.availableIncome += onceIncome; this.updateDialogIncomeUI(); this.saveAvailableIncomeData(this.availableIncome); this.updateIncomeMostProgressUI(); Laya.Tween.to(MainScene.instance.coinProfitRing, { rotation: 360 }, 800, Laya.Ease.linearIn, Laya.Handler.create(this, function () { MainScene.instance.coinProfitRing.rotation = 0; })); } updateDialogIncomeUI() { let coinStr = MathTool.currencyUnit(this.availableIncome); MainScene.instance.dialog_receiveCoinProfit.text_btn_clickReceive.text = coinStr; let coinStr3 = MathTool.currencyUnit(this.availableIncome * 3); MainScene.instance.dialog_receiveCoinProfit.text_btn_threeTimesReceive.text = coinStr3; } getOnceIncome() { let onceIncome = MainScene.gameControl.coinInfo.coinProfit; return onceIncome; } updateIncomeMostProgressUI() { let instance = MainScene.instance; let progressValue = 1 - this.ProfitCountDown / this.incomeTimeAtMost; instance.coinIncomeProgress.value = progressValue; } updateRingUI() { if (this.ProfitCountDown > 0) { } else { MainScene.instance.profitProgress.graphics.clear(); MainScene.instance.profitProgress.graphics.drawPie(38, 38, 38, 270, 270 + 359, "#fed20f"); } } saveAvailableIncomeData(value) { this.availableIncome = value; Data.setNumber("AvailableIncomeData", value); } getAvailableIncomeData() { return Data.getNumber("AvailableIncomeData"); } saveLastNormalStartTime() { let value = Laya.Browser.now(); Data.setNumber("LastNormalStartTime", value); } getLastNormalStartTime() { return Data.getNumber("LastNormalStartTime"); } saveLastFasterStartTime() { let value = Laya.Browser.now(); Data.setNumber("LastFasterStartTime", value); } getLastFasterStartTime() { return Data.getNumber("LastFasterStartTime"); } } class GameControl extends Laya.Script { constructor() { super(); this.shareOpen = true; this.bindToSunKnifeArr = []; this.isStartGame = false; this.curLevel = 1; this.maxLevel = 0; this.holdCoinsNum = 0; this.holdStrengthNum = 0; this.bindToSunTreeArr = []; this.knifeInfo = { "knifeNumGrade": 0, "knifeTotalNum": 0, "knifeUpgradeNumNeedCoins": 0, "knifeAttackGrade": 0, "knifeAttack": 0, "knifeUpgradeAttackNeedCoins": 0 }; this.knifeRestNum = 0; this.critInfo = { "critAttackGrade": 0, "critAttack": 0, "critUpgradeAttackNeedCoins": 0, "critChanceGrade": 0, "critChance": 0, "critUpgradeChanceNeedCoins": 0 }; this.coinInfo = { "coinValueGrade": 0, "coinValue": 0, "coinUpgradeValueNeedCoins": 0, "coinProfitGrade": 0, "coinProfit": 0, "coinUpgradeProfitNeedCoins": 0 }; this.nextChangeDirLevel = 0; this.planetsInfoAtCurLevel = { "planetTotalNum": 0, "innerRingPlanetNum": 0, "outerRingPlanetNum": 0, "planetCorrespondingNum": { "Mercury": 0, "Venus": 0, "Mars": 0, "Jupiter": 0, "Saturn": 0, } }; this.planetsInfo = [ { "name": "小兰", "url": "texture/Planet/Mercury.png", "skill": "可以为病毒加血" }, { "name": "小绿", "url": "texture/Planet/Venus.png", "skill": "消灭后会给病毒一个护盾" }, { "name": "小火", "url": "texture/Planet/Mars.png", "skill": "被攻击可减少病毒上的火箭和禁牌" }, { "name": "小紫", "url": "texture/Planet/Jupiter.png", "skill": "可以为病毒增加禁牌" }, { "name": "小黄", "url": "texture/Planet/Saturn.png", "skill": "可以为病毒加速" } ]; this.allPlanets = []; this.innerPlanets = []; this.outerPlanets = []; this.curPlanets = []; this.coinNumFromCurLevel = 0; this.propInvincibleRocketNum = 0; this.propInvincibleRocketTotalNum = 0; this.reviveChance = 0; this.gameStartTime = 0; this.sunPos = [175, 175]; this.launchRocketTag = 0; this.allTreePoints = [{ "x": 0, "y": 0, "rotation": 0 }]; this.allInnerPlanetPoints = [{ "x": 0, "y": 0, "rotation": 0 }]; this.allOuterPlanetPoints = [{ "x": 0, "y": 0, "rotation": 0 }]; this.smallLiquiCount = 0; this.bigLiquiCount = 0; this.slowDownTag = 0; this.SaturnSkillTag = 0; this.curKnifeArr = []; this.leftoverPlanets = []; this.newPlayerTag = 0; } onEnable() { MainScene.gameControl = this; this.init(); } init() { this.b_propTeach = this.getPropTeach(); this.lastGameOfflineTime = this.getLastOfflineTime(); this.gameStartTime = Laya.Browser.now(); let playCount = Data.getPlayCount(); if (playCount && playCount > 0) { this.initInfoFromData(); } else { this.initData(); } console.log("初始化时获取的分数", this.getMaxLevel()); Data.addPlayCount(); this.updateHomeUI(); let sun = new Sun(); MainScene.instance.SunBox.addChild(sun); MainScene.sun = sun; MainScene.sun.sunIdle(); Laya.timer.loop(1000, this, this.setThisOfflineTime); MainScene.instance.coinDailyIncomeControl = new CoinDailyIncomeControl(); if (this.maxLevel >= 5) { MainScene.instance.coinDailyIncomeControl.init(); MainScene.instance.coinProfit.visible = true; } else { MainScene.instance.coinProfit.visible = false; } SkeletonControl.initTemplet(); MainScene.instance.btn_testEffect.on(Laya.Event.MOUSE_DOWN, this, function () { MusicControl.gameFailed(); }); this.getOfflineStrength(); this.initTipUpperLimitAni(); this.allTreePoints = []; this.allInnerPlanetPoints = []; this.allOuterPlanetPoints = []; let sunTreeNode = sun.treeNode; let rSub = MyConsts.treeThorough; this.allTreePoints = this.getAllPoints(sunTreeNode.width / 2 - rSub, 15); let innerNode = sun.planetInnerRingNode; this.allInnerPlanetPoints = this.getAllPoints(innerNode.width / 2, 30); let outerNode = sun.planetOuterRingNode; this.allOuterPlanetPoints = this.getAllPoints(outerNode.width / 2, 30); this.fingerAni = AnimationControl.playFingerAni(); this.fingerAni.scale(1, 1); this.fingerAni.visible = false; this.checkNewPlayer(); } initInfoFromData() { this.coinInfo = this.getCoinInfo(); this.critInfo = this.getCritInfo(); this.knifeInfo = this.getKnifeInfo(); this.maxLevel = this.getMaxLevel(); this.holdCoinsNum = this.getHoldCoinsNum(); this.holdStrengthNum = this.getHoldStrengthNum(); } initData() { this.growthSystemInit(); this.setMaxLevel(0); this.setHoldCoinsNum(5000); this.setHoldStrengthNum(100); this.setPlayCount(0); } getAllPoints(r, angleRestriction) { let allPoints = []; let totalPointNum = 360 / angleRestriction; for (let i = 0; i < totalPointNum; i++) { let pointInfo = { "x": 0, "y": 0, "rotation": 0 }; let angle = angleRestriction * i; let radian = Math.PI / 180 * angle; let pointX = Math.cos(radian) * r; let pointY = Math.sin(radian) * r; pointInfo.rotation = MathTool.angleBePositive(angleRestriction * i - 90); pointInfo.x = pointX; pointInfo.y = pointY; allPoints.push(pointInfo); } return allPoints; } getAllBlankPoints(totalPointArr, existingRotation) { let allBlankPoints = [{ "x": 0, "y": 0, "rotation": 0 }]; allBlankPoints = []; for (let i = 0; i < totalPointArr.length; i++) { let point = { "x": 0, "y": 0, "rotation": 0 }; let apoint = totalPointArr[i]; point.x = apoint.x; point.y = apoint.y; point.rotation = apoint.rotation; allBlankPoints.push(point); } for (let i = 0; i < existingRotation.length; i++) { let a_existingRotation = existingRotation[i]; for (let j = 0; j < allBlankPoints.length; j++) { let apoint = allBlankPoints[j]; if (a_existingRotation == apoint.rotation) { allBlankPoints.splice(j, 1); break; } } } return allBlankPoints; } addCoins(addNum) { MainScene.gameControl.setHoldCoinsNum(MainScene.gameControl.holdCoinsNum + addNum); MusicControl.getCoins(); } receiveCoinDailyIncome(coinNum) { this.addCoins(coinNum); this.updateHomeUI(); } recoverEnergies(strengthNum, type) { switch (type) { case 0: if (this.holdStrengthNum >= 100) return; if (this.holdStrengthNum + strengthNum >= 100) { this.setHoldStrengthNum(100); } else { this.setHoldStrengthNum(this.holdStrengthNum + strengthNum); } let ring = MainScene.instance.dialog_getStrength.ring; Laya.Tween.to(ring, { rotation: 360 }, 800, Laya.Ease.linearIn, Laya.Handler.create(this, function () { ring.rotation = 0; })); break; case 1: this.setHoldStrengthNum(this.holdStrengthNum + strengthNum); break; default: break; } MainScene.gameControl.updateHomeUI(); } getOfflineStrength() { if (this.holdStrengthNum < 100) { let astartTime = this.getRecoverStrengthCountDownStartTime(); if (astartTime < 1 || !astartTime) { this.saveRecoverStrengthCountDownStartTime(-1); } let lastStartTime = this.recoverStrengthCountDownStartTime = this.getRecoverStrengthCountDownStartTime(); let curTime = Laya.Browser.now(); let offlineTimeTotal = Math.round((curTime - lastStartTime) / 1000); let offlineStrength = Math.floor(offlineTimeTotal / 60 / 5); let elapsedTime = Math.floor((curTime - lastStartTime) / 1000); if (this.holdStrengthNum < 100) { if (this.holdStrengthNum + offlineStrength >= 100) { this.setHoldStrengthNum(100); this.saveRecoverStrengthCountDownStartTime(-1); } else { this.setHoldStrengthNum(this.holdStrengthNum + offlineStrength); this.strengthCountDown = 60 * 5 - elapsedTime; this.updateHomeUI(); } } } else { this.saveRecoverStrengthCountDownStartTime(-1); } Laya.timer.loop(1000, this, this.timerCountDownStrength); } timerCountDownStrength() { if (this.holdStrengthNum < 100) { if (this.recoverStrengthCountDownStartTime > 0) { this.strengthCountDown -= 1; if (this.strengthCountDown <= 0) { this.recoverEnergies(1, 0); if (this.holdStrengthNum < 100) { this.strengthCountDown = 5 * 60; this.saveRecoverStrengthCountDownStartTime(); } else { this.saveRecoverStrengthCountDownStartTime(-1); } } } else { this.strengthCountDown = 5 * 60; this.saveRecoverStrengthCountDownStartTime(); } } else { this.strengthCountDown = 5 * 60; this.saveRecoverStrengthCountDownStartTime(-1); } this.updateStrengthUI(); } updateStrengthUI() { let interval = 5 * 60; let dialog = MainScene.instance.dialog_getStrength; if (this.holdStrengthNum < 100) { let countDown = this.strengthCountDown; let angle = 360 * ((interval - countDown) / (interval)); dialog.strengthRingProgress.graphics.clear(); dialog.strengthRingProgress.graphics.drawPie(92, 92, 92, 270, 270 + angle, "#fed20f"); let minute = Math.floor(countDown / 60); let second = countDown % 60; let str_minute = (minute >= 10) ? (minute + "") : (minute > 0 ? ("0" + minute) : "00"); let str_second = (second >= 10) ? (second + "") : (second > 0 ? ("0" + second) : "00"); dialog.tip.text = str_minute + ":" + str_second + " 后恢复1点体力"; } else { dialog.tip.text = "体力已经最满啦!"; let angle = 360; dialog.strengthRingProgress.graphics.clear(); dialog.strengthRingProgress.graphics.drawPie(92, 92, 92, 270, 270 + angle, "#fed20f"); } } growthSystemInit() { this.knifeInfo.knifeNumGrade = 1; this.knifeInfo.knifeTotalNum = 4; this.knifeInfo.knifeUpgradeNumNeedCoins = 50; this.knifeInfo.knifeAttackGrade = 1; this.knifeInfo.knifeAttack = 40; this.knifeInfo.knifeUpgradeAttackNeedCoins = 30; this.setKnifeInfo(this.knifeInfo); this.critInfo.critAttackGrade = 0; this.critInfo.critAttack = 0; this.critInfo.critUpgradeAttackNeedCoins = 0; this.critInfo.critChanceGrade = 0; this.critInfo.critChance = 0; this.critInfo.critUpgradeChanceNeedCoins = 0; Data.setCritInfo(this.critInfo); this.coinInfo.coinValueGrade = 0; this.coinInfo.coinValue = 0; this.coinInfo.coinUpgradeValueNeedCoins = 0; this.coinInfo.coinProfitGrade = 0; this.coinInfo.coinProfit = 0; this.coinInfo.coinUpgradeProfitNeedCoins = 0; Data.setCoinInfo(this.coinInfo); } critSystemInit() { this.critInfo.critAttackGrade = 1; this.critInfo.critAttack = Math.round(4 * this.critInfo.critAttackGrade / (this.critInfo.critAttackGrade + 6) * 100) / 100 - 0.57; this.critInfo.critUpgradeAttackNeedCoins = this.critInfo.critAttackGrade * 15; this.critInfo.critChanceGrade = 1; this.critInfo.critChance = Math.round((this.critInfo.critChanceGrade / (3 * this.critInfo.critChanceGrade + 50)) * 100) / 100; this.critInfo.critUpgradeChanceNeedCoins = this.critInfo.critChanceGrade * 10; Data.setCritInfo(this.critInfo); } coinSystemInit() { this.coinInfo.coinValueGrade = 1; this.coinInfo.coinValue = 10; this.coinInfo.coinUpgradeValueNeedCoins = 70; this.coinInfo.coinProfitGrade = 1; this.coinInfo.coinProfit = 20; this.coinInfo.coinUpgradeProfitNeedCoins = 60; Data.setCoinInfo(this.coinInfo); } onGameStageClick() { if (!this.isStartGame) return; if (this.launchRocketTag == 1) return; if (!this.curBeReadyKnife) { return; } if (!this.curBeReadyKnife.beReadyToLaunch) return; if ((this.knifeRestNum > 0 || this.propInvincibleRocketNum > 0) && this.launchRocketTag == 0) { this.launchRocketTag = 1; this.updateGameUI(); this.curBeReadyKnife.knifeBindToSun(); this.curBeReadyKnife = null; this.deductKnifeNum(); this.createKnife(); } } initTipUpperLimitAni() { let text_upperLimit = this.upperLimit = new Laya.Text(); text_upperLimit.text = "该道具本局获取次数已达上限"; text_upperLimit.color = "#ffffff"; text_upperLimit.fontSize = 38; text_upperLimit.alpha = 0; text_upperLimit.pivot(text_upperLimit.width / 2, text_upperLimit.height / 2); Laya.stage.addChild(text_upperLimit); text_upperLimit.pos(Laya.stage.width / 2, Laya.stage.height / 2); } showTipUpperLimit() { let aniY = Laya.stage.height / 2; MainScene.gameControl.upperLimit.y = aniY + 50; Laya.Tween.to(MainScene.gameControl.upperLimit, { y: aniY, alpha: 1 }, 500, null, null, 0.1, true); Laya.timer.once(500, MainScene.gameControl, function () { Laya.Tween.to(MainScene.gameControl.upperLimit, { y: aniY - 50, alpha: 0 }, 800, null, null, 0.1, true); }); } onRocketClick() { if (MainScene.instance.dialog_freelyGetProp.freelyChance.rocketChance > 0) { MainScene.instance.dialog_freelyGetProp.showDialog(0); } else { this.showTipUpperLimit(); } } usingProp_rocket() { if (!MainScene.gameControl.isStartGame) return; if (!MainScene.gameControl.curBeReadyKnife) return; MainScene.gameControl.propInvincibleRocketNum += 5; MainScene.gameControl.propInvincibleRocketTotalNum += 5; MainScene.gameControl.curBeReadyKnife.isInvincible = true; MainScene.gameControl.curBeReadyKnife.updateTexture(); MainScene.gameControl.updateGameUI(); } onSlowDownClick() { if (this.slowDownTag == 1) return; if (MainScene.instance.dialog_freelyGetProp.freelyChance.slowDownChance > 0) { MainScene.instance.dialog_freelyGetProp.showDialog(1); } else { this.showTipUpperLimit(); } this.updateGameUI(); } usingProp_slowDown() { MainScene.gameControl.slowDownTag = 1; MainScene.sun.sunRotateSpeed = 10; let innerPlanetsNum = MainScene.gameControl.innerPlanets.length; for (let i = 0; i < innerPlanetsNum; i++) { let planet = MainScene.gameControl.innerPlanets[i]; planet.revolveSpeed -= (planet.revolveSpeed * 0.5); } let outerPlanetsNum = MainScene.gameControl.outerPlanets.length; for (let i = 0; i < outerPlanetsNum; i++) { let planet = MainScene.gameControl.outerPlanets[i]; planet.revolveSpeed -= (planet.revolveSpeed * 0.5); } let sp = new Laya.Sprite(); sp.loadImage("texture/GameScene/radialLine.png"); sp.pivot(sp.width / 2, sp.height); let spP = new Laya.Point(MainScene.gameControl.curBeReadyKnife.x, MainScene.gameControl.curBeReadyKnife.y); spP = MainScene.instance.KnifeBox.localToGlobal(spP); sp.pos(spP.x, spP.y); Laya.stage.addChild(sp); let isStopSlowDown = false; let stopSlowDown = function () { isStopSlowDown = true; sp.removeSelf(); sp.destroy(); MainScene.gameControl.slowDownTag = 0; MainScene.sun.sunRotateSpeed = MainScene.sun.sunRotateSpeedInit; let innerPlanetsNum2 = MainScene.gameControl.innerPlanets.length; for (let i = 0; i < innerPlanetsNum2; i++) { let planet = MainScene.gameControl.innerPlanets[i]; planet.revolveSpeed = planet.revolveSpeedInit; } let outerPlanetsNum2 = MainScene.gameControl.outerPlanets.length; for (let i = 0; i < outerPlanetsNum2; i++) { let planet = MainScene.gameControl.outerPlanets[i]; planet.revolveSpeed = planet.revolveSpeedInit; } }; Laya.timer.once(15000, MainScene.gameControl, function () { if (!isStopSlowDown) { stopSlowDown(); } }); let stopSlowDownAfterGameOver = function () { if (!MainScene.gameControl.isStartGame) { if (!isStopSlowDown) { stopSlowDown(); } Laya.timer.clear(MainScene.gameControl, stopSlowDownAfterGameOver); } }; Laya.timer.frameLoop(1, MainScene.gameControl, stopSlowDownAfterGameOver); } onSubBloodClick() { if (MainScene.instance.dialog_freelyGetProp.freelyChance.subBloodChance > 0) { MainScene.instance.dialog_freelyGetProp.showDialog(2); } else { this.showTipUpperLimit(); } } usingProp_subBlood() { let subHP = Math.floor(MainScene.sun.curBlood * 0.5); AnimationControl.playSubBloodNumAni(subHP + "", MainScene.sun.normalNumBox, [360, 0], 1); MainScene.sun.subBlood(subHP); let innerPlanetsNum = MainScene.gameControl.innerPlanets.length; for (let i = 0; i < innerPlanetsNum; i++) { let planet = MainScene.gameControl.innerPlanets[i]; planet.subBlood(planet.blood * 0.5); } let outerPlanetsNum = MainScene.gameControl.outerPlanets.length; for (let i = 0; i < outerPlanetsNum; i++) { let planet = MainScene.gameControl.outerPlanets[i]; planet.subBlood(planet.blood * 0.5); } MainScene.gameControl.updateGameUI(); } curKnifeArrivedSun(knife) { let gameControl = MainScene.gameControl; if (!gameControl.isStartGame) return; gameControl.bindToSunKnifeArr.push(knife); knife.clearCheckCollision(); let knifeAttack = gameControl.checkKnifeCrit(knife, MainScene.sun.normalNumBox, [360, 0], 1); MainScene.sun.subBlood(knifeAttack); if (MainScene.gameControl.knifeRestNum == 1 && !MainScene.gameControl.b_propTeach) { } if (knife.attack > MainScene.sun.shieldBlood) { MainScene.sun.addRift(); } let addCoinNum = 1.5 * (Math.pow(gameControl.curLevel, 2) + 2 * gameControl.curLevel + gameControl.coinInfo.coinValue); gameControl.coinNumFromCurLevel += Math.floor(addCoinNum); gameControl.updateGameUI(); let isSunAlive = MainScene.sun.checkBlood(); if (isSunAlive) { if (gameControl.knifeRestNum <= 0 && gameControl.propInvincibleRocketNum <= 0) { gameControl.stopGame(); gameControl.levelFailed(); MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭已用完"; } } else { gameControl.levelSuccessful(); } } clearCurKnifeArr() { let num = this.curKnifeArr.length; if (this.curKnifeArr && num > 0) { for (let i = 0; i < num; i++) { this.curKnifeArr[0].removeSelf(); this.curKnifeArr.splice(0, 1); } ; } } createKnife() { if (!MainScene.gameControl.isStartGame) return; if (MainScene.gameControl.knifeRestNum <= 0 && MainScene.gameControl.propInvincibleRocketNum <= 0) { return; } let knife = Laya.Pool.getItemByClass("Knife", Knife); knife.beReadyToLaunch = false; knife.pivotX = knife.width / 2; knife.init(); MainScene.instance.KnifeBox.addChild(knife); MainScene.gameControl.curBeReadyKnife = knife; if (MainScene.gameControl.propInvincibleRocketNum > 0) { knife.isInvincible = true; knife.updateTexture(); } else { knife.isInvincible = false; knife.updateTexture(); } if (knife.fireAni) { knife.fireAni.visible = true; let posX = knife.width / 2 - 5; let posY = knife.height - 8; knife.fireAni.pos(posX, posY); } else { knife.fireAni = AnimationControl.knifeFireAni(knife); } knife.pos(360, 1800); let targetY = MainScene.instance.exampleKnife.y; let flySpeed = 200; let knifeFly = function () { if (knife.y - flySpeed <= targetY) { knife.y = targetY; Laya.timer.clear(this, knifeFly); MainScene.gameControl.launchRocketTag = 0; knife.beReadyToLaunch = true; } else { knife.y -= flySpeed; } }; Laya.timer.frameLoop(1, this, knifeFly); return knife; } deductKnifeNum() { if (MainScene.gameControl.propInvincibleRocketNum > 0) { MainScene.gameControl.propInvincibleRocketNum -= 1; } else { if (MainScene.gameControl.knifeRestNum > 0) { MainScene.gameControl.knifeRestNum -= 1; } } } saveMinPointY() { let knifeHeight = 124; let treeHeight = 111; let minKnifePoint = new Laya.Point(360, MainScene.sun.sunNode.y + MyConsts.knifeToSunCenter + knifeHeight); minKnifePoint = MainScene.sun.localToGlobal(minKnifePoint); minKnifePoint = MainScene.instance.KnifeBox.globalToLocal(minKnifePoint); this.minKnifeY = minKnifePoint.y; let minInnerPlanetPoint = new Laya.Point(360, MainScene.sun.sunNode.y + MainScene.sun.planetInnerRing.height / 2 + 60); minInnerPlanetPoint = MainScene.sun.localToGlobal(minInnerPlanetPoint); minInnerPlanetPoint = MainScene.instance.KnifeBox.globalToLocal(minInnerPlanetPoint); this.minInnerY = minInnerPlanetPoint.y; let minOuterPlanetPoint = new Laya.Point(360, MainScene.sun.sunNode.y + MainScene.sun.planetOuterRing.height / 2 + 60); minOuterPlanetPoint = MainScene.sun.localToGlobal(minOuterPlanetPoint); minOuterPlanetPoint = MainScene.instance.KnifeBox.globalToLocal(minOuterPlanetPoint); this.minOuterY = minOuterPlanetPoint.y; } getTreesNum() { let random = Math.random(); let treeNum = 0; let a = 0; let b = 0; let s = 0; if (this.curLevel <= 29) { s = 5; a = this.curLevel % (s * 3); b = Math.floor(this.curLevel / 15); if (this.curLevel >= 5 && this.curLevel <= 9) { if (random <= 0.1) { treeNum = b; } else if (random > 0.1 && random <= 0.7) { treeNum = b + 1; } else { treeNum = b + 2; } } else { if (a < s) { if (random <= 0.3) { treeNum = b; } else { treeNum = b + 1; } } else if (a >= s && a < (s * 2)) { if (random <= 0.3) { treeNum = b; } else if (random > 0.3 && random <= 0.8) { treeNum = b + 1; } else { treeNum = b + 2; } } else { if (random <= 0.1) { treeNum = b; } else if (random > 0.1 && random <= 0.6) { treeNum = b + 1; } else { treeNum = b + 2; } } } } else { s = 15; a = (this.curLevel - 29) % (s * 3); b = Math.floor((this.curLevel - 29) / 45) + 2; if (a > 0 && a <= s) { if (random <= 0.3) { treeNum = b; } else { treeNum = b + 1; } } else if (a > s && a <= (s * 2)) { if (random <= 0.3) { treeNum = b; } else if (random > 0.3 && random <= 0.8) { treeNum = b + 1; } else { treeNum = b + 2; } } else { if (random <= 0.1) { treeNum = b; } else if (random > 0.1 && random <= 0.6) { treeNum = b + 1; } else { treeNum = b + 2; } } } return treeNum; } getTreeExistingRotation() { let existingRotation = []; for (let i = 0; i < this.bindToSunTreeArr.length; i++) { existingRotation.push(this.bindToSunTreeArr[i].rotation); } return existingRotation; } getInnerPlanetExistingRotation() { let existingRotation = []; for (let i = 0; i < this.innerPlanets.length; i++) { existingRotation.push(this.innerPlanets[i].rotationSun); } return existingRotation; } getOuterPlanetExistingRotation() { let existingRotation = []; for (let i = 0; i < this.outerPlanets.length; i++) { existingRotation.push(this.outerPlanets[i].rotationSun); } return existingRotation; } generateTrees(treeNum, treePoint) { let sun = MainScene.sun.treeNode; let rSub = MyConsts.treeThorough; let TreeExistingRotation = this.getTreeExistingRotation(); if (TreeExistingRotation.length >= 24) return; let treeInfo = this.getRandomPoint2(treeNum, sun.width / 2 - rSub, TreeExistingRotation, 15); let newTree = []; for (let i = 0; i < treeNum; i++) { let tree = Laya.Pool.getItemByClass("tree", Tree); sun.addChild(tree); if (treePoint) { let point = [treePoint.x + this.sunPos[0], treePoint.y + this.sunPos[1]]; tree.pos(point[0], point[1]); tree.rotation = treePoint.rotation; } else { let point = [treeInfo[0][i][0] + this.sunPos[0], treeInfo[0][i][1] + this.sunPos[1]]; let rotation = treeInfo[1][i]; tree.pos(point[0], point[1]); tree.rotation = rotation; } tree.textID_tree.text = tree.rotation + ""; this.bindToSunTreeArr.push(tree); newTree.push(tree); } return newTree; } getRandomPoint(targetNum, r, existingRotation) { if (existingRotation.length > 12) return; let s = Math.sqrt(3); let pointArr = [ [0, 1], [-0.5, 0.5 * s], [-0.5 * s, 0.5], [-1, 0], [-0.5 * s, -0.5], [-0.5, -0.5 * s], [0, -1], [0.5, -0.5 * s], [0.5 * s, -0.5], [1, 0], [0.5 * s, 0.5], [0.5, 0.5 * s] ]; let treeInfo = []; let treePoint = []; let treeRotation = []; treeInfo.push(treePoint); treeInfo.push(treeRotation); let curArr = []; for (let i = 0; i < existingRotation.length; i++) { curArr.push(existingRotation[i] / 30); } let numArr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; for (let i = 0; i < curArr.length; i++) { for (let j = 0; j < numArr.length; j++) { if (curArr[i] == numArr[j]) { numArr.splice(j, 1); } } } if (numArr.length == 0) return; for (let i = 0; i < targetNum; i++) { let randomNum = Math.floor(Math.random() * numArr.length); let random = numArr[randomNum]; let point = [pointArr[random][0] * r, pointArr[random][1] * r]; treePoint.push(point); treeRotation.push(30 * random); numArr.splice(randomNum, 1); } return treeInfo; } getRandomPoint2(targetNum, r, existingRotation, angleRestriction) { let totalPointNum = 360 / angleRestriction; if (existingRotation.length > totalPointNum) return; let pointArr = []; for (let i = 0; i < totalPointNum; i++) { let angle = angleRestriction * i; let radian = Math.PI / 180 * angle; let pointX = Math.cos(radian) * r; let pointY = Math.sin(radian) * r; pointArr.push([pointX, pointY]); } let treeInfo = []; let treePoint = []; let treeRotation = []; treeInfo.push(treePoint); treeInfo.push(treeRotation); let curArr = []; for (let i = 0; i < existingRotation.length; i++) { let rotation2 = existingRotation[i] + 90; if (rotation2 >= 360) { rotation2 -= 360; } curArr.push(rotation2 / angleRestriction); } let numArr = []; for (let i = 0; i < totalPointNum; i++) { numArr.push(i); } for (let i = 0; i < curArr.length; i++) { for (let j = 0; j < numArr.length; j++) { if (curArr[i] == numArr[j]) { numArr.splice(j, 1); } } } if (numArr.length == 0) return; for (let i = 0; i < targetNum; i++) { let randomNum = Math.floor(Math.random() * numArr.length); let random = numArr[randomNum]; let point = [pointArr[random][0], pointArr[random][1]]; treePoint.push(point); let rotation2 = angleRestriction * random - 90; if (rotation2 < 0) { rotation2 += 360; } rotation2 = MathTool.angleBePositive(rotation2); treeRotation.push(rotation2); numArr.splice(randomNum, 1); } return treeInfo; } generatePlanet(planetNums) { let randomDirection = Math.round(Math.random()); for (let i = 0; i < planetNums.length; i++) { let planetNum = planetNums[i]; if (planetNum > 0) { for (let j = 0; j < planetNum; j++) { let planet = Laya.Pool.getItemByClass("Planet", Planet); planet.planetType = i; this.allPlanets.push(planet); } } } this.allPlanets = MathTool.shuffle(this.allPlanets); let planetTotalNum = this.planetsInfoAtCurLevel.planetTotalNum = this.allPlanets.length; if (planetTotalNum <= 3) { for (let i = 0; i < planetTotalNum; i++) { this.allPlanets[i].orbit = 0; this.planetsInfoAtCurLevel.innerRingPlanetNum = planetTotalNum; this.planetsInfoAtCurLevel.outerRingPlanetNum = 0; this.innerPlanets.push(this.allPlanets[i]); } } else if (planetTotalNum > 3) { for (let i = 0; i < planetTotalNum; i++) { if (i < 10) { let random = Math.round(Math.random()); let innerRingPlanetNum = this.planetsInfoAtCurLevel.innerRingPlanetNum; let outerRingPlanetNum = this.planetsInfoAtCurLevel.outerRingPlanetNum; if (innerRingPlanetNum >= 5) { this.allPlanets[i].orbit = 1; this.planetsInfoAtCurLevel.outerRingPlanetNum += 1; this.outerPlanets.push(this.allPlanets[i]); } else { if (random == 1) { if (outerRingPlanetNum + 1 > innerRingPlanetNum) { this.allPlanets[i].orbit = 0; this.planetsInfoAtCurLevel.innerRingPlanetNum += 1; this.innerPlanets.push(this.allPlanets[i]); } else { this.allPlanets[i].orbit = 1; this.planetsInfoAtCurLevel.outerRingPlanetNum += 1; this.outerPlanets.push(this.allPlanets[i]); } } else { this.allPlanets[i].orbit = 0; this.planetsInfoAtCurLevel.innerRingPlanetNum += 1; this.innerPlanets.push(this.allPlanets[i]); } } } else { this.leftoverPlanets.push(this.allPlanets[i]); } } } let innerNode = MainScene.sun.planetInnerRingNode; let outerNode = MainScene.sun.planetOuterRingNode; let innerRingPlanetNum = this.innerPlanets.length; let outerRingPlanetNum = this.outerPlanets.length; let InnerPlanetExistingRotation = this.getInnerPlanetExistingRotation(); let OuterPlanetExistingRotation = this.getInnerPlanetExistingRotation(); let pointInfo_innerRing = this.getRandomPoint(innerRingPlanetNum, innerNode.width / 2, InnerPlanetExistingRotation); let pointInfo_outerRing = this.getRandomPoint(outerRingPlanetNum, outerNode.width / 2, OuterPlanetExistingRotation); for (let i = 0; i < innerRingPlanetNum; i++) { let planet = this.innerPlanets[i]; planet.planetInit(); innerNode.addChild(planet); planet.rotationSun = pointInfo_innerRing[1][i]; planet.radian = Math.PI / 180 * pointInfo_innerRing[1][i]; planet.revolveCenterDistance = MainScene.sun.planetInnerRing.width / 2; planet.revolvedirection = (randomDirection == 0) ? 1 : -1; planet.pos(planet.revolveCenter[0] + Math.cos(planet.angle) * planet.revolveCenterDistance, planet.revolveCenter[1] + Math.sin(planet.angle) * planet.revolveCenterDistance); } for (let i = 0; i < outerRingPlanetNum; i++) { let planet = this.outerPlanets[i]; planet.planetInit(); outerNode.addChild(planet); planet.rotationSun = pointInfo_outerRing[1][i]; planet.radian = Math.PI / 180 * pointInfo_outerRing[1][i]; planet.revolveCenterDistance = MainScene.sun.planetOuterRing.width / 2; planet.revolvedirection = (randomDirection == 0) ? -1 : 1; planet.pos(planet.revolveCenter[0] + Math.cos(planet.angle) * planet.revolveCenterDistance, planet.revolveCenter[1] + Math.sin(planet.angle) * planet.revolveCenterDistance); } let sun = MainScene.sun; if (this.innerPlanets.length > 0) { sun.planetInnerRingNode.visible = true; Laya.Tween.to(sun.planetInnerRingNode, { alpha: 1 }, 500); } if (this.outerPlanets.length > 0) { sun.planetOuterRingNode.visible = true; Laya.Tween.to(sun.planetOuterRingNode, { alpha: 1 }, 500); } } planetBReplaceA(planetA) { if (this.leftoverPlanets.length <= 0) return; let planetB = this.leftoverPlanets[0]; this.leftoverPlanets.splice(0, 1); planetB.orbit = planetA.orbit; planetB.planetInit(); planetA.parent.addChild(planetB); planetB.radian = planetA.radian; planetB.revolveCenterDistance = planetA.revolveCenterDistance; planetB.revolvedirection = planetA.revolvedirection; planetB.pos(planetA.x, planetA.y); switch (planetB.orbit) { case 0: this.innerPlanets.push(planetB); break; case 1: this.outerPlanets.push(planetB); break; default: break; } return planetB; } getGeneratePlanetNums() { let planetNums = [0, 0, 0, 0, 0]; let levelNum = this.curLevel; let isBossLevel = levelNum % 5; let bossLevelPlanetNum = Math.floor(levelNum / 5); if (levelNum <= 34) { if (isBossLevel == 0) { if (levelNum == 30) { bossLevelPlanetNum = 5; } for (let i = 0; i < bossLevelPlanetNum; i++) { planetNums[i] = 1; } } else { if (levelNum <= 4 || levelNum == 6 || levelNum == 7) { planetNums = [0, 0, 0, 0, 0]; } else if (levelNum == 8 || levelNum == 9) { planetNums = [1, 0, 0, 0, 0]; } else if (levelNum >= 11 && levelNum < 25) { let targetPlanetNum = bossLevelPlanetNum - 1; planetNums = this.getPlanetFromUnloackedPlanet(targetPlanetNum, bossLevelPlanetNum); } else if (levelNum >= 26 && levelNum <= 29) { planetNums = this.getPlanetFromUnloackedPlanet(3, 5); } else if (levelNum >= 31 && levelNum <= 34) { planetNums = this.getPlanetFromUnloackedPlanet(4, 5); } } } else if (levelNum >= 35 && levelNum <= 59) { if (isBossLevel == 0) { planetNums = this.getPlanetFromUnloackedPlanet(6, 5); } else { planetNums = [1, 1, 1, 1, 1]; } } else { if (isBossLevel == 0) { let targetPlanetNum = Math.floor((this.curLevel - 60) / 30) + 7; planetNums = this.getPlanetFromUnloackedPlanet(targetPlanetNum, 5); } else { let targetPlanetNum = Math.floor((this.curLevel - 60) / 30) + 6; planetNums = this.getPlanetFromUnloackedPlanet(targetPlanetNum, 5); } } return planetNums; } getPlanetFromUnloackedPlanet(targetPlanetNum, unlockedPlanetNum) { let planetNums = [0, 0, 0, 0, 0]; let unlockedPlanetArr = []; for (let i = 0; i < unlockedPlanetNum; i++) { unlockedPlanetArr[i] = i; } for (let i = 0; i < targetPlanetNum; i++) { if (unlockedPlanetArr.length == 0) { for (let i = 0; i < unlockedPlanetNum; i++) { unlockedPlanetArr[i] = i; } } let a = Math.random(); let b = a * unlockedPlanetArr.length; let c = Math.floor(b); planetNums[unlockedPlanetArr[c]] += 1; unlockedPlanetArr.splice(c, 1); } return planetNums; } checkNewPlanet() { let planet = 0; if (this.curLevel <= 25 && this.curLevel % 5 == 0) { planet = this.curLevel / 5; } return planet; } levelStart() { let levelNum = MainScene.gameControl.maxLevel + 1; MainScene.instance.updateGameState(2); this.isStartGame = true; if (this.curBeReadyKnife) { this.curBeReadyKnife.alpha = 0; this.curBeReadyKnife.removeSelf(); Laya.Pool.recover("Knife", this.curBeReadyKnife); } this.clearCurKnifeArr(); let startFun = function () { let gamecontrol = MainScene.gameControl; gamecontrol.curLevel = levelNum; gamecontrol.knifeRestNum = gamecontrol.knifeInfo.knifeTotalNum; gamecontrol.bindToSunKnifeArr = []; gamecontrol.bindToSunTreeArr = []; gamecontrol.planetsInfoAtCurLevel.innerRingPlanetNum = 0; gamecontrol.planetsInfoAtCurLevel.outerRingPlanetNum = 0; gamecontrol.allPlanets = []; gamecontrol.innerPlanets = []; gamecontrol.outerPlanets = []; gamecontrol.leftoverPlanets = []; gamecontrol.coinNumFromCurLevel = 0; gamecontrol.reviveChance = 1; gamecontrol.propInvincibleRocketNum = 0; gamecontrol.propInvincibleRocketTotalNum = 0; gamecontrol.launchRocketTag = 1; MainScene.instance.dialog_freelyGetProp.init(); MainScene.sun.shieldBlood = 0; gamecontrol.updateGameUI(); if (gamecontrol.nextChangeDirLevel <= gamecontrol.curLevel) { let levelNum = Math.ceil(Math.random() * 3) + gamecontrol.curLevel; gamecontrol.nextChangeDirLevel = levelNum; MainScene.sun.sunRotateDirection = -MainScene.sun.sunRotateDirection; } let treeNum = gamecontrol.getTreesNum(); if (treeNum > 0) gamecontrol.generateTrees(treeNum); let planetNums = gamecontrol.getGeneratePlanetNums(); let planetType = gamecontrol.checkNewPlanet(); if (planetType >= 1 && planetType <= 5) { let dialogUnlockPlanet = MainScene.instance.dialog_unlockPlanet; dialogUnlockPlanet.planetIcon.loadImage(gamecontrol.planetsInfo[planetType - 1].url); dialogUnlockPlanet.planetIcon.width = dialogUnlockPlanet.planetIcon.texture.width; dialogUnlockPlanet.planetIcon.height = dialogUnlockPlanet.planetIcon.texture.height; dialogUnlockPlanet.planetIcon.pivotX = dialogUnlockPlanet.planetIcon.width / 2; dialogUnlockPlanet.planetIcon.pivotY = dialogUnlockPlanet.planetIcon.height / 2; dialogUnlockPlanet.planetIcon.pos(0, 0); dialogUnlockPlanet.planetName.text = gamecontrol.planetsInfo[planetType - 1].name; dialogUnlockPlanet.planetSkill.text = gamecontrol.planetsInfo[planetType - 1].skill; dialogUnlockPlanet.show(); } Laya.timer.once(500, gamecontrol, () => { gamecontrol.generatePlanet(planetNums); }); Laya.timer.once(100, gamecontrol, function () { MainScene.instance.touchArea.on(Laya.Event.MOUSE_DOWN, gamecontrol, gamecontrol.onGameStageClick); }); MainScene.sun.levelInit(); gamecontrol.attackSunTime = Laya.Browser.now(); Laya.timer.loop(1000, gamecontrol, gamecontrol.checkSunAttack); }; PlatfromContro.hideBanner(); AnimationControl.startGameBtnAni(); Laya.timer.once(1000, this, function () { startFun(); AnimationControl.gameUIMoveIn(); }); } levelStartInGame() { let levelNum = MainScene.gameControl.maxLevel + 1; MainScene.instance.updateGameState(2); this.isStartGame = true; if (this.curBeReadyKnife) { this.curBeReadyKnife.alpha = 0; this.curBeReadyKnife.removeSelf(); Laya.Pool.recover("Knife", this.curBeReadyKnife); } this.clearCurKnifeArr(); let startFun = function () { let gamecontrol = MainScene.gameControl; gamecontrol.curLevel = levelNum; gamecontrol.knifeRestNum = gamecontrol.knifeInfo.knifeTotalNum; gamecontrol.bindToSunKnifeArr = []; gamecontrol.bindToSunTreeArr = []; gamecontrol.planetsInfoAtCurLevel.innerRingPlanetNum = 0; gamecontrol.planetsInfoAtCurLevel.outerRingPlanetNum = 0; gamecontrol.allPlanets = []; gamecontrol.innerPlanets = []; gamecontrol.outerPlanets = []; gamecontrol.leftoverPlanets = []; gamecontrol.coinNumFromCurLevel = 0; gamecontrol.reviveChance = 1; gamecontrol.propInvincibleRocketNum = 0; gamecontrol.propInvincibleRocketTotalNum = 0; gamecontrol.launchRocketTag = 1; MainScene.instance.dialog_freelyGetProp.init(); MainScene.sun.shieldBlood = 0; gamecontrol.updateGameUI(); if (gamecontrol.nextChangeDirLevel <= gamecontrol.curLevel) { let levelNum = Math.ceil(Math.random() * 3) + gamecontrol.curLevel; gamecontrol.nextChangeDirLevel = levelNum; MainScene.sun.sunRotateDirection = -MainScene.sun.sunRotateDirection; } let treeNum = gamecontrol.getTreesNum(); if (treeNum > 0) gamecontrol.generateTrees(treeNum); let planetNums = gamecontrol.getGeneratePlanetNums(); let planetType = gamecontrol.checkNewPlanet(); if (planetType >= 1 && planetType <= 5) { let dialogUnlockPlanet = MainScene.instance.dialog_unlockPlanet; dialogUnlockPlanet.planetIcon.loadImage(gamecontrol.planetsInfo[planetType - 1].url); dialogUnlockPlanet.planetIcon.width = dialogUnlockPlanet.planetIcon.texture.width; dialogUnlockPlanet.planetIcon.height = dialogUnlockPlanet.planetIcon.texture.height; dialogUnlockPlanet.planetIcon.pivotX = dialogUnlockPlanet.planetIcon.width / 2; dialogUnlockPlanet.planetIcon.pivotY = dialogUnlockPlanet.planetIcon.height / 2; dialogUnlockPlanet.planetIcon.pos(0, 0); dialogUnlockPlanet.planetName.text = gamecontrol.planetsInfo[planetType - 1].name; dialogUnlockPlanet.planetSkill.text = gamecontrol.planetsInfo[planetType - 1].skill; dialogUnlockPlanet.show(); } Laya.timer.once(500, gamecontrol, () => { gamecontrol.generatePlanet(planetNums); }); Laya.timer.once(100, gamecontrol, function () { MainScene.instance.touchArea.on(Laya.Event.MOUSE_DOWN, gamecontrol, gamecontrol.onGameStageClick); }); MainScene.sun.levelInit(); gamecontrol.attackSunTime = Laya.Browser.now(); Laya.timer.loop(1000, gamecontrol, gamecontrol.checkSunAttack); }; startFun(); } checkSunAttack() { let curTime = Laya.Browser.now(); if ((curTime - this.attackSunTime) / 1000 >= 5) { if (this.isStartGame == true) { MainScene.sun.switchEmoji(3); } } } stopGame() { MainScene.instance.updateGameState(3); this.isStartGame = false; this.launchRocketTag = 1; this.clearCurKnifeArr(); Laya.timer.clear(this, this.checkSunAttack); if (this.curBeReadyKnife) { this.curBeReadyKnife.removeSelf(); Laya.Pool.recover("Knife", this.curBeReadyKnife); this.curBeReadyKnife = null; } } levelOver() { this.stopGame(); Laya.timer.clear(this, MainScene.sun.checkBlood); let knifeNum = this.bindToSunKnifeArr.length; for (let i = 0; i < knifeNum; i++) { this.bindToSunKnifeArr[0].alpha = 0; this.bindToSunKnifeArr[0].knifeImg.alpha = 0; this.bindToSunKnifeArr[0].removeSelf(); Laya.Pool.recover("Knife", this.bindToSunKnifeArr[0]); MainScene.gameControl.bindToSunKnifeArr.splice(0, 1); } let treeNum = this.bindToSunTreeArr.length; for (let i = 0; i < treeNum; i++) { this.bindToSunTreeArr[0].removeSelf(); Laya.Pool.recover("Tree", this.bindToSunTreeArr[0]); MainScene.gameControl.bindToSunTreeArr.splice(0, 1); } Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.onGameStageClick); for (let i = this.innerPlanets.length - 1; i >= 0; i--) { let planet = this.innerPlanets[i]; planet.die(null, 1); planet.removeSelf(); Laya.Pool.recover("Planet", planet); Laya.timer.clear(planet, planet.rotate); MainScene.gameControl.innerPlanets.splice(i, 1); } for (let i = this.outerPlanets.length - 1; i >= 0; i--) { let planet = this.outerPlanets[i]; planet.die(null, 1); planet.removeSelf(); Laya.Pool.recover("Planet", planet); Laya.timer.clear(planet, planet.rotate); MainScene.gameControl.outerPlanets.splice(i, 1); } Laya.timer.clear(this, this.checkSunAttack); MainScene.sun.stopShieldAni(); MainScene.sun.gameover_clearAnimation(); } levelFailed() { this.stopGame(); this.clearCurKnifeArr(); this.launchRocketTag = 1; let fun = function () { MusicControl.gameFailed(); this.levelFailedHasNoReviveChance(); }; let percent = MainScene.sun.getPercentOfBlood(); if (percent > 0.5) { MainScene.sun.switchEmoji(5); Laya.timer.once(1000, this, fun); } else { MainScene.sun.switchEmoji(6); Laya.timer.once(1000, this, fun); } if (LibData.getGameMode()) { BannerAd.showBannerAd(); } } levelFailedHasReviveChance() { this.stopGame(); MainScene.instance.gameOverUI.show_failedRevive(); } levelFailedHasNoReviveChance() { this.stopGame(); MainScene.instance.gameOverUI.show_failedRePlay(); } revive() { this.attackSunTime = Laya.Browser.now(); Laya.timer.loop(1000, this, this.checkSunAttack); this.launchRocketTag = 0; if (this.curBeReadyKnife) { this.curBeReadyKnife.alpha = 0; this.curBeReadyKnife.removeSelf(); Laya.Pool.recover("Knife", this.curBeReadyKnife); } this.isStartGame = true; this.reviveAni(); } reviveAni_callback() { let gameControl = MainScene.gameControl; gameControl.propInvincibleRocketNum += 7; gameControl.propInvincibleRocketTotalNum += 7; MainScene.sun.subBlood(MainScene.sun.curBlood * 0.5); let knifeNum = gameControl.bindToSunKnifeArr.length; let treeNum = gameControl.bindToSunTreeArr.length; if (knifeNum + treeNum <= 10) { gameControl.removeKnifeFromSun(knifeNum); gameControl.removeTreeFromSun(treeNum); } else { let knifeP = knifeNum / (knifeNum + treeNum); let knifeSubNum = Math.floor(10 * knifeP); let treeSubNum = 10 - knifeSubNum; gameControl.removeKnifeFromSun(knifeSubNum); gameControl.removeTreeFromSun(treeSubNum); } gameControl.createKnife(); gameControl.updateGameUI(); } reviveAni(callback) { let aknifeSP = Laya.Pool.getItemByClass("aknifeSP", Laya.Sprite); aknifeSP.loadImage("texture/GameScene/invincibleRocket.png"); aknifeSP.pivot(aknifeSP.width / 2, 0); let startY = MainScene.instance.exampleKnife.y; aknifeSP.pos(Laya.stage.width / 2, startY); MainScene.instance.KnifeBox.addChild(aknifeSP); let tp = new Laya.Point(MainScene.sun.sunNode.x, MainScene.sun.sunNode.y + MyConsts.knifeToSunCenter); tp = MainScene.sun.localToGlobal(tp); tp = MainScene.instance.KnifeBox.globalToLocal(tp); let targetY = tp.y; Laya.Tween.to(aknifeSP, { y: targetY }, 200, null, Laya.Handler.create(this, function () { aknifeSP.removeSelf(); Laya.Pool.recover("aknifeSP", aknifeSP); AnimationControl.reviveFireAni(MainScene.gameControl.reviveAni_callback); })); } levelSuccessful() { let addCoinNum = 1.5 * (2 * Math.pow(MainScene.gameControl.curLevel, 2) + 10 * MainScene.gameControl.curLevel + 10 * MainScene.gameControl.coinInfo.coinValue); MainScene.gameControl.coinNumFromCurLevel += Math.floor(addCoinNum); MainScene.gameControl.updateGameUI(); MainScene.gameControl.isStartGame = false; MainScene.sun.switchEmoji(7); MainScene.sun.clearRift(); let completeEvent = function () { if (MainScene.gameControl.curLevel > MainScene.gameControl.maxLevel) { let curLevel = MainScene.gameControl.curLevel; MainScene.gameControl.setMaxLevel(curLevel); if (curLevel == 10) { MainScene.gameControl.critSystemInit(); } else if (curLevel == 5) { MainScene.gameControl.coinSystemInit(); MainScene.instance.coinDailyIncomeControl.init(); MainScene.instance.coinProfit.visible = true; } } MainScene.instance.gameOverUI.show_success(); MusicControl.gameSuccess(); }; AnimationControl.sunDieAni(completeEvent, 1000); if (LibData.getGameMode()) { BannerAd.showBannerAd(); } } updateGameUI() { let instance = MainScene.instance; instance.text_levelNum.text = this.curLevel.toString(); if (this.propInvincibleRocketNum > 0) { instance.invincibleRocketNum.visible = true; instance.text_invincibleRocketNum.text = this.propInvincibleRocketNum + "/" + this.propInvincibleRocketTotalNum; } else { instance.invincibleRocketNum.visible = false; } instance.text_rocketNum.text = this.knifeRestNum + "/" + this.knifeInfo.knifeTotalNum; let coinStr = MathTool.currencyUnit(this.coinNumFromCurLevel); instance.text_coinNumFromCurLevel.text = coinStr; MainScene.sun.updateUI(); } updateHomeUI() { let instance = MainScene.instance; let coinStr = MathTool.currencyUnit(this.holdCoinsNum); instance.text_holdCoinsNum.text = coinStr; let strengthStr = MathTool.currencyUnit(this.holdStrengthNum); instance.text_holdStrengthNum.text = strengthStr; let maxLevelNum = MainScene.gameControl.maxLevel; if (maxLevelNum && maxLevelNum > 0) { instance.sp_lastPassedLevelNum.visible = true; instance.text_lastPassedLevelNum.text = MainScene.gameControl.maxLevel + ""; } else { instance.sp_lastPassedLevelNum.visible = false; } instance.text_lastPassedLevelNum.text = MainScene.gameControl.maxLevel + ""; instance.text_currentUnlockedLevelNum.text = MainScene.gameControl.maxLevel + 1 + ""; instance.text_nextLockedLevelNum.text = MainScene.gameControl.maxLevel + 2 + ""; instance.text_lastPassedLevelNum.pivotX = instance.text_lastPassedLevelNum.width / 2; instance.text_currentUnlockedLevelNum.pivotX = instance.text_currentUnlockedLevelNum.width / 2; instance.text_nextLockedLevelNum.pivotX = instance.text_nextLockedLevelNum.width / 2; instance.text_knifeNumGrade.text = "[lv" + this.knifeInfo.knifeNumGrade + "]"; instance.text_knifeNum.text = "" + this.knifeInfo.knifeTotalNum; let knifeUpgradeNumNeedCoinsStr = MathTool.currencyUnit(this.knifeInfo.knifeUpgradeNumNeedCoins); instance.text_knifeUpgradeNumNeedCoins.text = knifeUpgradeNumNeedCoinsStr; instance.text_knifeAttackGrade.text = "[lv" + this.knifeInfo.knifeAttackGrade + "]"; let knifeAttackStr = MathTool.currencyUnit(this.knifeInfo.knifeAttack); instance.text_knifeAttack.text = knifeAttackStr; let knifeUpgradeAttackNeedCoinsStr = MathTool.currencyUnit(this.knifeInfo.knifeUpgradeAttackNeedCoins); instance.text_knifeUpgradeAttackNeedCoins.text = knifeUpgradeAttackNeedCoinsStr; let upgradeTip = false; if (this.holdCoinsNum < this.knifeInfo.knifeUpgradeNumNeedCoins) { instance.btn_knifeUpgradeNumNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } else { instance.btn_knifeUpgradeNumNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png"; } if (this.holdCoinsNum < this.knifeInfo.knifeUpgradeAttackNeedCoins) { instance.btn_knifeUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } else { instance.btn_knifeUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png"; } if (this.knifeInfo.knifeNumGrade < MyConsts.growSystemGradeLimit.knifeNum && this.holdCoinsNum >= this.knifeInfo.knifeUpgradeNumNeedCoins) { upgradeTip = true; } if (this.knifeInfo.knifeAttackGrade < MyConsts.growSystemGradeLimit.knifeAttack && this.holdCoinsNum >= this.knifeInfo.knifeUpgradeAttackNeedCoins) { upgradeTip = true; } if (this.knifeInfo.knifeNumGrade >= MyConsts.growSystemGradeLimit.knifeNum && this.knifeInfo.knifeAttackGrade >= MyConsts.growSystemGradeLimit.knifeAttack) { upgradeTip = false; } if (MainScene.gameControl.getMaxLevel() < 1) { upgradeTip = false; } instance.upgradeTip_knife.visible = upgradeTip; instance.text_critChanceGrade.text = "[lv" + this.critInfo.critChanceGrade + "]"; instance.text_critChance.text = this.critInfo.critChance + "%"; let critUpgradeChanceNeedCoinsStr = MathTool.currencyUnit(this.critInfo.critUpgradeChanceNeedCoins); instance.text_critUpgradeChanceNeedCoins.text = critUpgradeChanceNeedCoinsStr; instance.text_critAttackGrade.text = "[lv" + this.critInfo.critAttackGrade + "]"; instance.text_critAttack.text = "" + this.critInfo.critAttack + "倍"; let critUpgradeAttackNeedCoinsStr = MathTool.currencyUnit(this.critInfo.critUpgradeAttackNeedCoins); instance.text_critUpgradeAttackNeedCoins.text = critUpgradeAttackNeedCoinsStr; upgradeTip = false; if (this.holdCoinsNum < this.critInfo.critUpgradeChanceNeedCoins) { instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } else { instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png"; } if (this.holdCoinsNum < this.critInfo.critUpgradeAttackNeedCoins) { instance.btn_critUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } else { instance.btn_critUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png"; } if (this.critInfo.critChanceGrade < MyConsts.growSystemGradeLimit.critChance && this.holdCoinsNum >= this.critInfo.critUpgradeChanceNeedCoins) { upgradeTip = true; } if (this.critInfo.critAttackGrade < MyConsts.growSystemGradeLimit.critAttack && this.holdCoinsNum >= this.critInfo.critUpgradeAttackNeedCoins) { upgradeTip = true; } if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance && this.critInfo.critAttackGrade >= MyConsts.growSystemGradeLimit.critAttack) { upgradeTip = false; } if (this.maxLevel < 10) upgradeTip = false; instance.upgradeTip_crit.visible = upgradeTip; instance.text_coinValueGrade.text = "[lv" + this.coinInfo.coinValueGrade + "]"; let coinValueStr = MathTool.currencyUnit(this.coinInfo.coinValue); instance.text_coinValue.text = coinValueStr; let coinUpgradeValueNeedCoinsStr = MathTool.currencyUnit(this.coinInfo.coinUpgradeValueNeedCoins); instance.text_coinUpgradeValueNeedCoins.text = coinUpgradeValueNeedCoinsStr; instance.text_coinProfitGrade.text = "[lv" + this.coinInfo.coinProfitGrade + "]"; let coinProfitStr = MathTool.currencyUnit(this.coinInfo.coinProfit); instance.text_coinProfit.text = coinProfitStr; let coinUpgradeProfitNeedCoinsStr = MathTool.currencyUnit(this.coinInfo.coinUpgradeProfitNeedCoins); instance.text_coinUpgradeProfitNeedCoins.text = coinUpgradeProfitNeedCoinsStr; upgradeTip = false; if (this.holdCoinsNum < this.coinInfo.coinUpgradeValueNeedCoins) { instance.btn_coinUpgradeValueNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } else { instance.btn_coinUpgradeValueNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png"; } if (this.holdCoinsNum < this.coinInfo.coinUpgradeProfitNeedCoins) { instance.btn_coinUpgradeProfitNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } else { instance.btn_coinUpgradeProfitNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png"; } if (this.coinInfo.coinValueGrade < MyConsts.growSystemGradeLimit.coinValue && this.holdCoinsNum >= this.coinInfo.coinUpgradeValueNeedCoins) { upgradeTip = true; } if (this.coinInfo.coinProfitGrade < MyConsts.growSystemGradeLimit.coinProfit && this.holdCoinsNum >= this.coinInfo.coinUpgradeProfitNeedCoins) { upgradeTip = true; } if (this.coinInfo.coinValueGrade >= MyConsts.growSystemGradeLimit.coinValue && this.coinInfo.coinProfitGrade >= MyConsts.growSystemGradeLimit.coinProfit) { upgradeTip = false; } if (this.maxLevel < 20) upgradeTip = false; instance.upgradeTip_coin.visible = upgradeTip; this.updateGrowSystemUI(); } checkNewPlayer() { if (this.maxLevel == 1 && this.newPlayerTag == 0) { MainScene.instance.updateGameState(3); this.newPlayerTag = 1; let instance = MainScene.instance; instance.tipBox.visible = true; let knifeBtn = instance.btn_knifeSystem; let btnKnifePoint = knifeBtn.localToGlobal(new Laya.Point(knifeBtn.width / 2, knifeBtn.height / 2)); instance.tipBoxMask.pos(btnKnifePoint.x + 15, btnKnifePoint.y); let point1 = instance.tipBoxMask.localToGlobal(new Laya.Point(50, 20)); this.fingerAni.pos(point1.x, point1.y); this.fingerAni.visible = true; instance.tipBoxMask.on(Laya.Event.MOUSE_DOWN, this, function () { let upgradeBtn = instance.btn_knifeUpgradeAttackNeedCoins; let btnUpgradePoint = upgradeBtn.localToGlobal(new Laya.Point(upgradeBtn.width / 2, upgradeBtn.height / 2)); instance.tipBoxMask.pos(btnUpgradePoint.x - 35, btnUpgradePoint.y + 10); instance.tipBoxMask.width = upgradeBtn.width; instance.tipBoxMask.height = upgradeBtn.height; instance.showKnifeSystemUI(); let point2 = instance.btn_knifeUpgradeAttackNeedCoins.localToGlobal(new Laya.Point(100, 0)); this.fingerAni.pos(point2.x, point2.y); Laya.timer.once(100, this, function () { instance.tipBoxMask.on(Laya.Event.MOUSE_DOWN, this, function () { instance.onKnifeUpgradeAttackNeedCoinsClick(); this.fingerAni.visible = false; instance.tipBox.visible = false; MainScene.instance.updateGameState(1); upgradeBtn.scale(1, 1); Laya.Tween.to(upgradeBtn, { scaleX: 0.8, scaleY: 0.8 }, 50); Laya.timer.once(50, this, function () { Laya.Tween.to(upgradeBtn, { scaleX: 1, scaleY: 1 }, 600); }); MusicControl.btnClick(); }); }); }); } } checkLastKnifeAttack() { let sun = MainScene.sun; let gameControl = MainScene.gameControl; let attack = gameControl.knifeInfo.knifeAttack; if (attack < (sun.curBlood + sun.shieldBlood)) { let instance = MainScene.instance; let prop = instance.prop_rocket; let point1 = prop.localToGlobal(new Laya.Point(prop.width / 2, prop.height / 2)); gameControl.fingerAni.pos(point1.x + 45, point1.y - 80); gameControl.fingerAni.visible = true; gameControl.fingerAni.scaleX = -1; instance.tipBoxMask.pos(point1.x + 40, point1.y - 5); instance.tipBoxMask.width = prop.width + 20; instance.tipBoxMask.height = prop.height + 20; instance.tipBox.visible = true; instance.tipBoxMask.on(Laya.Event.MOUSE_DOWN, gameControl, function () { gameControl.onRocketClick(); gameControl.fingerAni.destroy(); instance.tipBox.destroy(); gameControl.setPropTeach(true); }); } } updateGrowSystemUI() { let instance = MainScene.instance; if (this.knifeInfo.knifeNumGrade >= MyConsts.growSystemGradeLimit.knifeNum) { instance.btn_knifeUpgradeNumNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; instance.text_knifeUpgradeNumNeedCoins.text = "MAX"; } if (this.knifeInfo.knifeAttackGrade >= MyConsts.growSystemGradeLimit.knifeAttack) { instance.btn_knifeUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; instance.text_knifeUpgradeAttackNeedCoins.text = "MAX"; } if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance) { instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; instance.text_critUpgradeChanceNeedCoins.text = "MAX"; } if (this.critInfo.critAttackGrade >= MyConsts.growSystemGradeLimit.critAttack) { instance.btn_critUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; instance.text_critUpgradeAttackNeedCoins.text = "MAX"; } if (this.coinInfo.coinValueGrade >= MyConsts.growSystemGradeLimit.coinValue) { instance.btn_coinUpgradeValueNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; instance.text_coinUpgradeValueNeedCoins.text = "MAX"; } if (this.coinInfo.coinProfitGrade >= MyConsts.growSystemGradeLimit.coinProfit) { instance.btn_coinUpgradeProfitNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; instance.text_coinUpgradeProfitNeedCoins.text = "MAX"; } } upGradeKnifeNum() { if (this.holdCoinsNum < this.knifeInfo.knifeUpgradeNumNeedCoins) { if (this.maxLevel >= 5) { MainScene.instance.dialog_speedUpCoinProfit.show(); } return; } if (this.knifeInfo.knifeNumGrade >= MyConsts.growSystemGradeLimit.knifeNum) return; this.holdCoinsNum -= this.knifeInfo.knifeUpgradeNumNeedCoins; this.setHoldCoinsNum(this.holdCoinsNum); this.knifeInfo.knifeNumGrade += 1; this.knifeInfo.knifeTotalNum += 1; this.knifeInfo.knifeUpgradeNumNeedCoins += (65 * this.knifeInfo.knifeNumGrade); this.setKnifeInfo(this.knifeInfo); this.updateHomeUI(); if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance) { MainScene.instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } } upGradeKnifeAttack() { if (this.holdCoinsNum < this.knifeInfo.knifeUpgradeAttackNeedCoins) { if (this.maxLevel >= 5) { MainScene.instance.dialog_speedUpCoinProfit.show(); } return; } if (this.knifeInfo.knifeAttackGrade >= MyConsts.growSystemGradeLimit.knifeAttack) return; this.holdCoinsNum -= this.knifeInfo.knifeUpgradeAttackNeedCoins; this.setHoldCoinsNum(this.holdCoinsNum); this.knifeInfo.knifeAttackGrade += 1; this.knifeInfo.knifeAttack += (10 * this.knifeInfo.knifeAttackGrade); this.knifeInfo.knifeUpgradeAttackNeedCoins += (35 * this.knifeInfo.knifeAttackGrade); this.setKnifeInfo(this.knifeInfo); this.updateHomeUI(); if (this.knifeInfo.knifeAttackGrade >= MyConsts.growSystemGradeLimit.knifeAttack) { MainScene.instance.btn_knifeUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } } upGradeCritAttack() { if (this.holdCoinsNum < this.critInfo.critUpgradeAttackNeedCoins) { if (this.maxLevel >= 5) { MainScene.instance.dialog_speedUpCoinProfit.show(); } return; } if (this.critInfo.critAttackGrade >= MyConsts.growSystemGradeLimit.critAttack) return; this.holdCoinsNum -= this.critInfo.critUpgradeAttackNeedCoins; this.setHoldCoinsNum(this.holdCoinsNum); this.critInfo.critAttackGrade += 1; this.critInfo.critAttack = Math.round((4 * this.critInfo.critAttackGrade / (this.critInfo.critAttackGrade + 6) - 0.57) * 100) / 100; this.critInfo.critUpgradeAttackNeedCoins = 15 * this.critInfo.critAttackGrade; this.setCritInfo(this.critInfo); this.updateHomeUI(); if (this.critInfo.critAttackGrade >= MyConsts.growSystemGradeLimit.critAttack) { MainScene.instance.btn_critUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } } upGradeCritChance() { if (this.holdCoinsNum < this.critInfo.critUpgradeChanceNeedCoins) { if (this.maxLevel >= 5) { MainScene.instance.dialog_speedUpCoinProfit.show(); } return; } if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance) return; this.holdCoinsNum -= this.critInfo.critUpgradeChanceNeedCoins; this.setHoldCoinsNum(this.holdCoinsNum); this.critInfo.critChanceGrade += 1; this.critInfo.critChance = Math.round((this.critInfo.critChanceGrade / (3 * this.critInfo.critChanceGrade + 50)) * 10000) / 100; this.critInfo.critUpgradeChanceNeedCoins = 35 * this.critInfo.critChanceGrade; this.setCritInfo(this.critInfo); this.updateHomeUI(); if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance) { MainScene.instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } } upGradeCoinValue() { if (this.holdCoinsNum < this.coinInfo.coinUpgradeValueNeedCoins) { if (this.maxLevel >= 5) { MainScene.instance.dialog_speedUpCoinProfit.show(); } return; } if (this.coinInfo.coinValueGrade >= MyConsts.growSystemGradeLimit.coinValue) return; this.holdCoinsNum -= this.coinInfo.coinUpgradeValueNeedCoins; this.setHoldCoinsNum(this.holdCoinsNum); this.coinInfo.coinValueGrade += 1; this.coinInfo.coinValue += 2; this.coinInfo.coinUpgradeValueNeedCoins += 75; this.setCoinInfo(this.coinInfo); this.updateHomeUI(); if (this.coinInfo.coinValueGrade >= MyConsts.growSystemGradeLimit.coinValue) { MainScene.instance.btn_coinUpgradeValueNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } } upGradeCoinProfit() { if (this.holdCoinsNum < this.coinInfo.coinUpgradeProfitNeedCoins) { if (this.maxLevel >= 5) { MainScene.instance.dialog_speedUpCoinProfit.show(); } return; } if (this.coinInfo.coinProfitGrade >= MyConsts.growSystemGradeLimit.coinProfit) return; this.holdCoinsNum -= this.coinInfo.coinUpgradeProfitNeedCoins; this.setHoldCoinsNum(this.holdCoinsNum); this.coinInfo.coinProfitGrade += 1; this.coinInfo.coinProfit += 2; this.coinInfo.coinUpgradeProfitNeedCoins += 63; this.setCoinInfo(this.coinInfo); this.updateHomeUI(); if (this.coinInfo.coinProfitGrade >= MyConsts.growSystemGradeLimit.coinProfit) { MainScene.instance.btn_coinUpgradeProfitNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png"; } } removeKnifeFromSun(knifeNum) { for (let i = 0; i < knifeNum; i++) { if (this.bindToSunKnifeArr[i]) { let gameControl = MainScene.gameControl; let knife = gameControl.bindToSunKnifeArr[i]; AnimationControl.blowUpObstacle(knife); Laya.Tween.to(knife.knifeImg, { alpha: 0 }, 300); } } let gameControl = MainScene.gameControl; Laya.timer.once(300, gameControl, function () { for (let j = 0; j < knifeNum; j++) { let knife = gameControl.bindToSunKnifeArr[0]; knife.alpha = 0; knife.removeSelf(); Laya.Pool.recover("Knife", knife); gameControl.bindToSunKnifeArr.splice(0, 1); this.clearCurKnifeArr(); } }); } removeTreeFromSun(treeNum) { if (treeNum < 1) return; for (let i = 0; i < treeNum; i++) { if (this.bindToSunTreeArr[i]) { let tree = this.bindToSunTreeArr[i]; AnimationControl.blowUpObstacle(tree); } } let gameControl = MainScene.gameControl; Laya.timer.once(300, gameControl, function () { for (let j = 0; j < treeNum; j++) { let tree = gameControl.bindToSunTreeArr[0]; if (tree) { tree.removeSelf(); Laya.Pool.recover("Tree", tree); gameControl.bindToSunTreeArr.splice(0, 1); } } }); } addTree(treePoint) { let newTree = this.generateTrees(1, treePoint); if (!newTree) return; for (let i = 0; i < newTree.length; i++) { AnimationControl.planet_Jupiter_addTree(newTree[i]); } } checkKnifeCrit(knife, parent, pos, scale) { let knifeAttack = knife.attack; let critChance = this.critInfo.critChance / 100; let random = Math.random(); if (random <= critChance && this.critInfo.critAttack > 0) { knifeAttack = knife.attack * this.critInfo.critAttack; let attackNum = Math.floor(knifeAttack) + ""; AnimationControl.playCritNumAni(attackNum, parent, pos, scale); } else { let attackNum = Math.floor(knife.attack) + ""; AnimationControl.playSubBloodNumAni(attackNum, parent, pos, scale); } return knifeAttack; } getPlayCount() { return Data.getPlayCount(); } setPlayCount(value) { this.playCount = value; Data.setPlayCount(value); } getMaxLevel() { return Data.getMaxScore(); } setMaxLevel(value) { this.maxLevel = value; Data.setMaxScore(value); } getHoldCoinsNum() { return Data.getHoldCoinsNum(); } setHoldCoinsNum(value) { this.holdCoinsNum = value; Data.setHoldCoinsNum(value); } getHoldStrengthNum() { return Data.getHoldStrengthNum(); } setHoldStrengthNum(value) { this.holdStrengthNum = value; Data.setHoldStrengthNum(value); } getKnifeInfo() { let aknifeInfo = { "knifeNumGrade": 0, "knifeTotalNum": 0, "knifeUpgradeNumNeedCoins": 0, "knifeAttackGrade": 0, "knifeAttack": 0, "knifeUpgradeAttackNeedCoins": 0 }; let dataKnifeInfo = Data.getKnifeInfo(); aknifeInfo.knifeNumGrade = dataKnifeInfo.knifeNumGrade; aknifeInfo.knifeTotalNum = dataKnifeInfo.knifeTotalNum; aknifeInfo.knifeUpgradeNumNeedCoins = dataKnifeInfo.knifeUpgradeNumNeedCoins; aknifeInfo.knifeAttackGrade = dataKnifeInfo.knifeAttackGrade; aknifeInfo.knifeAttack = dataKnifeInfo.knifeAttack; aknifeInfo.knifeUpgradeAttackNeedCoins = dataKnifeInfo.knifeUpgradeAttackNeedCoins; return aknifeInfo; } setKnifeInfo(value) { this.knifeInfo = value; let aknifeInfo = { "knifeNumGrade": value.knifeNumGrade, "knifeTotalNum": value.knifeTotalNum, "knifeUpgradeNumNeedCoins": value.knifeUpgradeNumNeedCoins, "knifeAttackGrade": value.knifeAttackGrade, "knifeAttack": value.knifeAttack, "knifeUpgradeAttackNeedCoins": value.knifeUpgradeAttackNeedCoins }; Data.setKnifeInfo(aknifeInfo); } getCritInfo() { let aCritInfo = { "critAttackGrade": 0, "critAttack": 0, "critUpgradeAttackNeedCoins": 0, "critChanceGrade": 0, "critChance": 0, "critUpgradeChanceNeedCoins": 0 }; let dataCritInfo = Data.getCritInfo(); aCritInfo.critAttackGrade = dataCritInfo.critAttackGrade; aCritInfo.critAttack = dataCritInfo.critAttack; aCritInfo.critUpgradeAttackNeedCoins = dataCritInfo.critUpgradeAttackNeedCoins; aCritInfo.critChanceGrade = dataCritInfo.critChanceGrade; aCritInfo.critChance = dataCritInfo.critChance; aCritInfo.critUpgradeChanceNeedCoins = dataCritInfo.critUpgradeChanceNeedCoins; return aCritInfo; } setCritInfo(value) { this.critInfo = value; let acritInfo = { "critAttackGrade": value.critAttackGrade, "critAttack": value.critAttack, "critUpgradeAttackNeedCoins": value.critUpgradeAttackNeedCoins, "critChanceGrade": value.critChanceGrade, "critChance": value.critChance, "critUpgradeChanceNeedCoins": value.critUpgradeChanceNeedCoins }; Data.setCritInfo(acritInfo); } getCoinInfo() { let aCoinInfo = { "coinValueGrade": 0, "coinValue": 0, "coinUpgradeValueNeedCoins": 0, "coinProfitGrade": 0, "coinProfit": 0, "coinUpgradeProfitNeedCoins": 0 }; let dataCoinInfo = Data.getCoinInfo(); aCoinInfo.coinValueGrade = dataCoinInfo.coinValueGrade; aCoinInfo.coinValue = dataCoinInfo.coinValue; aCoinInfo.coinUpgradeValueNeedCoins = dataCoinInfo.coinUpgradeValueNeedCoins; aCoinInfo.coinProfitGrade = dataCoinInfo.coinProfitGrade; aCoinInfo.coinProfit = dataCoinInfo.coinProfit; aCoinInfo.coinUpgradeProfitNeedCoins = dataCoinInfo.coinUpgradeProfitNeedCoins; return aCoinInfo; } setCoinInfo(value) { this.coinInfo = value; let aCoinInfo = { "coinValueGrade": value.coinValueGrade, "coinValue": value.coinValue, "coinUpgradeValueNeedCoins": value.coinUpgradeValueNeedCoins, "coinProfitGrade": value.coinProfitGrade, "coinProfit": value.coinProfit, "coinUpgradeProfitNeedCoins": value.coinUpgradeProfitNeedCoins }; Data.setCoinInfo(aCoinInfo); } getLastOfflineTime() { return Data.getLastOfflineTime(); } setThisOfflineTime() { Data.setThisOfflineTime(Laya.Browser.now()); } getRecoverStrengthCountDownStartTime() { return Data.getRecoverStrengthCountDownStartTime(); } saveRecoverStrengthCountDownStartTime(num) { let startTime = num ? num : Laya.Browser.now(); this.recoverStrengthCountDownStartTime = startTime; Data.setRecoverStrengthCountDownStartTime(startTime); } getPropTeach() { return Data.getPropTeach(); } setPropTeach(value) { MainScene.gameControl.b_propTeach = value; Data.setPropTeach(value); } } class GameConfig { constructor() { } static init() { var reg = Laya.ClassUtils.regClass; reg("game/BtnEffectControl.ts", BtnEffectControl); reg("game/MainScene.ts", MainScene); reg("game/GameControl.ts", GameControl); } } GameConfig.width = 720; GameConfig.height = 1280; GameConfig.scaleMode = "fixedwidth"; GameConfig.screenMode = "vertical"; GameConfig.alignV = "middle"; GameConfig.alignH = "left"; GameConfig.startScene = "MainScene.scene"; GameConfig.sceneRoot = ""; GameConfig.debug = false; GameConfig.stat = false; GameConfig.physicsDebug = true; GameConfig.exportSceneToJson = true; GameConfig.init(); class Main { constructor() { if (window["Laya3D"]) Laya3D.init(GameConfig.width, GameConfig.height); else Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]); Laya["Physics"] && Laya["Physics"].enable(); Laya["DebugPanel"] && Laya["DebugPanel"].enable(); Laya.stage.scaleMode = GameConfig.scaleMode; Laya.stage.screenMode = GameConfig.screenMode; Laya.stage.alignV = GameConfig.alignV; Laya.stage.alignH = GameConfig.alignH; Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson; if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true") Laya.enableDebugPanel(); if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"]) Laya["PhysicsDebugDraw"].enable(); if (GameConfig.stat) Laya.Stat.show(); Laya.alertGlobalError = true; Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION); } onVersionLoaded() { Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded)); } onConfigLoaded() { let wx = window["wx"]; if (wx) { GameConfig.startScene && Laya.Scene.open(GameConfig.startScene); } else { GameConfig.startScene && Laya.Scene.open(GameConfig.startScene); } } } new Main(); }());