AlertManager.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. const GameModule = require("./GameModule");
  2. const DWTool = require("./DWTool");
  3. const PrefabManager = require("./PrefabManager");
  4. /**
  5. * 通用弹窗管理
  6. */
  7. class AlertManager {
  8. // 显示任务界面弹窗
  9. static showQuestPopup() {
  10. GameModule.audioMng.playClickButton();
  11. PrefabManager.loadPrefab('quest_popup')
  12. .then((result) => {
  13. let alert = result;
  14. let canvas = cc.find("Canvas");
  15. canvas.addChild(alert);
  16. });
  17. }
  18. static showOfflineGrossIncome(offlineGold) {
  19. PrefabManager.loadPrefab('offline_grossIncome')
  20. .then((result) => {
  21. let alert = result;
  22. let canvas = cc.find("Canvas");
  23. canvas.addChild(alert);
  24. alert.getComponent('OfflineGrossIncome').init(offlineGold);
  25. });
  26. }
  27. /// 显示抽奖界面
  28. static showDrawAlert(data = 1) {
  29. GameModule.audioMng.playClickButton();
  30. PrefabManager.loadPrefab('draw_content')
  31. .then((result) => {
  32. let alert = result;
  33. let canvas = cc.find("Canvas");
  34. alert.setPosition(0, 0);
  35. canvas.addChild(alert);
  36. });
  37. }
  38. /// 显示抽奖滚动界面
  39. static showDrawScrollAlert(drawData, typeId) {
  40. DWTool.loadResPrefab("./prefabs/draw/drawScroll")
  41. .then((result) => {
  42. let alert = cc.instantiate(result);
  43. let canvas = cc.find("Canvas");
  44. alert.setPosition(0, 0);
  45. canvas.addChild(alert);
  46. alert.getComponent("DrawScroll").init(drawData, typeId);
  47. });
  48. }
  49. /// 显示抽奖成功得到明星的界面
  50. static showDrawSuccessAlert(drawData, typeId, backGroudId) {
  51. DWTool.loadResPrefab("./prefabs/draw/drawStarSuccss")
  52. .then((result) => {
  53. let alert = cc.instantiate(result);
  54. let canvas = cc.find("Canvas");
  55. alert.setPosition(0, 0);
  56. canvas.addChild(alert);
  57. alert.getComponent("DrawStarSuccss").init(drawData, typeId, backGroudId);
  58. });
  59. }
  60. /// 显示技能弹窗界面
  61. static showSkillAlert() {
  62. GameModule.audioMng.playClickButton();
  63. if (Global.skillContent === undefined) {
  64. PrefabManager.loadPrefab('skill_content')
  65. .then((result) => {
  66. let alert = result;
  67. let canvas = cc.find("Canvas/commonNode");
  68. canvas.addChild(alert);
  69. Global.skillContent = alert;
  70. });
  71. } else {
  72. Global.skillContent.getComponent('skillContent').show();
  73. }
  74. }
  75. static showSkillBuyAlert (skillInfo, nextSkillInfo, starItem) {
  76. GameModule.audioMng.playClickButton();
  77. DWTool.loadResPrefab("./prefabs/skill/skillBuyAlert")
  78. .then((result) => {
  79. let alert = cc.instantiate(result);
  80. let canvas = cc.find("Canvas");
  81. canvas.addChild(alert);
  82. alert.getComponent('SkillBuyAlert').init(skillInfo, nextSkillInfo, starItem);
  83. });
  84. }
  85. /// 显示明星图鉴
  86. static showStarHandbookAlert() {
  87. GameModule.audioMng.playClickButton();
  88. PrefabManager.loadPrefab('starHandbook')
  89. .then((result) => {
  90. let alert = result;
  91. let canvas = cc.find("Canvas");
  92. canvas.addChild(alert);
  93. });
  94. }
  95. /// 显示明星界面
  96. static showStarAlert() {
  97. GameModule.audioMng.playClickButton();
  98. if (Global.starContent === undefined) {
  99. PrefabManager.loadPrefab('star_content')
  100. .then((result) => {
  101. let alert = result;
  102. let canvas = cc.find("Canvas/commonNode");
  103. canvas.addChild(alert);
  104. Global.starContent = alert;
  105. });
  106. } else {
  107. Global.starContent.getComponent('StarContent').show();
  108. }
  109. }
  110. /// 显示获取道具弹窗界面
  111. static showActGiftAlert(type, showText, spriteFrame) {
  112. DWTool.loadResPrefab("./prefabs/common/actgift")
  113. .then((result) => {
  114. let alert = cc.instantiate(result);
  115. let canvas = cc.find("Canvas");
  116. canvas.addChild(alert);
  117. alert.getComponent("Actgift").init(type, showText, spriteFrame);
  118. });
  119. }
  120. /// 显示签到界面
  121. static showSignInAlert() {
  122. PrefabManager.loadPrefab('sign_in')
  123. .then((result) => {
  124. let alert = result;
  125. let canvas = cc.find("Canvas");
  126. canvas.addChild(alert);
  127. });
  128. }
  129. /// 显示明星图鉴
  130. static showRankAlert(index = 0) {
  131. GameModule.audioMng.playClickButton();
  132. PrefabManager.loadPrefab('game_rank')
  133. .then((result) => {
  134. let alert = result;
  135. let canvas = cc.find("Canvas");
  136. canvas.addChild(alert);
  137. alert.getComponent('GameRank').init(index);
  138. });
  139. }
  140. /// 显示商城界面
  141. static showStoreAlert() {
  142. GameModule.audioMng.playClickButton();
  143. PrefabManager.loadPrefab('store_content')
  144. .then((result) => {
  145. let alert = result;
  146. let canvas = cc.find("Canvas");
  147. canvas.addChild(alert);
  148. });
  149. }
  150. /// 显示商城合辑界面
  151. static showStoreAlbumAlert(temDatas) {
  152. DWTool.loadResPrefab("./prefabs/store/storeAlbum")
  153. .then((result) => {
  154. let alert = cc.instantiate(result);
  155. alert.getComponent('StoreSubcript').init(temDatas);
  156. let canvas = cc.find("Canvas");
  157. canvas.addChild(alert);
  158. });
  159. }
  160. /// 显示商城钻石优惠界面
  161. static showStoreDiamondAlert(selectIndex) {
  162. DWTool.loadResPrefab("./prefabs/store/storeDiamond")
  163. .then((result) => {
  164. let alert = cc.instantiate(result);
  165. let canvas = cc.find("Canvas");
  166. canvas.addChild(alert);
  167. alert.getComponent('StoreDiamondDiscount').init(selectIndex);
  168. });
  169. }
  170. //// 显示商城礼包弹窗
  171. static showStoreGiftAlert(giftIndex, giftData) {
  172. DWTool.loadResPrefab("./prefabs/store/storeGiftAlert")
  173. .then((result) => {
  174. let alert = cc.instantiate(result);
  175. let canvas = cc.find("Canvas");
  176. canvas.addChild(alert);
  177. alert.getComponent('StoreGiftAlert').init(giftIndex, giftData);
  178. });
  179. }
  180. /// 显示技能2弹出金币效果
  181. static showSkill2Efc(gold) {
  182. DWTool.loadResPrefab("./prefabs/skill/use_skill2_efc")
  183. .then((result) => {
  184. let alert = cc.instantiate(result);
  185. let canvas = cc.find("Canvas/useSkillNode");
  186. canvas.addChild(alert);
  187. alert.getComponent('UseSkill2Efc').init(gold);
  188. });
  189. }
  190. /// 显示共有弹窗
  191. static showCommonAlert(iconPath, desc, title) {
  192. DWTool.loadResPrefab("./prefabs/common/commonAlert")
  193. .then((result) => {
  194. let alert = cc.instantiate(result);
  195. let canvas = cc.find("Canvas");
  196. canvas.addChild(alert);
  197. alert.getComponent('commAlert').init(iconPath, desc, title);
  198. });
  199. }
  200. /// 显示分享失败弹窗
  201. static showShareFailAlert() {
  202. DWTool.loadResPrefab("./prefabs/common/shareFailAlert")
  203. .then((result) => {
  204. let alert = cc.instantiate(result);
  205. let canvas = cc.find("Canvas");
  206. canvas.addChild(alert);
  207. alert.getComponent('shareFailAlert').show();
  208. });
  209. }
  210. // 显示错误消息提示
  211. static showCommonErrorAlert(message) {
  212. if (CC_WECHATGAME) {
  213. wx.showToast({
  214. title: message,
  215. icon: 'none'
  216. });
  217. } else {
  218. alert(message);
  219. }
  220. }
  221. // 显示所拥有礼包界面
  222. static showStarGiftBag(array) {
  223. DWTool.loadResPrefab("./prefabs/star/star_gift_bag")
  224. .then((result) => {
  225. let alert = cc.instantiate(result);
  226. let canvas = cc.find("Canvas");
  227. canvas.addChild(alert);
  228. alert.getComponent('StarGiftBag').init(array);
  229. });
  230. }
  231. }
  232. module.exports = AlertManager;