GamePlay.ts 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  1. import CellItem from "./view/uiItem/CellItem";
  2. import { PROPTYPE } from "./data/Enum";
  3. import PoolMgr, { NODEPOOLPREFABTYPE } from "./mgr/PoolMgr";
  4. import GameConst from "./data/GameConst";
  5. import GameLogic from "./util/GameLogic";
  6. import BonusTip from "./view/effect/BonusTip";
  7. import DataMgr from "./mgr/DataMgr";
  8. import EffectMgr, { TIP_SPRITEITEM_TYPE } from "./mgr/EffectMgr";
  9. import { DataEventId, EVENT_TYPE, GameProp, VideoAdType } from "../game/data/GameData";
  10. import JsbSystem from "../mk/system/JsbSystem";
  11. const { ccclass, property } = cc._decorator;
  12. @ccclass
  13. export default class GamePlay extends cc.Component {
  14. /**单例模式 */
  15. public static Inst: GamePlay = null;
  16. /**背景 */
  17. @property(cc.Node)
  18. node_bg: cc.Node = null;
  19. /**标题 */
  20. @property(cc.Node)
  21. node_top: cc.Node = null;
  22. @property(cc.Label)
  23. label_level: cc.Label = null;
  24. @property(cc.Node)
  25. node_redPacketIcon: cc.Node = null;
  26. @property({ type: cc.Node, displayName: "气泡红包1" })
  27. btn_gameGetRed1: cc.Node = null;
  28. @property({ type: cc.Node, displayName: "气泡红包2" })
  29. btn_gameGetRed2: cc.Node = null;
  30. @property({ type: cc.Node, displayName: "气泡红包3" })
  31. btn_gameGetRed3: cc.Node = null;
  32. @property({ type: cc.Node, displayName: "气泡红包3" })
  33. btn_gameGetRed4: cc.Node = null;
  34. /**内容 */
  35. @property(cc.Node)
  36. node_content: cc.Node = null;
  37. /**cell背景块 */
  38. @property(cc.Node)
  39. node_cellBg: cc.Node = null;
  40. /**暂停按钮 */
  41. @property(cc.Node)
  42. node_pauseBtn: cc.Node = null;
  43. /**进度条UI */
  44. @property(cc.Node)
  45. node_progressUI: cc.Node = null;
  46. @property(cc.Sprite)
  47. spr_progress: cc.Sprite = null;
  48. /**重置按钮 */
  49. @property(cc.Node)
  50. node_resetBtn: cc.Node = null;
  51. @property(cc.Label)
  52. label_resetPropNum: cc.Label = null;
  53. /**锤子按钮 */
  54. @property(cc.Node)
  55. node_hammerBtn: cc.Node = null;
  56. @property(cc.Label)
  57. label_hammerPropNum: cc.Label = null;
  58. /**变色按钮 */
  59. @property(cc.Node)
  60. node_changeBtn: cc.Node = null;
  61. @property(cc.Label)
  62. label_changePropNum: cc.Label = null;
  63. /**更改CellItemUI */
  64. @property(cc.Node)
  65. node_changeCellItemUI: cc.Node = null;
  66. /**特效UI */
  67. @property(cc.Node)
  68. node_effectUI: cc.Node = null;
  69. /**关卡红包UI */
  70. @property(cc.Node)
  71. node_levelRedPacketUI: cc.Node = null;
  72. /**点击检测遮罩 */
  73. @property(cc.Node)
  74. node_touchListenMask: cc.Node = null;
  75. /**当前进度得分 */
  76. public curProgressScore: number = 0;
  77. /**当前得分 */
  78. public curGetScore: number = 0;
  79. /**目标分数 */
  80. public targetScore: number = 0;
  81. /**最终得分 */
  82. public finalGetScore: number = 0;
  83. /**增加得分速度 */
  84. public addScoreSpeed: number = 4;
  85. // /**道具类型 */
  86. // public curPropType: PROPTYPE = PROPTYPE.Null;
  87. /**消消的方块数组
  88. * @param:key index_x
  89. * @param: value 整个纵列数组
  90. */
  91. public cellItemDic: { [key: number]: CellItem[] } = {};
  92. public cellItemArr: CellItem[] = [];
  93. /**清理CellItem的Vec数组 */
  94. public cleanedVecArr: cc.Vec2[] = [];
  95. /**能够清理的vecArr组 */
  96. public couldCleanVecArr: cc.Vec2[] = [];
  97. /**清理纵列的x */
  98. public cleanXIndexArr: number[] = [];
  99. /**所有的清理 */
  100. public allCleanedXArr: number[] = [];
  101. /**剩余未移除的xIndex */
  102. public leftXIndexArr: number[] = [];
  103. /**当前选择的cellItem */
  104. public curSelectCellItem: CellItem = null;
  105. /**当前点击得cellItem */
  106. public curClickCellItem: CellItem = null;
  107. /**当前选择的道具按钮 */
  108. public curSelectPropBtn: cc.Node = null;
  109. /**是否可以点击 */
  110. public ifCouldClick: boolean = true;
  111. /**是否已经通关 */
  112. public ifPass: boolean = false;
  113. /**是否获取后台回调 */
  114. public ifGetPass: boolean = false;
  115. /**是否打开积分红包 */
  116. public ifOpenScoreRedPacket: boolean = false;
  117. /**当前的道具类型 */
  118. private _curPropType: PROPTYPE;
  119. public get curPropType(): PROPTYPE {
  120. return this._curPropType;
  121. }
  122. public set curPropType(v: PROPTYPE) {
  123. //LogUtil.log("this.curSelectPropBtn", this.curSelectPropBtn);
  124. let ani = null;
  125. if (this.curSelectPropBtn) {
  126. mk.console.log("this.curSelectPropBtn", this.curSelectPropBtn);
  127. ani = this.curSelectPropBtn.children[1].getComponent(cc.Animation);
  128. }
  129. if (v == PROPTYPE.Null) {
  130. if (ani) {
  131. ani.play("ani_normalBtn");
  132. }
  133. this.setPropBtnNormalTip(this.curSelectPropBtn)
  134. }
  135. else {
  136. if (ani) {
  137. ani.play("ani_selectBtn");
  138. }
  139. this.setPropBtnSelectTip(this.curSelectPropBtn)
  140. }
  141. this._curPropType = v;
  142. }
  143. //刷新计时
  144. public isAllShow = false;
  145. private isShowRedPacket = true;
  146. // LIFE-CYCLE CALLBACKS:
  147. onLoad() {
  148. GamePlay.Inst = this;
  149. mk.event.register("event_guide", this.clickGuide, this);
  150. }
  151. private clickGuide(data: string) {
  152. if (data == "1_3") {//点击即可消除哦!
  153. this.cellItemDic[0][0] && this.cellItemDic[0][0].onClick();
  154. }
  155. else if (data == "1_5") {//再点击一次增加大量进度哦
  156. this.cellItemDic[1][1] && this.cellItemDic[1][1].onClick();
  157. }
  158. }
  159. public start() {
  160. mk.data.sendDataEvent(DataEventId.level, "关卡开启");
  161. PoolMgr.Inst.initPoolPrefab();
  162. GameConst.loadConfig().then(() => {
  163. this.adapt();
  164. // AudioMgr.Inst.playMusic(AUDIO_CLIP_NAME.bg_game);
  165. mk.audio.playMusic("music_gameBg");
  166. //读取在线分数数据
  167. gData.gameData.setProp(GameProp.curTotalScore, 0);//杀掉进程,则清零积分
  168. let score = gData.gameData.getProp(GameProp.curTotalScore);
  169. this.curGetScore = score;
  170. this.curProgressScore = score;
  171. this.finalGetScore = score;
  172. console.log("score", score);
  173. this.initView();
  174. this.initEvent();
  175. this.intervalShowGuide();
  176. this.intervalShowInter();
  177. cc.tween(this.btn_gameGetRed1).delay(0.2).to(1, { y: 60 }, { easing: "" }).to(1, { y: 0 }, { easing: "" }).union().repeatForever().start();
  178. cc.tween(this.btn_gameGetRed2).delay(0.4).to(1, { y: 60 }, { easing: "" }).to(1, { y: 0 }, { easing: "" }).union().repeatForever().start();
  179. cc.tween(this.btn_gameGetRed3).delay(0.2).to(1, { y: 60 }, { easing: "" }).to(1, { y: 0 }, { easing: "" }).union().repeatForever().start();
  180. cc.tween(this.btn_gameGetRed4).delay(0.4).to(1, { y: 60 }, { easing: "" }).to(1, { y: 0 }, { easing: "" }).union().repeatForever().start();
  181. }).catch();
  182. this.qipaoShow();
  183. this.btn_gameGetRed1.active = false;
  184. this.btn_gameGetRed3.active = false;
  185. this.btn_gameGetRed4.active = false;
  186. this.isShowRedPacket = gData.gameData.funOpenData[7] == "1";
  187. if (this.isShowRedPacket) {
  188. mk.event.register("refreshGameUI", this.refreshRedPacketUI.bind(this), this);
  189. }
  190. }
  191. onEnable() {
  192. mk.console.log("PROPTYPE[PROPTYPE.Change]", PROPTYPE.Change);
  193. }
  194. onDisable() {
  195. //退出游戏归置下道具状态
  196. this.curPropType = PROPTYPE.Null;
  197. if (this.curSelectCellItem) {
  198. this.curSelectCellItem.normal();
  199. }
  200. if (this.node_changeCellItemUI.active = true) {
  201. this.node_changeCellItemUI.active = false;
  202. }
  203. }
  204. adapt() {
  205. mk.console.log("进行适配!!!!!!!!!!!!!!!!");
  206. //背景适配
  207. this.node_bg.setContentSize(new cc.Size(cc.winSize.width, cc.winSize.height));
  208. // this.node_top.y = (cc.winSize.height - this.node_top.height) * 0.5 + 5;
  209. const world_pos = gData.gameData.gameStyle.node_top_ui.parent.convertToWorldSpaceAR(gData.gameData.gameStyle.node_top_ui.getPosition());
  210. const node_pos = this.node_top.parent.convertToNodeSpaceAR(world_pos);
  211. this.node_top.y = node_pos.y - 40;
  212. }
  213. update(dt) {
  214. this.doBubbleRedPacketLogic(dt);
  215. if (this.curProgressScore >= this.curGetScore) {
  216. if (this.curProgressScore == 0) {
  217. this.spr_progress.fillRange = 0;
  218. }
  219. return;
  220. }
  221. else {
  222. if (this.curProgressScore >= this.targetScore) {
  223. this.curProgressScore = this.curGetScore;
  224. this.initScore();
  225. }
  226. else {
  227. let nextProgressScore: number = this.curProgressScore + this.addScoreSpeed;
  228. if (/**this.curProgressScore < GamePlay.Inst.targetScore && */nextProgressScore >= GamePlay.Inst.targetScore) {
  229. let node_getTargetScoreTip = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.GetTargetScoreTip);
  230. GamePlay.Inst.node_effectUI.addChild(node_getTargetScoreTip);
  231. //进度到达开始显示(挪到initScore判断)
  232. // gData.reward.subType = 2;
  233. // mk.ad.videoAdType = VideoAdType.LevelScoreRedBag;
  234. // mk.ui.openPanel("module/reward/rewardLuck");
  235. }
  236. this.curProgressScore = nextProgressScore;
  237. if (this.curProgressScore >= this.curGetScore) {
  238. this.curProgressScore = this.curGetScore;
  239. }
  240. this.initScore();
  241. }
  242. }
  243. }
  244. /**初始化视图 */
  245. initView() {
  246. this.initLevel();
  247. this.initTotalScore();
  248. this.initScore();
  249. this.initProgress();
  250. this.initHammerPropNum();
  251. this.setPropBtnNormalTip(this.node_hammerBtn);
  252. this.initResetPropNum();
  253. this.setPropBtnNormalTip(this.node_resetBtn);
  254. this.initChanegPropNum();
  255. this.setPropBtnNormalTip(this.node_changeBtn);
  256. this.initCellBg();
  257. this.initCell();
  258. }
  259. /**初始化事件 */
  260. initEvent() {
  261. this.node_pauseBtn.on(cc.Node.EventType.TOUCH_END, this.onClickBtn, this);
  262. this.node_resetBtn.on(cc.Node.EventType.TOUCH_END, this.onClickBtn, this);
  263. this.node_hammerBtn.on(cc.Node.EventType.TOUCH_END, this.onClickBtn, this);
  264. this.node_changeBtn.on(cc.Node.EventType.TOUCH_END, this.onClickBtn, this);
  265. this.node_redPacketIcon.on(cc.Node.EventType.TOUCH_END, this.onClickRedPacketIcon, this);
  266. mk.event.register(EVENT_TYPE.BACK_WxAuth, this.onWxAuthBack, this);
  267. }
  268. /**初始化关卡数目 */
  269. initLevel() {
  270. mk.console.log("[Game] levelNum", gData.gameData.getProp(GameProp.levelNum));
  271. let level = gData.gameData.getProp(GameProp.levelNum);
  272. this.label_level.string = `第${level + 1}关`
  273. }
  274. /**初始化总分数 */
  275. initTotalScore() {
  276. if (this.targetScore) {
  277. return;
  278. }
  279. let level = gData.gameData.getProp(GameProp.levelNum);
  280. //加入一些随机值,而不是都能获得过关红包
  281. this.targetScore = 450 + level * (5 + Math.floor(Math.random() * 15));
  282. // //测试切换
  283. // this.targetScore = 5000;
  284. this.addScoreSpeed = Math.floor(this.targetScore / 200) * 2 + 4;
  285. mk.console.log("this.addScoreSpeed", this.addScoreSpeed);
  286. }
  287. /**初始化得分 */
  288. initScore() {
  289. this.initProgress();
  290. }
  291. /**初始化进度 */
  292. initProgress() {
  293. let progress = this.curProgressScore / this.targetScore;
  294. progress = progress > 1 ? 1 : progress;
  295. this.spr_progress.fillRange = progress;
  296. if (progress >= 1) {
  297. //进度到达开始显示
  298. gData.reward.subType = 2;
  299. mk.ad.videoAdType = VideoAdType.LevelScoreRedBag;
  300. let node_rewardLuck = mk.ui.getCurOnPanel("rewardLuck");
  301. if (!node_rewardLuck && gData.gameData.funOpenData['6'] == '1') {
  302. mk.ui.openPanel("module/reward/rewardLuck");
  303. }
  304. }
  305. // if (progress >= 1) {
  306. // this.pass();
  307. // mk.ui.openPanel("module/reward/rewardMission");
  308. // }
  309. // LogUtil.log("progressprogressprogressprogressprogressprogress", progress);
  310. }
  311. /**初始化道具 */
  312. initPropNum() {
  313. this.initHammerPropNum();
  314. this.initResetPropNum();
  315. this.initChanegPropNum();
  316. }
  317. /**初始化锤子道具数目 */
  318. initHammerPropNum() {
  319. let hammerPropNum = gData.gameData.getProp(GameProp.hammerPropNum);
  320. if (hammerPropNum) {
  321. this.label_hammerPropNum.string = hammerPropNum.toString();
  322. }
  323. else {
  324. this.label_hammerPropNum.string = "+";
  325. }
  326. }
  327. /**初始化重置道具数目 */
  328. initResetPropNum() {
  329. let resetPropNum = gData.gameData.getProp(GameProp.resetPropNum);
  330. if (resetPropNum) {
  331. this.label_resetPropNum.string = resetPropNum.toString();
  332. }
  333. else {
  334. this.label_resetPropNum.string = "+";
  335. }
  336. }
  337. /**初始化替换道具数目 */
  338. initChanegPropNum() {
  339. let changePropNum = gData.gameData.getProp(GameProp.changePropNum);
  340. if (changePropNum) {
  341. this.label_changePropNum.string = changePropNum.toString();
  342. }
  343. else {
  344. this.label_changePropNum.string = "+";
  345. }
  346. }
  347. // update (dt) {}
  348. /**初始化cellBg */
  349. initCellBg() {
  350. for (var i = 0; i < GameConst.col_num; i++) {
  351. for (var j = 0; j < GameConst.row_num; j++) {
  352. let prefab_cellBg = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.CellBg);
  353. // LogUtil.log("prefab_cellBg", prefab_cellBg);
  354. let node_cellBg = cc.instantiate(prefab_cellBg);
  355. this.node_cellBg.addChild(node_cellBg);
  356. }
  357. }
  358. }
  359. /**初始化cell */
  360. public initCell() {
  361. this.addCellItemFuc = () => { this.addCellItem(); };
  362. this.schedule(this.addCellItemFuc, 0.05);
  363. }
  364. public addCellItemFuc: Function = null;
  365. public curXIndex: number = 0;
  366. public curYIndex: number = 7;
  367. /**添加CellItem */
  368. public addCellItem() {
  369. mk.console.log("addCellItem!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  370. this.addColCellItem();
  371. this.curXIndex++;
  372. if (this.curXIndex >= GameConst.col_num) {
  373. this.unschedule(this.addCellItemFuc);
  374. // this.getStartRedPacketCellItem();
  375. }
  376. }
  377. /**添加纵列的cellItem */
  378. public addColCellItem() {
  379. this.cellItemDic[this.curXIndex] = [];
  380. for (var i = GameConst.row_num - 1; i >= 0; i--) {
  381. let prefab_cellItem = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.CellItem);
  382. let node_prefab = cc.instantiate(prefab_cellItem);
  383. let cellItem = node_prefab.getComponent(CellItem);
  384. cellItem.init(this.curXIndex, i);
  385. this.cellItemDic[this.curXIndex][i] = cellItem;
  386. this.cellItemArr.push(cellItem);
  387. this.node_content.addChild(node_prefab);
  388. }
  389. }
  390. /**点击按钮 */
  391. onClickBtn(event: cc.Event.EventTouch) {
  392. this.intervalShowGuide();
  393. this.intervalShowInter();
  394. //是否已经通关
  395. if (this.ifPass) {
  396. EffectMgr.Inst.addTip("通关结算啦,请稍后操作哈")
  397. return;
  398. }
  399. // AudioMgr.Inst.playEffect(AUDIO_CLIP_NAME.buttonClick);
  400. mk.audio.playEffect("button");
  401. switch (event.currentTarget) {
  402. case this.node_pauseBtn:
  403. this.onClickPauseBtn();
  404. break;
  405. case this.node_hammerBtn:
  406. this.onClickHammerBtn();
  407. break;
  408. case this.node_changeBtn:
  409. this.onClickChangeBtn();
  410. break;
  411. case this.node_resetBtn:
  412. this.onClickResetBtn();
  413. break;
  414. }
  415. }
  416. /**点击暂停按钮 */
  417. onClickPauseBtn() {
  418. mk.ui.openPanel("game/prefab/uiPanel/PauseUI")
  419. }
  420. /**点击分享 */
  421. public onClickShare() {
  422. if (!gData.loginData.isAuth) {
  423. // mk.tip.pop("请先点击头像,在设置界面授权");
  424. JsbSystem.WxAuth();
  425. return;
  426. }
  427. JsbSystem.sharePic();
  428. }
  429. /**点击重置按钮 */
  430. onClickResetBtn() {
  431. //设置当前选择的道具按钮
  432. this.setCurSelectPropBtn(this.node_resetBtn);
  433. this.curPropType = PROPTYPE.Reset;
  434. let resetPropNum = gData.gameData.getProp(GameProp.resetPropNum);
  435. if (!resetPropNum || resetPropNum <= 0) {
  436. mk.ui.openPanel("game/prefab/uiPanel/GetPropUI");
  437. return;
  438. }
  439. // AudioMgr.Inst.playEffect(AUDIO_CLIP_NAME.refresh);
  440. mk.audio.playEffect("ef_refresh");
  441. let keys = Object.keys(this.cellItemDic);
  442. for (var i = 0; i < keys.length; i++) {
  443. let key = Number(keys[i]);
  444. let colCellItemArr = this.cellItemDic[key];
  445. for (var j = 0; j < colCellItemArr.length; j++) {
  446. let cellItem = colCellItemArr[j];
  447. if (cellItem) {
  448. cellItem.reset();
  449. }
  450. }
  451. }
  452. //暂时不扣
  453. DataMgr.Inst.updatePropNum(2, GamePlay.Inst.curPropType, -1);
  454. this.curPropType = PROPTYPE.Null;
  455. //this.recycleAllCellItem();
  456. }
  457. //点击锤子按钮
  458. onClickHammerBtn() {
  459. //设置当前选择的道具按钮
  460. this.setCurSelectPropBtn(this.node_hammerBtn);
  461. this.curPropType = PROPTYPE.Hammer;
  462. let hammerPropNum = gData.gameData.getProp(GameProp.hammerPropNum);
  463. if (!hammerPropNum || hammerPropNum <= 0) {
  464. mk.ui.openPanel("game/prefab/uiPanel/GetPropUI");
  465. return;
  466. }
  467. DataMgr.Inst.updatePropNum(2, GamePlay.Inst.curPropType, -1);
  468. }
  469. //点击更换按钮
  470. onClickChangeBtn() {
  471. //设置当前选择的道具按钮
  472. this.setCurSelectPropBtn(this.node_changeBtn);
  473. this.curPropType = PROPTYPE.Change;
  474. let changePropNum = gData.gameData.getProp(GameProp.changePropNum);
  475. if (!changePropNum || changePropNum <= 0) {
  476. mk.ui.openPanel("game/prefab/uiPanel/GetPropUI");
  477. return;
  478. }
  479. DataMgr.Inst.updatePropNum(2, GamePlay.Inst.curPropType, -1);
  480. }
  481. /** 点击关卡气泡红包 */
  482. onClickLevelQiPaoPacket(index) {
  483. mk.ad.videoAdType = VideoAdType.LevelQiPaoRedBag;
  484. gData.gameData.openIndex = parseInt(index);
  485. }
  486. /**更改cellItem类型
  487. * @param cellItemType
  488. */
  489. changeCellItemType(cellItemType: number) {
  490. let pos_x = this.curSelectCellItem.node.x + GamePlay.Inst.node_content.x;
  491. let pos_y = this.curSelectCellItem.node.y + GamePlay.Inst.node_content.y;
  492. let node_change = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.Change);
  493. node_change.setPosition(pos_x, pos_y);
  494. GamePlay.Inst.node_effectUI.addChild(node_change);
  495. this.curSelectCellItem.setType(cellItemType)
  496. // AudioMgr.Inst.playEffect(AUDIO_CLIP_NAME.change);
  497. mk.audio.playEffect("ef_change");
  498. this.curSelectCellItem = null;
  499. }
  500. /**设置当前 */
  501. setCurSelectPropBtn(propBtn: cc.Node) {
  502. if (this.curSelectPropBtn) {
  503. let node_ani = this.curSelectPropBtn.children[1];
  504. if (node_ani) {
  505. let ani = node_ani.getComponent(cc.Animation);
  506. if (ani) {
  507. ani.play("ani_normalBtn");
  508. }
  509. }
  510. this.setPropBtnNormalTip(this.curSelectPropBtn);
  511. }
  512. this.curSelectPropBtn = propBtn;
  513. }
  514. /**设置道具普通提示 */
  515. setPropBtnNormalTip(propBtn: cc.Node) {
  516. if (!propBtn) {
  517. return;
  518. }
  519. let node_tip = propBtn.children[2];
  520. if (node_tip) {
  521. let label = null;
  522. switch (propBtn) {
  523. case this.node_hammerBtn:
  524. label = this.label_hammerPropNum;
  525. break;
  526. case this.node_resetBtn:
  527. label = this.label_resetPropNum;
  528. break;
  529. case this.node_changeBtn:
  530. label = this.label_changePropNum;
  531. break;
  532. }
  533. let str = label.string;
  534. let num = Number(str);
  535. let label_tip = node_tip.getComponent(cc.Label);
  536. mk.console.log("propBtn.name", propBtn.name);
  537. mk.console.log("num", num);
  538. if (num && num >= 1) {
  539. label_tip.string = "";
  540. }
  541. else {
  542. label_tip.string = "点我领取";
  543. }
  544. }
  545. }
  546. /**设置道具使用提示 */
  547. setPropBtnSelectTip(propBtn: cc.Node) {
  548. if (!propBtn) {
  549. return;
  550. }
  551. let node_tip = propBtn.children[2];
  552. if (node_tip) {
  553. let label = node_tip.getComponent(cc.Label)
  554. label.string = "道具使用中";
  555. }
  556. }
  557. /**显示CellItemUI */
  558. showChangeCellItemUI() {
  559. let cruSelectCellItem = this.curSelectCellItem;
  560. GamePlay.Inst.node_changeCellItemUI.active = true;
  561. // let min_x = -this.node_content.width * 0.5 + this.node_changeCellItemUI.width * 0.5;
  562. // let max_x = this.node_content.width * 0.5 + this.node_changeCellItemUI.width * 0.5;
  563. GamePlay.Inst.node_changeCellItemUI.y = cruSelectCellItem.node.y + cruSelectCellItem.node.height * 0.5 + GamePlay.Inst.node_changeCellItemUI.height * 0.5 + 20;
  564. }
  565. //onClick
  566. onClickRedPacketIcon() {
  567. if (this.spr_progress.fillRange == 1) {
  568. EffectMgr.Inst.addTip("已达成目标啦,过关发放哦");
  569. }
  570. else {
  571. EffectMgr.Inst.addTip("达到目标分数,才能领取哦");
  572. }
  573. }
  574. //找到红包的那个水果
  575. /**
  576. * 获取红包cellItem
  577. */
  578. public getStartRedPacketCellItem() {
  579. let totalCellItemArr: CellItem[] = this.cellItemArr.concat();
  580. let largeCellItemVec: cc.Vec2[] = [];
  581. for (var i = 0; i < totalCellItemArr.length; i++) {
  582. let cellItem = totalCellItemArr[i];
  583. if (!!cellItem) {
  584. GameLogic.getCouldCleanVecList(cellItem.x, cellItem.y, cellItem.type, true);
  585. // console.log("this.couldCleanVecArr", this.couldCleanVecArr);
  586. console.log("largeCellItemVec.length", largeCellItemVec.length)
  587. if (largeCellItemVec.length < this.couldCleanVecArr.length) {
  588. largeCellItemVec = this.couldCleanVecArr;
  589. }
  590. this.couldCleanVecArr.forEach(element => {
  591. let index = GameConst.col_num * element.x + (GameConst.row_num - 1 - element.y);
  592. totalCellItemArr[index] = null;
  593. this.cellItemDic[element.x][element.y].ifRemoved = false;
  594. });
  595. this.couldCleanVecArr = [];
  596. }
  597. }
  598. console.log("FC------------------------------------------------------------");
  599. let random_index = mk.math.random(0, largeCellItemVec.length - 1);
  600. let vec = largeCellItemVec[random_index];
  601. let redPcaketCellItem: CellItem = this.cellItemDic[vec.x][vec.y];
  602. redPcaketCellItem.showRedPacket();
  603. return redPcaketCellItem;
  604. }
  605. //自定义事件---------------------------------------------------------------------
  606. /**微信授权返回 */
  607. onWxAuthBack() {
  608. if (this.node.active) {
  609. this.restart();
  610. //
  611. let node_redPacketUI = mk.ui.getCurOnPanel("RedPacketUI")
  612. if (node_redPacketUI) {
  613. mk.ui.closePanel("RedPacketUI");
  614. }
  615. }
  616. this.initLevel();
  617. this.initTotalScore();
  618. this.initPropNum();
  619. mk.event.remove(EVENT_TYPE.BACK_WxAuth, this.onWxAuthBack, this);
  620. }
  621. //其他显示或逻辑项-------------------------------------------------------------------
  622. /**根据vecList清除cellItem */
  623. public cleanCellItemByVecList() {
  624. //LogUtil.log("[Game] Game.Inst.cleanCellItemVecArr", Game.Inst.cleanCellItemVecArr);
  625. //没有可清清除
  626. if (GamePlay.Inst.cleanedVecArr.length <= 0) {
  627. //FC:+ 是否可以点击
  628. this.ifCouldClick = true;
  629. EffectMgr.Inst.addTip("点击两个或以上消除哦");
  630. return;
  631. }
  632. //区分消除音效
  633. if (GamePlay.Inst.cleanedVecArr.length >= 4) {
  634. // AudioMgr.Inst.playEffect(AUDIO_CLIP_NAME.eliminate_bonus);
  635. mk.audio.playEffect("ef_eliminate_bonus");
  636. }
  637. else {
  638. //AudioMgr.Inst.playEffect(AUDIO_CLIP_NAME.eliminate);
  639. mk.audio.playEffect("ef_eliminate");
  640. }
  641. // AudioMgr.Inst.playEffect(AUDIO_CLIP_NAME.fly);
  642. mk.audio.playEffect("ef_fly");
  643. //同时消除
  644. for (var i = 0; i < GamePlay.Inst.cleanedVecArr.length; i++) {
  645. let vec = GamePlay.Inst.cleanedVecArr[i];
  646. //最后一个判定
  647. if (i == GamePlay.Inst.cleanedVecArr.length - 1) {
  648. this.checkBonusNum(GamePlay.Inst.cleanedVecArr.length);
  649. GamePlay.Inst.cellItemDic[vec.x][vec.y].recycle(false, true);
  650. }
  651. else {
  652. GamePlay.Inst.cellItemDic[vec.x][vec.y].recycle();
  653. }
  654. //回收 注释 改成如上
  655. //Game.Inst.cellItemDic[vec.x][vec.y].recycle();
  656. //Game.Inst.cellItemDic[vec.x][vec.y] = null;
  657. if (this.cleanXIndexArr.indexOf(vec.x) == -1) {
  658. this.cleanXIndexArr.push(vec.x);
  659. }
  660. }
  661. this.cleanXIndexArr.sort();
  662. //计算下全部移除的
  663. this.allCleanedXArr = GameLogic.getAllCleanXIndex(this.cleanXIndexArr);
  664. //FC:移除完,检测下落
  665. this.scheduleOnce(() => {
  666. //检测下落
  667. this.checkMoveDownCellItem();
  668. }, 0.2)
  669. }
  670. /**检测向下移动的cellItem */
  671. checkMoveDownCellItem() {
  672. mk.console.log("this.cleanXIndexArr", this.cleanXIndexArr);
  673. for (var i = 0; i < this.cleanXIndexArr.length; i++) {
  674. let xIndex = this.cleanXIndexArr[i];
  675. this.moveYCellItem(xIndex);
  676. }
  677. }
  678. /**移动
  679. * @param xIndex 移除的纵列
  680. * @param removedYIndex 移除的横向index
  681. */
  682. public moveYCellItem(xIndex: number) {
  683. // LogUtil.log("moveYCellItem x", xIndex, this.allCleanedXArr);
  684. /**移动的次序(第几个移动的用来控制延迟移动的时间) */
  685. let movedIndex: number = 0;
  686. //移动位置间隔(比如前面两个空位就移动两格)
  687. let intervalNum: number = 0;
  688. /**是否是全部清理的x */
  689. let ifAllCleanedX: boolean = this.allCleanedXArr.indexOf(xIndex) != -1;
  690. /**是否是最后清理的x(全部清理完才开始左移) */
  691. let ifLastCleanX: boolean = (xIndex == this.cleanXIndexArr[this.cleanXIndexArr.length - 1]);
  692. let cellItemDic = GamePlay.Inst.cellItemDic[xIndex];
  693. //计算y方向移动的最后一位(这样只计算一次不用循环)
  694. let lastMoveCellItemY: number = null;
  695. let leftLastCellItemY: number = null;
  696. if (ifLastCleanX) {
  697. let lastCellItemArrSort = this.cleanedVecArr.filter((vec) => vec.x == xIndex).sort();
  698. lastMoveCellItemY = lastCellItemArrSort[0].y;
  699. // LogUtil.log("lastCellItemY", xIndex, lastMoveCellItemY, lastCellItemArrSort);
  700. for (var i = 0; i < GameConst.row_num; i++) {
  701. if (cellItemDic) {
  702. let cellItem = cellItemDic[i];
  703. if (cellItem) {
  704. leftLastCellItemY = cellItem.y;
  705. // LogUtil.log("leftLastCellItemY", leftLastCellItemY);
  706. break;
  707. }
  708. }
  709. }
  710. // let leftCellItemArrSort = this.cl
  711. }
  712. //如果最后一行 并且 是被全部清除的x
  713. if (ifLastCleanX && ifAllCleanedX) {
  714. // LogUtil.log("【checkMoveLeftCellItem】检测消除 全部消除的一列就是消除xIndex中最后一列");
  715. this.checkMoveLeftCellItem();
  716. return;
  717. }
  718. //y方向从下至上循环排查
  719. for (var i = GameConst.row_num - 1; i >= 0; i--) {
  720. if (cellItemDic) {
  721. let cellItem = cellItemDic[i];
  722. //该xIndex纵列没有全部移除
  723. if (cellItem) {
  724. if (ifLastCleanX && i == leftLastCellItemY) {
  725. // LogUtil.log("【checkMoveLeftCellItem】检测消除 移除了最后一个");
  726. cellItem.moveDown(xIndex, i + intervalNum, movedIndex, true);
  727. }
  728. else {
  729. cellItem.moveDown(xIndex, i + intervalNum, movedIndex);
  730. }
  731. movedIndex++;
  732. }
  733. else {
  734. intervalNum += 1;
  735. }
  736. }
  737. else {
  738. continue;
  739. }
  740. }
  741. }
  742. /**检测向左移动的cellItem */
  743. checkMoveLeftCellItem() {
  744. //计算消除的纵列中,有没有被全部移除
  745. //let allCleanedXArr = GameUtil.getAllCleanXIndex(this.cleanXIndexArr);
  746. // LogUtil.log("[Game] checkMoveLeftCellItem allCleanXArr ---------------------", this.allCleanedXArr);
  747. //如果没有全部移除得就return
  748. if (this.allCleanedXArr.length <= 0) {
  749. //LogUtil.log("【checkMoveLeftCellItem】检测是否能消除 没有全部移除的");
  750. GamePlay.Inst.ifCouldClick = true;
  751. GamePlay.Inst.checkIfEliminate();
  752. return;
  753. }
  754. //剩余一列未移除的xIndex
  755. let leftXIndexArr: number[] = GameLogic.getLeftXIndexArr();
  756. let leftMaxXIndex: number = leftXIndexArr[leftXIndexArr.length - 1];
  757. if (leftXIndexArr.length <= 0) {
  758. //检测是否移除
  759. this.checkIfEliminate();
  760. }
  761. else {
  762. mk.console.log("leftXIndexArr", leftXIndexArr);
  763. let intervalNum: number = 0;
  764. for (var i = 0; i < GameConst.col_num; i++) {
  765. let cellItemArr = GamePlay.Inst.cellItemDic[i];
  766. if (this.allCleanedXArr.indexOf(i) == -1) {
  767. //剩余存在的cellItem
  768. let leftCellItemArr = cellItemArr.filter((cellItem) => cellItem != null);
  769. if (intervalNum > 0) {
  770. for (var j = 0; j < cellItemArr.length; j++) {
  771. let cellItem = cellItemArr[j];
  772. if (cellItem) {
  773. if (i == leftMaxXIndex && j == (leftCellItemArr[0].y)) {
  774. mk.console.log("i,j,intervalNum", i, j, intervalNum);
  775. cellItem.moveLeft(i - intervalNum, j, true);
  776. }
  777. else {
  778. cellItem.moveLeft(i - intervalNum, j);
  779. }
  780. }
  781. }
  782. }
  783. else {
  784. //对应 1 2 3 列 中 3全部消除
  785. if (i == leftMaxXIndex) {
  786. GamePlay.Inst.ifCouldClick = true;
  787. GamePlay.Inst.checkIfEliminate();
  788. }
  789. }
  790. }
  791. else {
  792. intervalNum += 1;
  793. }
  794. }
  795. }
  796. }
  797. public timeout_pass: number = null;
  798. /**检测是否能移除 */
  799. checkIfEliminate() {
  800. mk.console.log("开始检测是否还能够消除!!!!!!!!!!!!!!!!!!!!!");
  801. //FC:替换
  802. GameLogic.getCouldCleanVec();
  803. if (this.couldCleanVecArr.length <= 0 && !this.ifPass) {
  804. EffectMgr.Inst.addSpriteTip(TIP_SPRITEITEM_TYPE.NormalPass);
  805. let timeOut = setTimeout(() => {
  806. this.pass();
  807. clearTimeout(timeOut);
  808. }, 1500);
  809. }
  810. //FC:正式使用
  811. // let timeOut = setTimeout(() => {
  812. // GameUtil.getCouldCleanVec();
  813. // if (this.couldCleanVecArr.length <= 0 && !this.ifPass) {
  814. // this.pass();
  815. // }
  816. // clearTimeout(timeOut);
  817. // }, 1500);
  818. }
  819. getCouldCleanCellItem() {
  820. for (var i = 0; this.cellItemArr.length; i++) {
  821. let cellItem = this.cellItemArr[i];
  822. let aroundSameType = GameLogic.getAroundSameType(cellItem.x, cellItem.y, cellItem.type, false);
  823. if (aroundSameType.length > 0) {
  824. return;
  825. }
  826. }
  827. //this.nextLevel();
  828. this.pass();
  829. //this.recycleAllCellItem();
  830. }
  831. /**restart
  832. * @param 是否扣除体力
  833. */
  834. restart() {
  835. mk.console.log("restart!!!!!!!!!!!!!!!")
  836. this.refreshGame();
  837. }
  838. /**下一关 */
  839. nextLevel() {
  840. mk.console.log("nextLevel!!!!!!!!!!!!!!!")
  841. this.targetScore = 0;//下一关才重置目标分数
  842. this.refreshGame();
  843. }
  844. /**刷新关卡 */
  845. refreshGame() {
  846. mk.data.sendDataEvent(DataEventId.level, "关卡开启");
  847. this.recycleAllCellItem();
  848. this.ifPass = false;
  849. this.ifGetPass = false;
  850. this.ifCouldClick = true;
  851. this.initLevel();
  852. this.initTotalScore();
  853. //FC:改成累分制而不是每关重置
  854. // this.curProgressScore = 0;
  855. // this.curGetScore = 0;
  856. // this.finalGetScore = 0;
  857. this.initScore();
  858. }
  859. /**回收所有的 */
  860. recycleAllCellItem() {
  861. for (var i = 0; i < GameConst.col_num; i++) {
  862. for (var j = 0; j < GameConst.row_num; j++) {
  863. let cellItem = this.cellItemDic[i][j];
  864. if (cellItem) {
  865. // mk.console.log("回收把>>>>>>>>>>>>>>>>>>>>>>");
  866. cellItem.recycle(true, false, false);
  867. }
  868. }
  869. }
  870. // while (this.cellItemList.length > 0) {
  871. // this.cellItemList.splice(0, 1);
  872. // this.cellItemList[0].recycle();
  873. // }
  874. this.cellItemArr = [];
  875. this.cellItemDic = {};
  876. this.curXIndex = 0;
  877. this.curYIndex = GameConst.row_num - 1;
  878. this.initCell();
  879. }
  880. /**通关 */
  881. pass() {
  882. //这边会多次进入
  883. if (GamePlay.Inst.node.active == false || this.ifPass) {
  884. return;
  885. }
  886. mk.data.sendDataEvent(DataEventId.level, "关卡通关");
  887. this.ifPass = true;
  888. GamePlay.Inst.ifGetPass = false;
  889. let levelNum = gData.gameData.getProp(GameProp.levelNum);
  890. if (levelNum == 0) {
  891. mk.data.sendXYEvent("firstlevel", "完成第一关");
  892. }
  893. mk.console.log("[Game]pass passLevelNum", levelNum);
  894. GamePlay.Inst.ifGetPass = true;
  895. gData.gameData.setProp(GameProp.levelNum, ++levelNum);
  896. if (gData.gameData.funOpenData['6'] == '1') {
  897. let node_rewardLuck = mk.ui.getCurOnPanel("rewardLuck");
  898. if (node_rewardLuck || this.finalGetScore >= this.targetScore) {
  899. return;
  900. }
  901. else {
  902. //游戏结算
  903. this.gameCount();
  904. console.log("gData.gameData.getProp(GameProp.levelNum)", gData.gameData.getProp(GameProp.levelNum));
  905. }
  906. }
  907. else {
  908. //游戏结算
  909. this.gameCount();
  910. console.log("gData.gameData.getProp(GameProp.levelNum)", gData.gameData.getProp(GameProp.levelNum));
  911. }
  912. }
  913. /**游戏结算 */
  914. gameCount() {
  915. let node_getPropUI = mk.ui.getCurOnPanel("GetPropUI");
  916. if (node_getPropUI) {
  917. mk.ui.closePanel("GetPropUI");
  918. }
  919. this.gameOver();
  920. }
  921. /**游戏结束 */
  922. gameOver() {
  923. mk.data.setTAEventUser(1, 'video_play_time', 1);
  924. mk.ui.openPanel("game/prefab/uiPanel/GameOverUI");
  925. }
  926. checkBonusNum(cleanCellItemNum: number) {
  927. if (cleanCellItemNum >= 4) {
  928. let node_bonusTip = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.BonusTip);
  929. let bonusTip = node_bonusTip.getComponent(BonusTip);
  930. //LogUtil.log("bonusTip",bonusTip);
  931. if (cleanCellItemNum == 4) {
  932. bonusTip.init(4);
  933. mk.audio.playEffect("ef_bonus4");
  934. }
  935. else if (cleanCellItemNum == 5) {
  936. bonusTip.init(5);
  937. mk.audio.playEffect("ef_bonus5");
  938. }
  939. else if (cleanCellItemNum == 6) {
  940. bonusTip.init(6);
  941. mk.audio.playEffect("ef_bonus6");
  942. }
  943. else if (cleanCellItemNum == 7) {
  944. bonusTip.init(7);
  945. mk.audio.playEffect("ef_bonus7");
  946. }
  947. else if (cleanCellItemNum == 8) {
  948. bonusTip.init(8);
  949. mk.audio.playEffect("ef_bonus8");
  950. }
  951. else {
  952. bonusTip.init(8);
  953. mk.audio.playEffect("ef_bonus8");
  954. }
  955. this.node_effectUI.addChild(node_bonusTip);
  956. }
  957. }
  958. checkAddLevelRedPacket(eliminateNum: number): boolean {
  959. let chance = (eliminateNum - 3) * 0.2;
  960. let random = Math.random();
  961. if (random < chance) {
  962. return true;
  963. }
  964. else {
  965. return false;
  966. }
  967. }
  968. public interval_ShowGuide: number = null;
  969. //间隔显示
  970. intervalShowGuide() {
  971. this.cancelShowCouldCleanCellItem();
  972. this.interval_ShowGuide = setInterval(() => {
  973. this.showCouldCleanCellItem();
  974. }, 10000);
  975. }
  976. /**显示 */
  977. showCouldCleanCellItem() {
  978. if (mk.ui.getCurOnPanel("RedPacketUI") || mk.ui.getCurOnPanel("GameOverUI") || !this.couldCleanVecArr || !this.cellItemDic) {
  979. return;
  980. }
  981. if (this.couldCleanVecArr.length <= 0) {
  982. GameLogic.getCouldCleanVec();
  983. }
  984. if (this.couldCleanVecArr.length > 0) {
  985. for (var i = 0; i < this.couldCleanVecArr.length; i++) {
  986. let vec = this.couldCleanVecArr[i];
  987. if (this.cellItemDic[vec.x]) {
  988. let cellItem = this.cellItemDic[vec.x][vec.y];
  989. if (cellItem) {
  990. cellItem.shake();
  991. }
  992. }
  993. else {
  994. }
  995. }
  996. }
  997. }
  998. /**取消显示 */
  999. cancelShowCouldCleanCellItem() {
  1000. if (this.interval_ShowGuide) {
  1001. clearInterval(this.interval_ShowGuide);
  1002. this.interval_ShowGuide = null;
  1003. if (this.couldCleanVecArr.length > 0) {
  1004. for (var i = 0; i < this.couldCleanVecArr.length; i++) {
  1005. let vec = this.couldCleanVecArr[i];
  1006. let cellItem = this.cellItemDic[vec.x][vec.y];
  1007. if (cellItem) {
  1008. cellItem.normal();
  1009. }
  1010. }
  1011. }
  1012. this.couldCleanVecArr = [];
  1013. }
  1014. }
  1015. public interval_ShowInter: number = null;
  1016. //间隔显示
  1017. intervalShowInter() {
  1018. let time = gData.gameData.configs.ServerConfig.interOpenGapTime;
  1019. if (!time) {
  1020. time = 15000;
  1021. }
  1022. else {
  1023. time *= 1000;
  1024. }
  1025. this.cancelShowInter();
  1026. this.interval_ShowGuide = setInterval(() => {
  1027. mk.ad.showInterAd(0);
  1028. }, time);
  1029. }
  1030. cancelShowInter() {
  1031. if (this.interval_ShowGuide) {
  1032. clearInterval(this.interval_ShowGuide);
  1033. }
  1034. }
  1035. /**
  1036. * 气泡红包是否开启
  1037. */
  1038. private qipaoShow() {
  1039. for (let i = 0; i < 4; i++) {
  1040. this['btn_gameGetRed' + (i + 1)].active = gData.gameData.funBtns.btn8.active;
  1041. }
  1042. }
  1043. public doBubbleRedPacketLogic(dt) {
  1044. if (!this.isShowRedPacket) {
  1045. return;
  1046. }
  1047. if (this.isAllShow) {
  1048. if(gData.gameData.redPacketShowCount != 0)
  1049. {
  1050. gData.gameData.redPacketShowCount = 0;
  1051. }
  1052. return;
  1053. }
  1054. let count = 0;
  1055. let len = gData.gameData.redPacketShowCount;
  1056. for(let i = 0; i != len; ++i)
  1057. {
  1058. if (!this.btn_gameGetRed1.active) {
  1059. this.btn_gameGetRed1.active = true;
  1060. ++count;
  1061. continue;
  1062. } else if (!this.btn_gameGetRed2.active) {
  1063. this.btn_gameGetRed2.active = true;
  1064. ++count;
  1065. continue;
  1066. } else if (!this.btn_gameGetRed3.active) {
  1067. this.btn_gameGetRed3.active = true;
  1068. ++count;
  1069. continue;
  1070. } else if (!this.btn_gameGetRed4.active) {
  1071. this.btn_gameGetRed4.active = true;
  1072. ++count;
  1073. continue;
  1074. }
  1075. this.isAllShow = true;
  1076. gData.gameData.redPacketShowCount = 0;
  1077. count = 0;
  1078. }
  1079. if(count > 0)
  1080. {
  1081. gData.gameData.redPacketShowCount -= count;
  1082. }
  1083. }
  1084. private refreshRedPacketUI(index) {
  1085. gData.gameData.openIndex = -1;
  1086. if (index == 4) {
  1087. this.btn_gameGetRed1.active = false;
  1088. if (this.isAllShow) {
  1089. this.isAllShow = false;
  1090. }
  1091. } else if (index == 5) {
  1092. this.btn_gameGetRed2.active = false;
  1093. if (this.isAllShow) {
  1094. this.isAllShow = false;
  1095. }
  1096. } else if (index == 6) {
  1097. this.btn_gameGetRed3.active = false;
  1098. if (this.isAllShow) {
  1099. this.isAllShow = false;
  1100. }
  1101. } else if (index == 7) {
  1102. this.btn_gameGetRed4.active = false;
  1103. if (this.isAllShow) {
  1104. this.isAllShow = false;
  1105. }
  1106. }
  1107. }
  1108. }