123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- 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('drawScroll')
- .then((result) => {
- let alert = 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 (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) {
- 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 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 (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);
- });
- }
- }
- module.exports = AlertManager;
|