1
0

AlertManager.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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() {
  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. });
  168. }
  169. //// 显示商城礼包弹窗
  170. static showStoreGiftAlert(giftIndex, giftData) {
  171. DWTool.loadResPrefab("./prefabs/store/storeGiftAlert")
  172. .then((result) => {
  173. let alert = cc.instantiate(result);
  174. let canvas = cc.find("Canvas");
  175. canvas.addChild(alert);
  176. alert.getComponent('StoreGiftAlert').init(giftIndex, giftData);
  177. });
  178. }
  179. /// 显示技能2弹出金币效果
  180. static showSkill2Efc(gold) {
  181. DWTool.loadResPrefab("./prefabs/skill/use_skill2_efc")
  182. .then((result) => {
  183. let alert = cc.instantiate(result);
  184. let canvas = cc.find("Canvas/useSkillNode");
  185. canvas.addChild(alert);
  186. alert.getComponent('UseSkill2Efc').init(gold);
  187. });
  188. }
  189. /// 显示共有弹窗
  190. static showCommonAlert(iconPath, desc, title) {
  191. DWTool.loadResPrefab("./prefabs/common/commonAlert")
  192. .then((result) => {
  193. let alert = cc.instantiate(result);
  194. let canvas = cc.find("Canvas");
  195. canvas.addChild(alert);
  196. alert.getComponent('commAlert').init(iconPath, desc, title);
  197. });
  198. }
  199. /// 显示分享失败弹窗
  200. static showShareFailAlert() {
  201. DWTool.loadResPrefab("./prefabs/common/shareFailAlert")
  202. .then((result) => {
  203. let alert = cc.instantiate(result);
  204. let canvas = cc.find("Canvas");
  205. canvas.addChild(alert);
  206. alert.getComponent('shareFailAlert').show();
  207. });
  208. }
  209. // 显示错误消息提示
  210. static showCommonErrorAlert(message) {
  211. if (CC_WECHATGAME) {
  212. wx.showToast({
  213. title: message,
  214. icon: 'none'
  215. });
  216. } else {
  217. alert(message);
  218. }
  219. }
  220. }
  221. module.exports = AlertManager;