const GameModule = require("./GameModule"); const DWTool = require("./DWTool"); const PrefabManager = require("./PrefabManager"); /** * 通用弹窗管理 */ class AlertManager { // 显示任务界面弹窗 static showQuestPopup() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('quest_popup') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } static showOfflineGrossIncome(offlineGold) { PrefabManager.loadPrefab('offline_grossIncome') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('OfflineGrossIncome').init(offlineGold); }); } /// 显示抽奖界面 static showDrawAlert(data = 1) { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('draw_content') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); alert.setPosition(0, 0); canvas.addChild(alert); }); } /// 显示抽奖滚动界面 static showDrawScrollAlert(drawData, typeId) { PrefabManager.loadPrefab('drawCycleScroll') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); alert.setPosition(0, 0); canvas.addChild(alert); alert.getComponent("DrawCycleScroll").init(drawData, typeId); }); } /// 显示抽奖成功得到明星的界面 static showDrawSuccessAlert(drawData, typeId) { DWTool.loadResPrefab("./prefabs/draw/drawStarSuccss") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); alert.setPosition(0, 0); canvas.addChild(alert); alert.getComponent("DrawStarSuccss").init(drawData, typeId); }); } /// 显示抽奖红包的界面 static showDrawRedRecordAlert() { DWTool.loadResPrefab("./prefabs/draw/drawRedRecord") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); alert.setPosition(0, 0); canvas.addChild(alert); }); } /// 显示技能弹窗界面 static showSkillAlert() { GameModule.audioMng.playClickButton(); if (GameGlobal.skillContent === undefined) { PrefabManager.loadPrefab('skill_content') .then((result) => { let alert = result; let canvas = cc.find("Canvas/commonNode"); canvas.addChild(alert); GameGlobal.skillContent = alert; }); } else { GameGlobal.skillContent.getComponent('skillContent').show(); } } static showSkillBuyAlert (skillInfo, nextSkillInfo, starItem) { GameModule.audioMng.playClickButton(); DWTool.loadResPrefab("./prefabs/skill/skillBuyAlert") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('SkillBuyAlert').init(skillInfo, nextSkillInfo, starItem); }); } /// 显示明星图鉴 static showStarHandbookAlert() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('starHandbook') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } /// 显示明星界面 static showStarAlert() { GameModule.audioMng.playClickButton(); if (GameGlobal.starContent === undefined || GameGlobal.starContent === null) { PrefabManager.loadPrefab('star_content') .then((result) => { let alert = result; let canvas = cc.find("Canvas/commonNode"); canvas.addChild(alert); GameGlobal.starContent = alert; }); } else { GameGlobal.starContent.getComponent('StarContent').show(); } } /// 显示获取道具弹窗界面 static showActGiftAlert(type, showText, spriteFrame) { DWTool.loadResPrefab("./prefabs/common/actgift") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent("Actgift").init(type, showText, spriteFrame); }); } /// 显示签到界面 static showSignInAlert() { PrefabManager.loadPrefab('sign_in') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } /// 显示明星图鉴 static showRankAlert(index = 0) { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('game_rank') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('GameRank').init(index); }); } /// 显示商城界面 static showStoreAlert() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('store_content') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } /// 显示商城合辑界面 static showStoreAlbumAlert(temDatas) { DWTool.loadResPrefab("./prefabs/store/storeAlbum") .then((result) => { let alert = cc.instantiate(result); alert.getComponent('StoreSubcript').init(temDatas); let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } /// 显示商城钻石优惠界面 static showStoreDiamondAlert(selectIndex) { DWTool.loadResPrefab("./prefabs/store/storeDiamond") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('StoreDiamondDiscount').init(selectIndex); }); } //// 显示商城礼包弹窗 static showStoreGiftAlert(giftIndex, giftData) { DWTool.loadResPrefab("./prefabs/store/storeGiftAlert") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('StoreGiftAlert').init(giftIndex, giftData); }); } /// 显示技能2弹出金币效果 static showSkill2Efc(gold) { DWTool.loadResPrefab("./prefabs/skill/use_skill2_efc") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas/useSkillNode"); canvas.addChild(alert); alert.getComponent('UseSkill2Efc').init(gold); }); } /// 显示共有弹窗 static showCommonAlert(iconPath, desc, title) { DWTool.loadResPrefab("./prefabs/common/commonAlert") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('commAlert').init(iconPath, desc, title); }); } /// 显示每天获取钻石弹窗 static showGetDiamondEveryDayAlert(iconPath, desc, title, diamond) { DWTool.loadResPrefab("./prefabs/common/commonAlert") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('commAlert').initAddDiamond(iconPath, desc, title, diamond); }); } /// 显示通知弹窗 static showNoticeAlert(noticeStr) { DWTool.loadResPrefab("./prefabs/common/noticeAlert") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('NoticeAlert').init(noticeStr); }); } /// 显示分享失败弹窗 static showShareFailAlert() { DWTool.loadResPrefab("./prefabs/common/shareFailAlert") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('shareFailAlert').show(); }); } // 显示错误消息提示 static showCommonErrorAlert(message) { if (window.tt != undefined) { //今日头条 tt.showToast({ title: message, icon: 'none' }); } else if (CC_WECHATGAME) { wx.showToast({ title: message, icon: 'none' }); /// qq平台直接弹出错误 } else if (CC_QQPLAY) { BK.UI.showToast({ title: message, duration:1500, complete:function() { BK.Script.log(0,0,"complete show"); } }); } else { alert(message); } } // 显示所拥有礼包界面 static showStarGiftBag(array) { DWTool.loadResPrefab("./prefabs/star/star_gift_bag") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); alert.getComponent('StarGiftBag').init(array); }); } // 显示所拥有礼包界面 static showStoreQQaddGroup() { DWTool.loadResPrefab("./prefabs/store/storeQQAlert") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } //显示我的小程序神秘礼包界面 static showAppletAlert() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('my_applet') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } //显示邀请好友界面 static showInviteAlert() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('invite_mission') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } static showLoginRewardAlert() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('login_reward') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } // 显示音效设置 static showGameSetting() { GameModule.audioMng.playClickButton(); DWTool.loadResPrefab("./prefabs/setting/game_setting") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } //好友助力界面 static showFriendHelpAlert() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('friend_help_click') .then((result) => { let canvas = cc.find("Canvas"); canvas.addChild(result); }); } //好友系统界面 static showGameFriend() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('game_friend') .then((result) => { let canvas = cc.find("Canvas"); canvas.addChild(result); result.getComponent('GameFriendCtrl').init(); }); } /** *每天时间段奖励的弹窗 * * @static * @memberof AlertManager */ static showGetAward() { GameModule.audioMng.playClickButton(); PrefabManager.loadPrefab('dayAward_Alert') .then((result) => { let alert = result; let canvas = cc.find("Canvas"); canvas.addChild(alert); }); } } module.exports = AlertManager;