import {RDPlatformParam} from "./RDPlatformParam"; import HttpManager from "../net/HttpManager"; import {AdsManager} from "./AdsManager"; import {BenzAssetManager} from "../asset/BenzAssetManager"; import {AssetsHelper} from "../asset/AssetsHelper"; export class OpCommand { public static readonly CMD_OPTION_BANNER_MOVE = 101; //banner位移误触开关 public static readonly CMD_OPTION_VIDEO_SELECT = 102; //默认勾选激励广告开关 public static readonly CMD_OPTION_VIDEO_ICON = 103; //激励视频广告按键图标开关 public static readonly CMD_OPTION_ALL_SCREEN = 104;//全屏导出界面开关 public static readonly CMD_OPTION_EXIT = 105;//假退出打开互推界面开关 public static readonly CMD_OPTION_INTERTITAL = 106;//插屏广告误触-延迟出广告:游戏结算和暂停时1500毫秒后突然弹出 } export default class OptionsManager { private static _instance: OptionsManager = new OptionsManager(); public static getInstance(): OptionsManager { return this._instance; } private switchData = {}; public init(): void { let self = this; this.initCity(); } changeData(data) { let newData = {}; let ary1 = data.split("#"); for (let i = 0; i < ary1.length; i++) { let ary2 = ary1[i].split("|"); newData[ary2[0]] = { 'switch': ary2[1], 'prob': ary2[2], }; } return newData; } getOptionData(cityId) { var gameId = RDPlatformParam.ADPARAM[RDPlatformParam.platFromId]["gameId"]; if (!gameId) return; HttpManager.getInstance().get("https://hcrsstzb-sst.emptygame.com.cn:8443", "/ReadGameConfig11", "id=" + gameId + "&" + "cid=" + cityId, function (err, res) { console.log("开关数据成功" + res); if(!res) return; this.switchData = this.changeData(res); console.log("开关数据成功" + JSON.stringify(this.switchData)); // this.initCity(); }.bind(this)); } initCity() { HttpManager.getInstance().get("https://pv.sohu.com", "/cityjson", "", function (err, res) { console.log("城市数据" + res); if (!err) { let cityId = res.split('"')[7]; console.log("城市行政id" + cityId); this.getOptionData(cityId); } }.bind(this)); } getOptionSwitch(cmd: number): boolean { var eventId = RDPlatformParam.ADPARAM[RDPlatformParam.platFromId]["eventId"]; if (!eventId) return false; let id = eventId[cmd.toString()]; if (!id) return false; let data = this.switchData[id]; if (!data) return false; console.log("开关数据" + JSON.stringify(data)); return data.switch == "true"; } /** * 退出按钮添加 */ // addExit(node: cc.Node) { // if (OptionsManager.getInstance().getOptionSwitch(OpCommand.CMD_OPTION_EXIT)) { // //Todo 给对应界面添加虚拟退出按钮 位置自动转到世界坐标的右上角(距离上面130 , 右边15) // let btn: cc.Node = cc.instantiate(BenzAssetManager.getInstance().getAsset(AssetsHelper.SHOW_ADSCREEN_BUTTON)); // btn.on(cc.Node.EventType.TOUCH_END, function () { // AdsManager.getInstance().showADScreen(); // }, this); // btn.setPosition(node.convertToNodeSpaceAR(cc.v2(cc.winSize.width - 15, cc.winSize.height - 130))); // node.addChild(btn); // } // } /** * 界面切换是否跳出全屏推广 */ // addADScreen() { // if (OptionsManager.getInstance().getOptionSwitch(OpCommand.CMD_OPTION_ALL_SCREEN)) { // AdsManager.getInstance().showADScreen(); // } // } }