HallScene.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. var baseScene = require('BaseScene');
  2. import EventMgr from "../base/EventMgr";
  3. import ResMgr from "../base/ResMgr";
  4. import UIMgr from "../base/UIMgr";
  5. import SoundMgr from "../base/SoundMgr";
  6. import Tool from "../base/Tool";
  7. import UserInfoMgr from "../base/user/UserInfoMgr";
  8. cc.Class({
  9. extends: baseScene,
  10. properties: {
  11. atlasVIP: cc.SpriteAtlas, //vip图集
  12. labCoin: cc.Label,
  13. labBli: cc.Label,
  14. labName: cc.Label,
  15. labID: cc.Label,
  16. labHBNum: cc.Label,
  17. labYGNum: cc.Label,
  18. labJixian: cc.Label,
  19. spHead: cc.Sprite,
  20. spVipDi: cc.Sprite,
  21. spVip: cc.Sprite,
  22. yunNode: cc.Node,
  23. haidaoNode: cc.Node,
  24. centerNode: cc.Node,
  25. roomNode: cc.Node,
  26. shopNode: cc.Node,
  27. mailNode: cc.Node,
  28. exchangeNode: cc.Node,
  29. btnsNode: cc.Node,
  30. jiaziNode: cc.Node,
  31. jixianSuoNode: cc.Node,
  32. paomaNode: cc.Node,
  33. dropDownNode: cc.Node, //下拉内容
  34. geduanNode: cc.Node, //遮挡(防止瞎点)
  35. },
  36. // LIFE-CYCLE CALLBACKS:
  37. onLoad () {
  38. this._super();
  39. this.initData();
  40. this.initListeners();
  41. this.setPopLayerData();
  42. // var frameSize = cc.view.getFrameSize();
  43. // if (frameSize.width / frameSize.height < 1.65) {
  44. // cc.view.setDesignResolutionSize(720,1280, cc.ResolutionPolicy.FIXED_WIDTH);
  45. // }
  46. },
  47. start () {
  48. this.onShow();
  49. this.popLayer();
  50. this.setPlayerInfo();
  51. this.setPoolValue();
  52. cc.director.preloadScene("gameScene");
  53. },
  54. // update (dt) {},
  55. initData(){
  56. this.popLayers = []; //存储需要自动打开的界面
  57. this.llkConfig = ConfigModel.getGlobalConfigByKey("llk");
  58. },
  59. initListeners(){
  60. // this.registerListener('121', this.setPlayerInfo);
  61. this.registerListener('121', this.setPlayerInfo);
  62. EventMgr.on(EventType.OtherJC_REFRESH, this.setPoolValue, this); //刷新奖池
  63. },
  64. setPopLayerData(){
  65. this.popLayers = [];
  66. // this.popLayers.push('xxxxx');
  67. },
  68. popLayer(){
  69. if(this.popLayers.length <= 0){
  70. this.showGeduan(false);
  71. return;
  72. }
  73. let tempPop = this.popLayers.shift();
  74. let self = this;
  75. this.showGeduan(true);
  76. if(tempPop){
  77. UIMgr.openUI(`prefabs/${tempPop}`, (pf)=>{
  78. pf.getComponent(tempPop).setCloseBack(()=>{
  79. self.scheduleOnce(()=>{
  80. self.popLayer();
  81. });
  82. });
  83. });
  84. }
  85. },
  86. onShow(){
  87. if(this.llkConfig.Onoff == 1 && GameModel.player.VIPExp >= this.llkConfig.Viplimt){
  88. this.jixianSuoNode.active = true;
  89. }else{
  90. this.jixianSuoNode.active = false;
  91. }
  92. },
  93. setPlayerInfo(){
  94. this.labCoin.string = utils.getGoldString(GameModel.getItemCountByModel(GAME_RES_MAP.Gold));
  95. this.labBli.string = GameModel.getItemCountByModel(GAME_RES_MAP.Red);
  96. console.log('sasdas: ', GameModel.player);
  97. this.labName.string = GameModel.player.Name;
  98. this.labID.string = `ID:${GameModel.player.ID}`;
  99. let vipLv = utils.getVipLevel();
  100. this.spVipDi.spriteFrame = this.atlasVIP.getSpriteFrame(`VIPdi${vipLv+1}`);
  101. this.spVip.spriteFrame = this.atlasVIP.getSpriteFrame(`VIP${vipLv+1}`);
  102. ResMgr.loadRemoteTexture(this.spHead, GameModel.player.Head);
  103. /*
  104. this.labHBNum.string = 222222;
  105. this.labYGNum.string = 333333;
  106. ResMgr.loadTexture('texture/head/h1', (sp)=>{
  107. this.spHead.spriteFrame = sp;
  108. this.spHead.node.width = 90;
  109. this.spHead.node.height = 90;
  110. });
  111. */
  112. },
  113. setPoolValue(){
  114. let value1 = Tool.formatNumber(GameModel.pool3, 7);
  115. let value2 = Tool.formatNumber(GameModel.pool1, 7);
  116. let value3 = Tool.formatNumber(GameModel.Pool7, 7);
  117. this.labHBNum.string = value1;
  118. this.labYGNum.string = value2;
  119. this.labJixian.string = value3;
  120. },
  121. showGeduan(bShow = false){
  122. this.geduanNode.active = bShow;
  123. },
  124. showHides(bShow){
  125. for(let i=1; i< this.centerNode.childrenCount; i++){
  126. this.centerNode.children[i].active = false;
  127. }
  128. if(this.centerNode.children[0].active) //房间界面只能自己关闭
  129. bShow = false;
  130. this.yunNode.active = bShow;
  131. this.haidaoNode.active = bShow;
  132. this.btnsNode.active = bShow;
  133. this.jiaziNode.active = bShow;
  134. this.paomaNode.getComponent('PaomaLayer').setShowOrHide(bShow);
  135. },
  136. //---------------------点击事件---------------------------
  137. onClickHongbao(){
  138. SoundMgr.playClick();
  139. // EventMgr.emit('paopao', 'Hello World');
  140. this.showHides(false);
  141. this.roomNode.getComponent('RoomLayer').showRoom(this, 1);
  142. },
  143. //赏金争夺
  144. onClickBonusRank(){
  145. SoundMgr.playClick();
  146. UIMgr.openUI('prefabs/BonusRankLayer');
  147. },
  148. onClickYuangu(){
  149. SoundMgr.playClick();
  150. this.showHides(false);
  151. this.roomNode.getComponent('RoomLayer').showRoom(this, 2);
  152. },
  153. onClickJixian(){
  154. SoundMgr.playClick();
  155. this.showHides(false);
  156. this.roomNode.getComponent('RoomLayer').showRoom(this, 3);
  157. },
  158. onClickCoin(){
  159. // 测试
  160. // UIMgr.openUI('prefabs/TipsLayer', (pf)=>{
  161. // pf.getComponent('TipsLayer').setCon('飒飒飒飒');
  162. // });
  163. // UIMgr.openUI('prefabs/GetRewardLayer', (pf)=>{
  164. // pf.getComponent('GetRewardLayer').initData();
  165. // });
  166. this.onClickShop();
  167. },
  168. onClickBli(){
  169. SoundMgr.playClick();
  170. this.showHides(false);
  171. this.exchangeNode.getComponent('ExchangeLayer').showExchange(this);
  172. },
  173. onClickHead(){
  174. SoundMgr.playClick();
  175. UIMgr.openUI('prefabs/PlayerInfoLayer');
  176. },
  177. onClickMenu(){
  178. SoundMgr.playClick();
  179. this.dropDownNode.active = !this.dropDownNode.active;
  180. let tPosY = [80, -10, -100];
  181. if(this.dropDownNode.active){
  182. Tool.effectMoveY(this.dropDownNode, tPosY);
  183. }
  184. },
  185. onClickFirst(){
  186. SoundMgr.playClick();
  187. UIMgr.openUI('prefabs/FirstChargeLayer');
  188. },
  189. onClickSign(){
  190. SoundMgr.playClick();
  191. UIMgr.openUI('prefabs/SignLayer');
  192. },
  193. onClickService(){
  194. SoundMgr.playClick();
  195. },
  196. onClickSet(){
  197. SoundMgr.playClick();
  198. UIMgr.openUI('prefabs/SetLayer');
  199. },
  200. onClickChaozhi(){
  201. SoundMgr.playClick();
  202. UIMgr.openUI('prefabs/FortuneGiftLayer');
  203. },
  204. onClickMonthCard(){
  205. SoundMgr.playClick();
  206. UIMgr.openUI('prefabs/MonthCardLayer');
  207. },
  208. onClickZhaocai(){
  209. SoundMgr.playClick();
  210. UIMgr.openUI('prefabs/ZhaoCaiLayer');
  211. },
  212. onClickVIP(){
  213. SoundMgr.playClick();
  214. UIMgr.openUI('prefabs/VIPLayer');
  215. },
  216. onClickShare(){
  217. SoundMgr.playClick();
  218. UIMgr.openUI('prefabs/ShareTaskLayer');
  219. },
  220. onClickRedgrowth(){
  221. SoundMgr.playClick();
  222. UIMgr.openUI('prefabs/RedGrowthLayer');
  223. },
  224. onClickInvestment(){
  225. SoundMgr.playClick();
  226. UIMgr.openUI('prefabs/SevenInvestLayer');
  227. },
  228. onClickExchangeTask(){
  229. SoundMgr.playClick();
  230. UIMgr.openUI('prefabs/ExchangeTaskLayer');
  231. },
  232. onClickMail(){
  233. SoundMgr.playClick();
  234. this.showHides(false);
  235. this.mailNode.getComponent('MailLayer').showMail(this);
  236. },
  237. onClickActivity(){
  238. SoundMgr.playClick();
  239. UIMgr.openUI('prefabs/ActivityLayer');
  240. },
  241. onClickShop(){
  242. SoundMgr.playClick();
  243. this.showHides(false);
  244. this.shopNode.getComponent('ShopLayer').showShop(this);
  245. },
  246. onClickTask(){
  247. SoundMgr.playClick();
  248. UIMgr.openUI('prefabs/TaskLayer', (pf)=>{
  249. pf.getComponent('TaskLayer').initData();
  250. });
  251. },
  252. onClickDailySale(){
  253. SoundMgr.playClick();
  254. UIMgr.openUI('prefabs/TeHuiLayer', (pf)=>{
  255. // pf.getComponent('TeHuiLayer').initData();
  256. });
  257. },
  258. });