UiM.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. import RewardNode from "../ui/RewardNode";
  2. import RedPackageNode from "../ui/RedPackageNode";
  3. import AdM from "./AdM";
  4. import Main from "../Main";
  5. import GameM from "./GameM";
  6. import LogUtil from "../utils/LogUtil";
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class UiM extends cc.Component {
  10. static Instance: UiM = null
  11. @property(cc.Node)
  12. onPanelPar: cc.Node = null;
  13. @property(cc.Node)
  14. hallNode: cc.Node = null;
  15. // @property(cc.Node)
  16. // guideNode: cc.Node = null;
  17. @property(cc.Node)
  18. giftNode: cc.Node = null;
  19. @property(cc.Node)
  20. taskNode: cc.Node = null;
  21. @property(RewardNode)
  22. rewardNode: RewardNode = null;
  23. @property(RedPackageNode)
  24. redPackageNode: RedPackageNode = null;
  25. shopNode: cc.Node = null;
  26. settingNode: cc.Node = null;
  27. cashNode: cc.Node = null;
  28. turntableNode: cc.Node = null;
  29. dailyNode: cc.Node = null;
  30. treasureNode: cc.Node = null;
  31. InvestNode: cc.Node = null;
  32. safeDepositBoxNode: cc.Node = null;
  33. officialNode: cc.Node = null;
  34. cashRecordNode: cc.Node = null;
  35. redCodeNode: cc.Node = null;
  36. ruleNode: cc.Node = null;
  37. CertificationNode: cc.Node = null;
  38. AntiAddictionNode: cc.Node = null;
  39. clubMainNode: cc.Node = null;
  40. moreGameNode: cc.Node = null;
  41. clubGuideNode: cc.Node = null;
  42. usualCaidanNode: cc.Node = null
  43. cashProNode: cc.Node = null
  44. downLoadUI: cc.Node = null
  45. nativeAdAwardNode: cc.Node = null
  46. normalCashProNode: cc.Node = null
  47. guideInstallApkNode: cc.Node = null
  48. moreGamePopNode: cc.Node = null
  49. panelFuns: Function[] = [];
  50. /** 右侧进入打开的界面数组 */
  51. panelArr = []
  52. /** 直接弹出打开界面数组 */
  53. private onPanelArr = []
  54. onLoad() {
  55. UiM.Instance = this
  56. }
  57. start() {
  58. }
  59. checkDelayShow(func) {
  60. // if (UiM.Instance.guideNode.active) {
  61. // UiM.Instance.panelFuns.push(func)
  62. // }
  63. // else {
  64. // }
  65. func()
  66. }
  67. displayPanel() {
  68. if (this.panelFuns.length > 0) {
  69. let tempFun = this.panelFuns.pop();
  70. tempFun();
  71. }
  72. }
  73. closePanelFromHome() {
  74. if (this.panelArr.length > 0) {
  75. let p = this.panelArr.pop()
  76. this.closePanel(p)
  77. }
  78. }
  79. closePanelM() {
  80. if (this.panelArr.length > 0) {
  81. let p = this.panelArr.pop()
  82. this.closePanel(p)
  83. AdM.popChange(-1)
  84. }
  85. }
  86. /** 右侧进入打开界面 */
  87. openPanel(p, effect = true) {
  88. p.active = true
  89. this.panelArr.push(p)
  90. if (effect) {
  91. p.setPosition(750, 0)
  92. cc.tween(p)
  93. .to(0.3, { position: cc.v2(0, 0) }, cc.easeOut(3))
  94. .start()
  95. }
  96. else {
  97. p.setPosition(0, 0)
  98. }
  99. AdM.popChange(1)
  100. }
  101. /** 左侧进入打开界面 */
  102. openLeftPanel(p, effect = true) {
  103. p.active = true
  104. if (effect) {
  105. p.setPosition(-750, 0)
  106. cc.tween(p)
  107. .to(0.3, { position: cc.v2(0, 0) }, cc.easeOut(3))
  108. .start()
  109. }
  110. else {
  111. p.setPosition(0, 0)
  112. }
  113. }
  114. /** 右侧移出关闭界面 */
  115. private closePanel(p) {
  116. LogUtil.logV("closePanel", p.name)
  117. if (p.name == 'RedPackageNode') {
  118. p.getComponent(RedPackageNode).bgNode.active = false
  119. }
  120. cc.tween(p)
  121. .to(0.3, { position: cc.v2(750, 0) }, cc.easeOut(3))
  122. .call(() => {
  123. p.active = false
  124. if (p.name == 'cashNode') {
  125. if (GameM.commonData.maxCarLevel >= 10) {
  126. if (GameM.commonData.backShowDaily) {
  127. GameM.commonData.backShowDaily = false
  128. UiM.Instance.hallNode.getComponent(Main).showDialyPanel()
  129. }
  130. else if (GameM.commonData.dailyFirstLogin) {
  131. GameM.commonData.dailyFirstLogin = false
  132. UiM.Instance.hallNode.getComponent(Main).showDialyPanel()
  133. }
  134. }
  135. UiM.Instance.cashNode = null
  136. p.removeFromParent()
  137. console.log(p)
  138. }
  139. if (p.name == "ClubTixianNode") {
  140. p.removeFromParent()
  141. }
  142. })
  143. .start()
  144. }
  145. setPanelCool() {
  146. this.openLoading = true
  147. this.scheduleOnce(() => {
  148. this.openLoading = false
  149. }, 0.3)
  150. }
  151. //打开界面等待着
  152. private openLoading = false
  153. onPanel(name, effect = false, callBack = null) {
  154. if (this.openLoading) {
  155. return
  156. }
  157. this.openLoading = true
  158. cc.loader.loadRes('panelNode/' + name, cc.Prefab, (err, assets) => {
  159. if (err) {
  160. cc.error(err);
  161. return;
  162. }
  163. let has = false
  164. let panel = null
  165. for (var i = 0; i < this.onPanelArr.length; i++) {
  166. panel = this.onPanelArr[i]
  167. if (panel.name == name) {
  168. has = true
  169. break
  170. }
  171. }
  172. if (!has) {
  173. panel = cc.instantiate(assets)
  174. this.onPanelArr.push(panel)
  175. this.onPanelPar.addChild(panel)
  176. }
  177. if (effect) {
  178. panel.setPosition(750, 0)
  179. cc.tween(panel)
  180. .to(0.3, { position: cc.v2(0, 0) }, cc.easeOut(3))
  181. .delay(0.3)
  182. .call(() => {
  183. this.openLoading = false
  184. })
  185. .start()
  186. }
  187. else {
  188. this.scheduleOnce(() => {
  189. this.openLoading = false
  190. }, 0.3)
  191. }
  192. if (name == PANEL_NAME.ShopNode) {
  193. this.shopNode = panel
  194. }
  195. else if (name == PANEL_NAME.CashNode) {
  196. this.cashNode = panel
  197. }
  198. else if (name == PANEL_NAME.TurnTableNode) {
  199. this.turntableNode = panel
  200. }
  201. else if (name == PANEL_NAME.DailyNode) {
  202. this.dailyNode = panel
  203. }
  204. else if (name == PANEL_NAME.TreasureNode) {
  205. this.treasureNode = panel
  206. }
  207. else if (name == PANEL_NAME.SettingNode) {
  208. this.settingNode = panel
  209. }
  210. else if (name == PANEL_NAME.InvestNode) {
  211. this.InvestNode = panel
  212. }
  213. else if (name == PANEL_NAME.SafeDepositBox) {
  214. this.safeDepositBoxNode = panel
  215. }
  216. else if (name == PANEL_NAME.OfficialNode) {
  217. this.officialNode = panel
  218. }
  219. else if (name == PANEL_NAME.CashRecordNode) {
  220. this.cashRecordNode = panel
  221. }
  222. else if (name == PANEL_NAME.RedCodeNode) {
  223. this.redCodeNode = panel
  224. } else if (name == PANEL_NAME.clubMainNode) {
  225. this.clubMainNode = panel
  226. } else if (name == PANEL_NAME.clubGuideNode) {
  227. this.clubGuideNode = panel
  228. }
  229. else if (name == PANEL_NAME.RuleNode) {
  230. this.ruleNode = panel
  231. }
  232. else if (name == PANEL_NAME.CertificationNode) {
  233. this.CertificationNode = panel
  234. }
  235. else if (name == PANEL_NAME.AntiAddictionNode) {
  236. this.AntiAddictionNode = panel
  237. } else if (name == PANEL_NAME.moreGameNode) {
  238. this.moreGameNode = panel
  239. }
  240. else if (name == PANEL_NAME.UsualCaidanNode) {
  241. this.usualCaidanNode = panel
  242. }
  243. else if (name == PANEL_NAME.CashProNode) {
  244. this.cashProNode = panel
  245. }
  246. else if (name == PANEL_NAME.DownLoadUI) {
  247. this.downLoadUI = panel
  248. }
  249. else if (name == PANEL_NAME.NativeAdAwardNode) {
  250. this.nativeAdAwardNode = panel
  251. }
  252. else if (name == PANEL_NAME.NormalCashProNode) {
  253. this.normalCashProNode = panel
  254. }
  255. else if (name == PANEL_NAME.GuideInstallApkNode) {
  256. this.guideInstallApkNode = panel
  257. }
  258. else if (name == PANEL_NAME.MoreGamePopNode) {
  259. this.moreGamePopNode = panel
  260. }
  261. if (callBack) {
  262. callBack()
  263. }
  264. })
  265. }
  266. offPanel(name, effect = false, callBack = null) {
  267. if (this.openLoading && effect) {
  268. return
  269. }
  270. this.openLoading = true
  271. let panel = null
  272. for (var i = 0; i < this.onPanelArr.length; i++) {
  273. panel = this.onPanelArr[i]
  274. if (panel.name == name) {
  275. this.onPanelArr.splice(i, 1)
  276. break
  277. }
  278. }
  279. if (name == PANEL_NAME.ShopNode) {
  280. this.shopNode = null
  281. }
  282. else if (name == PANEL_NAME.CashNode) {
  283. this.cashNode = null
  284. }
  285. else if (name == PANEL_NAME.TurnTableNode) {
  286. this.turntableNode = null
  287. }
  288. else if (name == PANEL_NAME.DailyNode) {
  289. this.dailyNode = null
  290. }
  291. else if (name == PANEL_NAME.TreasureNode) {
  292. this.treasureNode = null
  293. }
  294. else if (name == PANEL_NAME.SettingNode) {
  295. this.settingNode = null
  296. }
  297. else if (name == PANEL_NAME.InvestNode) {
  298. this.InvestNode = null
  299. }
  300. else if (name == PANEL_NAME.SafeDepositBox) {
  301. this.safeDepositBoxNode = null
  302. }
  303. else if (name == PANEL_NAME.OfficialNode) {
  304. this.officialNode = null
  305. }
  306. else if (name == PANEL_NAME.CashRecordNode) {
  307. this.cashRecordNode = null
  308. }
  309. else if (name == PANEL_NAME.RedCodeNode) {
  310. this.redCodeNode = null
  311. }
  312. else if (name == PANEL_NAME.RuleNode) {
  313. this.ruleNode = null
  314. }
  315. else if (name == PANEL_NAME.CertificationNode) {
  316. this.CertificationNode = null
  317. }
  318. else if (name == PANEL_NAME.AntiAddictionNode) {
  319. this.AntiAddictionNode = null
  320. } else if (name == PANEL_NAME.clubMainNode) {
  321. this.clubMainNode = null
  322. } else if (name == PANEL_NAME.clubGuideNode) {
  323. this.clubGuideNode = null
  324. } else if (name == PANEL_NAME.moreGameNode) {
  325. this.moreGameNode = null
  326. }
  327. else if (name == PANEL_NAME.UsualCaidanNode) {
  328. this.usualCaidanNode = null
  329. }
  330. else if (name == PANEL_NAME.CashProNode) {
  331. this.cashProNode = null
  332. }
  333. else if (name == PANEL_NAME.DownLoadUI) {
  334. this.downLoadUI = null
  335. }
  336. else if (name == PANEL_NAME.NativeAdAwardNode) {
  337. this.nativeAdAwardNode = null
  338. }
  339. else if (name == PANEL_NAME.NormalCashProNode) {
  340. this.normalCashProNode = null
  341. }
  342. else if (name == PANEL_NAME.GuideInstallApkNode) {
  343. this.guideInstallApkNode = null
  344. }
  345. else if (name == PANEL_NAME.MoreGamePopNode) {
  346. this.moreGamePopNode = null
  347. }
  348. if (panel) {
  349. if (effect) {
  350. cc.tween(panel)
  351. .to(0.3, { position: cc.v2(750, 0) }, cc.easeOut(3))
  352. .call(() => {
  353. if (panel.name == 'cashNode') {
  354. if (GameM.commonData.maxCarLevel >= 10) {
  355. if (GameM.commonData.backShowDaily) {
  356. GameM.commonData.backShowDaily = false
  357. UiM.Instance.hallNode.getComponent(Main).showDialyPanel()
  358. }
  359. else if (GameM.commonData.dailyFirstLogin) {
  360. GameM.commonData.dailyFirstLogin = false
  361. UiM.Instance.hallNode.getComponent(Main).showDialyPanel()
  362. }
  363. }
  364. }
  365. panel.removeFromParent()
  366. this.openLoading = false
  367. if (callBack) {
  368. callBack()
  369. }
  370. })
  371. .start()
  372. }
  373. else {
  374. panel.removeFromParent()
  375. this.openLoading = false
  376. if (callBack) {
  377. callBack()
  378. }
  379. }
  380. }
  381. else {
  382. this.openLoading = false
  383. if (callBack) {
  384. callBack()
  385. }
  386. }
  387. }
  388. }
  389. export enum PANEL_NAME {
  390. SettingNode = 'SettingNode',
  391. InvestNode = 'InvestNode',
  392. ShopNode = 'ShopNode',
  393. TurnTableNode = 'TurnTableNode',
  394. CashNode = 'CashNode',
  395. RemindNode = 'RemindNode',
  396. DailyNode = 'DailyNode',
  397. TreasureNode = 'TreasureNode',
  398. PieceNode = 'PieceNode',
  399. SafeDepositBox = 'SafeDepositBox',//保险箱
  400. OfficialNode = 'OfficialNode',
  401. CashRecordNode = 'CashRecordNode',
  402. RedCodeNode = 'RedCodeNode',
  403. RuleNode = 'RuleNode',
  404. CertificationNode = 'CertificationNode',
  405. AntiAddictionNode = 'AntiAddictionNode',
  406. clubMainNode = 'clubMainNode',
  407. clubGuideNode = 'clubGuideNode',
  408. moreGameNode = 'moreGameNode',
  409. CashPro = 'CashPro',
  410. UsualCaidanNode = 'UsualCaidanNode',
  411. CashProNode = 'CashProNode',
  412. DownLoadUI = 'DownLoadUI',
  413. NativeAdAwardNode = 'NativeAdAwardNode',
  414. NormalCashProNode = 'NormalCashProNode',
  415. CoinTipNode = 'CoinTipNode',
  416. GuideInstallApkNode = 'GuideInstallApkNode',
  417. RedeemNode = 'RedeemNode',
  418. MoreGamePopNode = 'MoreGamePopNode'
  419. }