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) { DWTool.loadResPrefab("./prefabs/draw/drawScroll") .then((result) => { let alert = cc.instantiate(result); let canvas = cc.find("Canvas"); alert.setPosition(0, 0); canvas.addChild(alert); alert.getComponent("DrawScroll").init(drawData, typeId); }); } /// 显示抽奖成功得到明星的界面 static showDrawSuccessAlert(drawData, typeId, backGroudId) { 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, backGroudId); }); } /// 显示技能弹窗界面 static showSkillAlert() { GameModule.audioMng.playClickButton(); if (Global.skillContent === undefined) { PrefabManager.loadPrefab('skill_content') .then((result) => { let alert = result; let canvas = cc.find("Canvas/commonNode"); canvas.addChild(alert); Global.skillContent = alert; }); } else { Global.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 (Global.starContent === undefined) { PrefabManager.loadPrefab('star_content') .then((result) => { let alert = result; let canvas = cc.find("Canvas/commonNode"); canvas.addChild(alert); Global.starContent = alert; }); } else { Global.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 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 (CC_WECHATGAME) { wx.showToast({ title: message, icon: 'none' }); } 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); }); } } module.exports = AlertManager;