import DataMgr from "../data/DataMgr"; import { EAdType, Prop } from "../data/Define"; import UIBase from "../fgui/core/UIBase"; import ui_UIAddProp from "../fgui/res/game/ui_UIAddProp"; import PlatMgr from "../game/PlatMgr"; import { xGame } from "../xGame"; import { UIGame } from "./UIGame"; import UIGameEnd from "./UIGameEnd"; import UILevelDisplay from "./UILevelDisplay"; import UIMain from "./UIMain"; import UISkill from "./UISkill"; import UIMsg from "./UIMsg"; import GlobalManager from "../utils/GlobalManager"; import JSBridgeUtils from "../utils/JSBridgeUtils"; export default class UIAddProp extends UIBase { protected ui: ui_UIAddProp; // public curType: string = ""; public constructor() { super(); } protected onConstructor(): void { this.ui = ui_UIAddProp.createInstance(); this.contentPane = this.ui; this.isEject = false; this.addUIClick(this.ui.closeBtn, this.closeSelf); this.addUIClick(this.ui.myNode.coinBtn, this.switchBtn, ["coin"]); this.addUIClick(this.ui.myNode.diamondBtn, this.switchBtn, ["diamond"]); this.updateUI(); this.addUIClick(this.ui.myNode.node1, this.shareGetDiamond); this.addUIClick(this.ui.myNode.node2, this.videoGetDiamond); this.addUIClick(this.ui.myNode.node6, this.openPutBallView); // this.addUIClick(this.ui.myNode.node3, this.convertCoin, [3]); this.addUIClick(this.ui.myNode.node3, this.videoGetCoin); this.addUIClick(this.ui.myNode.node4, this.convertCoin, [4]); this.addUIClick(this.ui.myNode.node5, this.convertCoin, [5]); } public show(type): void { super.show(); //type,0-金币,1-钻石 this.curType = type == 0 ? "coin" : "diamond"; this.switchBtn(""); this.ui.t0.play(); // this.ui.myNode.node1.c1.selectedIndex = Moyu.isTT ? 0 : 1; PlatMgr.showInsert(true); } public closeSelf() { this.hide(); } updateUI() { let data = cfgTable.moneyData; let temp: cfgTable.money; let obj; for (const key in data) { temp = data[key]; obj = this.ui.myNode["node" + key]; if (parseInt(key) <= 2) { //钻石 obj.diamondTxt.text = "+" + temp.num; } else { //金币 obj.coinTxt.text = temp.num; obj.diamondTxt.text = temp.get.split('_')[1]; } } // this.updateDiamondShare(); } updateDiamondShare() { let data = DataMgr.getShareDiamondTimes(); if (data >= xGame.common.maxShareDiamondTimes) { this.ui.myNode.node1.shareTxt.text = "Available Tomorrow" this.ui.myNode.node1.touchable = false; xGame.uiMgr.Show(UIMsg, "Come back tomorrow"); } else { this.ui.myNode.node1.shareTxt.text = `(${data}/${xGame.common.maxShareDiamondTimes})` this.ui.myNode.node1.touchable = true; } } switchBtn(type) { if (type == "") type = this.curType; else { if (this.curType == type) { return; } else { this.curType = type; } } if (type == "coin") { this.ui.myNode.coinBtn.c1.selectedIndex = 0; this.ui.myNode.diamondBtn.c1.selectedIndex = 1; this.ui.myNode.coinBtn.displayObject.zOrder = 10; this.ui.myNode.diamondBtn.displayObject.zOrder = 9; // this.ui.myNode.c1.selectedIndex = 0; } else { this.ui.myNode.coinBtn.c1.selectedIndex = 1; this.ui.myNode.diamondBtn.c1.selectedIndex = 0; this.ui.myNode.coinBtn.displayObject.zOrder = 9; this.ui.myNode.diamondBtn.displayObject.zOrder = 10; // this.ui.myNode.c1.selectedIndex = 1; } } convertCoin(index) { let data = cfgTable.moneyData[index]; let coinNum = data.num; let str = data.get.split('_')[1]; let needDiamond = parseInt(str); if (DataMgr.diamondEnough(needDiamond)) { DataMgr.setDiamond(-needDiamond); xGame.common.playObjFlyAnim(coinNum, Prop.coin); //兑换成功 xGame.uiMgr.Show(UIMsg, "Exchange successful!"); } else { //钻石不足~ xGame.uiMgr.Show(UIMsg, "Diamond shortage"); //切换到钻石栏 this.switchBtn("diamond"); } } videoGetDiamond() { console.log('zh:qjff_AD_for_uiAddProp_videoGetDiamond') // GlobalManager.instance.registerMethod('xxxxx',this.xxxxx); // JSBridgeUtils.instance.showRewardAd('xxxxx'); //需要传递参数 //Laya.LocalStorage.setItem('temp_qjff_AD_for_uiGameEnd_level', level+''); if (JSBridgeUtils.instance.showRewardAd('qjff_AD_for_uiAddProp_videoGetDiamond')) { } else { console.log('zh:AD 失败,直接发放奖励') this.qjff_AD_for_uiAddProp_videoGetDiamond(); } // let num = cfgTable.moneyData[2].num; // Moyu.showVideoAd(() => { // xGame.common.playObjFlyAnim(num, Prop.diamond); // this.closeSelf(); // }, EAdType.addDiamond) } public qjff_AD_for_uiAddProp_videoGetDiamond() { let num = cfgTable.moneyData[2].num; xGame.common.playObjFlyAnim(num, Prop.diamond); this.closeSelf(); } videoGetCoin() { console.log('zh:qjff_AD_for_uiAddProp_videoGetCoin') // GlobalManager.instance.registerMethod('xxxxx',this.xxxxx); // JSBridgeUtils.instance.showRewardAd('xxxxx'); //需要传递参数 //Laya.LocalStorage.setItem('temp_qjff_AD_for_uiGameEnd_level', level+''); if (JSBridgeUtils.instance.showRewardAd('qjff_AD_for_uiAddProp_videoGetCoin')) { } else { console.log('zh:AD 失败,直接发放奖励') this.qjff_AD_for_uiAddProp_videoGetCoin(); } // Moyu.showVideoAd(() => { // xGame.common.playObjFlyAnim(2000, Prop.coin); // this.closeSelf(); // }, EAdType.addCoin) } public qjff_AD_for_uiAddProp_videoGetCoin() { xGame.common.playObjFlyAnim(2000, Prop.coin); this.closeSelf(); } shareGetDiamond() { let times = DataMgr.getShareDiamondTimes(); if (times >= xGame.common.maxShareDiamondTimes) { console.log('zh: 233333333333 maxShareDiamondTimes') xGame.uiMgr.Show(UIMsg, "Come back tomorrow"); } else { console.log('zh:33333333333333ad') // if (Moyu.isTT) { // let num = cfgTable.moneyData[1].num; // Moyu.shareVideo = '' // Moyu.shareGame((success) => { // if (success) { // xGame.uiMgr.Show(UIMsg, "分享成功!"); // xGame.common.playObjFlyAnim(num, Prop.diamond); // DataMgr.setShareDiamondTimes(1); // this.updateDiamondShare(); // } // else { // xGame.uiMgr.Show(UIMsg, "分享失败!"); // } // }) // } // else { // // // Moyu.showVideoAd(() => {//分享 // let diamond = xGame.common.randomNum(50, 100); // xGame.common.playObjFlyAnim(diamond, Prop.diamond); // DataMgr.setShareDiamondTimes(1); // this.updateDiamondShare(); // }, EAdType.randomDiamond) // // // } // Moyu.showVideoAd(() => {//分享 // let diamond = xGame.common.randomNum(50, 100); // xGame.common.playObjFlyAnim(diamond, Prop.diamond); // DataMgr.setShareDiamondTimes(1); // this.updateDiamondShare(); // }, EAdType.randomDiamond) console.log('zh:qjff_AD_for_uiAddProp_shareGetDiamond') // GlobalManager.instance.registerMethod('xxxxx',this.xxxxx); // JSBridgeUtils.instance.showRewardAd('xxxxx'); //需要传递参数 //Laya.LocalStorage.setItem('temp_qjff_AD_for_uiGameEnd_level', level+''); if (JSBridgeUtils.instance.showRewardAd('qjff_AD_for_uiAddProp_shareGetDiamond')) { } else { console.log('zh:AD 失败,直接发放奖励') this.qjff_AD_for_uiAddProp_shareGetDiamond(); } } } public qjff_AD_for_uiAddProp_shareGetDiamond() { let diamond = xGame.common.randomNum(50, 100); xGame.common.playObjFlyAnim(diamond, Prop.diamond); DataMgr.setShareDiamondTimes(1); this.updateDiamondShare(); } //进入摆球达人界面 openPutBallView() { let end = xGame.uiMgr.getUI(UIGameEnd); let skill = xGame.uiMgr.getUI(UISkill); let level = xGame.uiMgr.getUI(UILevelDisplay); let uigame = xGame.uiMgr.getUI(UIGame); // if (end && !end.isHide) { xGame.uiMgr.Hide(UIGameEnd); xGame.uiMgr.Show(UIMain); } if (skill && !skill.isHide) xGame.uiMgr.Hide(UISkill); if (uigame && !uigame.isHide) xGame.uiMgr.Hide(UIGame); // if (level && !level.isHide) { //不做操作 } else { xGame.uiMgr.Show(UILevelDisplay); } // this.closeSelf(); } } UIAddProp.uiName = "UIAddProp";