FightResultPanel.ts 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import CashOutData from "../datas/CashOutData";
  8. import { HTTP_TYPE } from "../datas/CommonData";
  9. import { FightData, FightResult } from "../datas/FightData";
  10. import { MateData } from "../datas/MateData";
  11. import { RichData } from "../datas/RichData";
  12. import AdM from "../manager/AdM";
  13. import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM";
  14. import GuideMng from "../manager/GuideMng";
  15. import HttpM from "../manager/HttpM";
  16. import UiM, { PANEL_NAME } from "../manager/UiM";
  17. import MyExtends from "../tools/MyExtends";
  18. import Time from "../tools/Time";
  19. import BasePanel from "../uiFrames/BasePanel";
  20. import UIMng, { PanelType } from "../uiFrames/UIMng";
  21. import Random from "../utils/Random";
  22. import Sciencen_M from "../utils/Sciencen_M";
  23. import CashOut from "./CashOut";
  24. import EffectNode from "./EffectNode";
  25. const { ccclass, property } = cc._decorator;
  26. @ccclass
  27. export default class FightResultPanel extends BasePanel {
  28. @property(cc.Node)
  29. panelNode: cc.Node = null;
  30. @property(cc.Node)
  31. successNode: cc.Node = null;
  32. @property(cc.Node)
  33. title: cc.Node = null;
  34. @property(cc.Node)
  35. stars: cc.Node[] = [];
  36. @property(cc.Node)
  37. rectNode: cc.Node = null;
  38. @property(cc.Node)
  39. boxNode: cc.Node = null;
  40. @property(sp.Skeleton)
  41. boxs: sp.Skeleton[] = [];
  42. @property(cc.Node)
  43. box_qipao: cc.Node = null;
  44. @property(cc.Node)
  45. rds: cc.Node[] = [];
  46. @property(cc.Sprite)
  47. rds_imgs: cc.Sprite[] = [];
  48. @property(cc.Label)
  49. rds_txts: cc.Label[] = [];
  50. @property(cc.Label)
  51. rds_tipTxts: cc.Label[] = [];
  52. @property(cc.Node)
  53. rds_lightbox: cc.Node[] = [];
  54. @property(cc.Node)
  55. rd_tianfu: cc.Node = null;
  56. @property(cc.Label)
  57. rd_tianfu_txt: cc.Label = null;
  58. //@property(cc.Node)
  59. //btnOpen: cc.Node = null;
  60. @property(cc.Node)
  61. failNode: cc.Node = null;
  62. @property(cc.Sprite)
  63. failRoleImg: cc.Sprite = null;
  64. @property(cc.Node)
  65. cashNode: cc.Node = null;
  66. @property(cc.Sprite)
  67. cashImg: cc.Sprite = null;
  68. @property(cc.Label)
  69. cashTxt: cc.Label = null;
  70. @property(cc.Node)
  71. rewardNo: cc.Node = null;
  72. @property(cc.Node)
  73. rewardNode: cc.Node = null;
  74. @property(cc.Label)
  75. rewardRemaindeTxt: cc.Label = null;
  76. @property(cc.Node)
  77. btnCash: cc.Node = null;
  78. @property(cc.Node)
  79. btnSure: cc.Node = null;
  80. @property(cc.Node)
  81. btnAdSure: cc.Node = null;
  82. @property(cc.Node)
  83. btnAdRich: cc.Node = null;
  84. @property(cc.Node)
  85. btnBack: cc.Node = null;
  86. @property(cc.Node)
  87. btnNor: cc.Node = null;
  88. @property(cc.Node)
  89. btnClose: cc.Node = null;
  90. private result: FightResult = null;
  91. private boxInitPos: cc.Vec2 = cc.v2();
  92. private rewardCfg: any = null;
  93. private rewardList: any[] = null;
  94. private rewardCoin: string = '';
  95. private rewardBoxIndex: number = 0;
  96. private isDoubleReward: boolean = false;
  97. private isCanClickBtn: boolean = true;
  98. private isClickRichAd: boolean = false;
  99. private richDoubleIndex: number = -1;
  100. /**大富翁除了 双倍卡之外的奖励盒子索引数组*/
  101. private richBoxList: number[] = [];
  102. onLoad() {
  103. this.boxInitPos = this.boxNode.getPosition();
  104. /*
  105. GameM.commonData.updateGold(num)
  106. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  107. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  108. */
  109. }
  110. OnEnter(param: any) {
  111. this.result = param;
  112. this.rewardCoin = "";
  113. this.isDoubleReward = false;
  114. this.isCanClickBtn = true;
  115. this.successNode.active = this.result.result == 1;
  116. this.failNode.active = this.result.result != 1;
  117. this.rewardRemaindeTxt.node.active = this.result.fightType == 2;
  118. this.rewardRemaindeTxt.string = this.result.reward_times > 0 ? "今日剩余奖励次数:" + this.result.reward_times : "";
  119. this.btnAdRich.active = false;
  120. this.btnNor.active = false;
  121. this.richDoubleIndex = -1;
  122. //this.rewardRemaindeTxt.string
  123. if (this.result.fightType == 2) {
  124. let haveRward = this.result.rewards != null && this.result.rewards.length > 0;
  125. this.rewardNode.active = haveRward;
  126. this.btnClose.active = haveRward;
  127. this.btnAdSure.active = haveRward;
  128. this.btnSure.active = !haveRward;
  129. this.rewardNo.active = !haveRward;
  130. }
  131. else if (this.result.fightType == 3) {
  132. //大富翁战斗
  133. let haveRward = this.result.rewards != null && this.result.rewards.length > 0;
  134. this.rewardNode.active = haveRward;
  135. this.btnClose.active = haveRward;
  136. this.btnAdSure.active = haveRward;
  137. this.btnSure.active = !haveRward;
  138. this.rewardNo.active = !haveRward;
  139. this.isClickRichAd = false;
  140. this.richBoxList = [];
  141. }
  142. else {
  143. //不显示宝箱奖励 改为提现
  144. this.rewardNode.active = false;
  145. //this.rewardNode.active = true;
  146. this.btnSure.active = false;
  147. this.btnAdSure.active = false;
  148. this.btnClose.active = true;
  149. this.rewardNo.active = false;
  150. }
  151. if (this.result.result == 1) {
  152. GameM.audioM.playEffect(AUDIO_TYPE.victory);
  153. for (let i = 0; i < this.boxs.length; i++) {
  154. cc.Tween.stopAllByTarget(this.stars[i]);
  155. this.stars[i].scale = 20;
  156. this.stars[i].active = false;
  157. if (i + 1 == this.result.star) {
  158. this.rewardBoxIndex = i;
  159. this.boxs[i].node.active = true;
  160. } else {
  161. this.boxs[i].node.active = false;
  162. }
  163. }
  164. if (this.result.fightType == 2) {
  165. //战斗二 正常领取奖励
  166. this.cashNode.active = false;
  167. this.btnCash.active = false;
  168. this.btnClose.active = false;
  169. this.btnAdSure.active = false;
  170. this.boxNode.scale = 1;
  171. this.box_qipao.active = true;
  172. //this.box.color = this.GetBoxColor();
  173. this.boxs[this.rewardBoxIndex].setAnimation(0, "idle", true);
  174. if (this.result.rewards != null) {
  175. this.rewardList = this.result.rewards;
  176. //this.rewardList = this.rewardList.sort((a, b) => { return a.reward_id - b.reward_id });
  177. console.log("----->rewardList:", this.rewardList);
  178. for (let n of this.rds) {
  179. n.setPosition(this.boxInitPos);
  180. n.active = false;
  181. }
  182. this.rd_tianfu.setPosition(this.boxInitPos);
  183. this.rd_tianfu.active = false;
  184. for (let i = 0; i < this.rewardList.length; i++) {
  185. cc.loader.loadRes("xiyou/icon/reward" + this.rewardList[i].code, cc.SpriteFrame, (err, res) => {
  186. if (err) { console.log("img load err:" + JSON.stringify(err)); }
  187. this.rds_imgs[i].spriteFrame = res;
  188. });
  189. this.rds_lightbox[i].active = false;
  190. if (this.rewardList[i].code == "10001") {
  191. let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  192. num = Sciencen_M.instance.accMul(num, this.rewardList[i].count.toString());
  193. this.rewardCoin = num;
  194. this.rds_txts[i].string = Sciencen_M.instance.format(num);
  195. } else {
  196. this.rds_txts[i].string = this.rewardList[i].count.toString();
  197. }
  198. this.rds_tipTxts[i].string = this.rewardList[i].name;
  199. this.rds[i].getChildByName("AdIcon").active = false;// this.rewardList[i].code == "30005";
  200. }
  201. this.rd_tianfu_txt.string = this.result.talent.toString();
  202. this.rectNode.height = this.rewardList.length + 1 > 3 ? 430 : 215;
  203. this.title.y = this.rewardList.length + 1 > 3 ? 390 : 460;
  204. this.InitRewardData();
  205. }
  206. // AdM.onSendEvent(`fight_old_win`, `旧怪触发战斗胜利`, 'fight_old_win');
  207. }
  208. else if (this.result.fightType == 3) {
  209. //战斗三 大富翁奖励
  210. this.cashNode.active = false;
  211. this.btnCash.active = false;
  212. this.btnClose.active = false;
  213. this.btnAdSure.active = false;
  214. this.boxNode.scale = 1;
  215. this.box_qipao.active = true;
  216. //this.box.color = this.GetBoxColor();
  217. this.boxs[this.rewardBoxIndex].setAnimation(0, "idle", true);
  218. if (this.result.rewards != null) {
  219. this.rewardList = this.result.rewards;
  220. //this.rewardList = this.rewardList.sort((a, b) => { return a.reward_id - b.reward_id });
  221. console.log("----->rewardList:", this.rewardList);
  222. for (let n of this.rds) {
  223. n.setPosition(this.boxInitPos);
  224. n.active = false;
  225. }
  226. this.rd_tianfu.setPosition(this.boxInitPos);
  227. this.rd_tianfu.active = false;
  228. for (let i = 0; i < this.rewardList.length; i++) {
  229. cc.loader.loadRes("xiyou/icon/reward" + this.rewardList[i].code, cc.SpriteFrame, (err, res) => {
  230. if (err) { console.log("img load err:" + JSON.stringify(err)); }
  231. this.rds_imgs[i].spriteFrame = res;
  232. });
  233. if (this.rewardList[i].code == "10001") {
  234. let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  235. num = Sciencen_M.instance.accMul(num, this.rewardList[i].count.toString());
  236. this.rewardCoin = num;
  237. this.rds_txts[i].string = Sciencen_M.instance.format(num);
  238. this.richBoxList.push(i);
  239. this.rds_lightbox[i].active = false;
  240. }
  241. else if (this.rewardList[i].code == "30005") {
  242. this.richDoubleIndex = i;
  243. this.rds_txts[i].string = this.rewardList[i].count.toString();
  244. this.rds_lightbox[i].active = true;
  245. }
  246. else {
  247. this.rds_txts[i].string = this.rewardList[i].count.toString();
  248. this.rds_lightbox[i].active = false;
  249. this.richBoxList.push(i);
  250. }
  251. this.rds[i].getChildByName("AdIcon").active = this.rewardList[i].code == "30005";
  252. this.rds_tipTxts[i].string = this.rewardList[i].name;
  253. }
  254. this.rd_tianfu_txt.string = this.result.talent.toString();
  255. this.rectNode.height = this.rewardList.length > 3 ? 430 : 215;
  256. this.title.y = this.rewardList.length + 1 > 3 ? 390 : 460;
  257. this.InitRewardData();
  258. }
  259. AdM.onSendEvent('Qujing_Fight_Win', '取经战斗胜利', "qujing");
  260. }
  261. else {
  262. //战斗一 提现
  263. this.cashNode.active = true;
  264. this.btnClose.active = false;
  265. this.btnCash.active = true;
  266. cc.loader.loadRes('carPic/side/side_' + this.result.lv, cc.SpriteFrame, (err, res) => {
  267. if (err) { console.log("img load err:" + JSON.stringify(err)); }
  268. this.cashImg.spriteFrame = res;
  269. });
  270. let cfg = CashOutData.Instance.cashCft;
  271. let len = cfg.length;
  272. for (var i = 0; i < len; i++) {
  273. if (cfg[i].type_value == this.result.lv) {
  274. this.cashTxt.string = cfg[i].moneyshow.split('~')[1];
  275. break;
  276. }
  277. }
  278. if (this.result.lv == 14) {
  279. GuideMng.Ins.CheckCashGuide14();
  280. }
  281. // AdM.onSendEvent(`fight_new_win_${this.result.lv}`, `${GameM.commonData.fightRoleCfg[this.result.lv.toString()].name}`, 'fight_new_win')
  282. }
  283. this.PlayStarAni();
  284. } else {
  285. GameM.audioM.playEffect(AUDIO_TYPE.fail);
  286. cc.loader.loadRes('carPic/side/side_' + this.result.lv, cc.SpriteFrame, (err, res) => {
  287. if (err) { console.log("img load err:" + JSON.stringify(err)); }
  288. this.failRoleImg.spriteFrame = res;
  289. });
  290. this.btnClose.active = false;
  291. if (this.result.fightType == 1) {
  292. // AdM.onSendEvent(`fight_new_fail_${this.result.lv}`, `${GameM.commonData.fightRoleCfg[this.result.lv.toString()].name}`, 'fight_new_fail')
  293. } else {
  294. // AdM.onSendEvent(`fight_old_fail`, `旧怪触发战斗失败`, 'fight_old_fail');
  295. }
  296. }
  297. this.panelNode.scale = 0;
  298. this.node.active = true;
  299. cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" }).start();
  300. this.node.setSiblingIndex(this.node.parent.childrenCount - 1);
  301. }
  302. OnExit() {
  303. this.node.active = false;
  304. //进行货币获取计算
  305. this.RewardCalculate();
  306. //解锁伙伴判断
  307. if (this.result.fightType == 1 && this.result.result == 1) {
  308. //if (this.result.unlock_mateid != null && this.result.unlock_mateid !== "") {
  309. // let mateid = Number(this.result.unlock_mateid);
  310. // //解锁伙伴
  311. // FightData.Ins.UnlockMate(mateid, this.result.lv);
  312. //}
  313. if (this.result.lv == 7) {
  314. //西游
  315. //提现引导 弃用
  316. // GuideMng.Ins.CheckCashGuide10();
  317. }
  318. //if (this.result.lv == 5 || this.result.lv == 12 || this.result.lv == 19 || this.result.lv == 21) {
  319. // let mateid = 2;
  320. // if (this.result.lv == 5)
  321. // mateid = 2;
  322. // else if (this.result.lv == 12)
  323. // mateid = 3;
  324. // else if (this.result.lv == 19)
  325. // mateid = 4;
  326. // else if (this.result.lv == 21)
  327. // mateid = 5;
  328. // FightData.Ins.UnlockMate(mateid, this.result.lv);
  329. //}
  330. }
  331. }
  332. async PlayStarAni() {
  333. let posAry: cc.Vec2[] = [];
  334. if (this.result.star < 1) { return; }
  335. else {
  336. if (this.result.star == 1) {
  337. posAry.push(cc.v2(0, 15));
  338. } else if (this.result.star == 2) {
  339. posAry.push(cc.v2(-40, 15));
  340. posAry.push(cc.v2(40, 15));
  341. } else if (this.result.star == 3) {
  342. posAry.push(cc.v2(-80, 3));
  343. posAry.push(cc.v2(0, 15));
  344. posAry.push(cc.v2(80, 3));
  345. }
  346. }
  347. let index = 0;
  348. for (let i = 0; i < this.stars.length; i++) {
  349. if (i + 1 <= this.result.star) {
  350. this.stars[i].scale = 20;
  351. this.stars[i].active = true;
  352. console.log("POS:" + posAry[index].y);
  353. this.stars[i].setPosition(posAry[index]);
  354. cc.tween(this.stars[i]).to(0.15, { scale: 1 }).start();
  355. index++;
  356. await Time.WaitForSeconds(0.2);
  357. }
  358. }
  359. }
  360. GetBoxColor() {
  361. switch (this.result.star) {
  362. case 1:
  363. return cc.color(100, 100, 100, 255);
  364. case 2:
  365. return cc.color(56, 150, 126, 255);
  366. case 3:
  367. return cc.color(255, 255, 0, 255);
  368. }
  369. /*
  370. [
  371. {1: 0.4},
  372. {2: 2},
  373. {3: 4}
  374. ]
  375. */
  376. }
  377. RewardCalculate() {
  378. if (this.result.result == 1) {
  379. if (this.result.fightType == 2) {
  380. let times = this.isDoubleReward ? 2 : 1;
  381. MateData.Ins.talentCoin += this.result.talent * times;
  382. //更新红点
  383. MateData.Ins.checkMateRedPoint()
  384. if (this.result.rewards != null) {
  385. for (let i = 0; i < this.rewardList.length; i++) {
  386. if (this.rewardList[i].code == "10001") {
  387. if (this.isDoubleReward)
  388. this.rewardCoin = Sciencen_M.instance.accMul(this.rewardCoin, "2");
  389. GameM.commonData.updateGold(this.rewardCoin);
  390. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false);
  391. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  392. } else if (this.rewardList[i].code == "10002") {
  393. GameM.commonData.updateRedMoney(this.rewardList[i].count * times)
  394. } else if (this.rewardList[i].code == "20002") {
  395. GameM.commonData.roleData.turntableCard += this.rewardList[i].count * times;
  396. } else if (this.rewardList[i].code == "20001") {
  397. GameM.commonData.roleData.speedCard += this.rewardList[i].count * times;
  398. } else if (this.rewardList[i].code == "20003") {
  399. GameM.commonData.roleData.ticket += this.rewardList[i].count * times;
  400. }
  401. }
  402. }
  403. GameM.commonData.updateRoleData();
  404. }
  405. else if (this.result.fightType == 3) {
  406. //return;
  407. //更新红点
  408. MateData.Ins.checkMateRedPoint()
  409. if (this.result.rewards != null) {
  410. let richDice: any = null;
  411. let rewardefts: number[] = [];
  412. for (let i = 0; i < this.rewardList.length; i++) {
  413. if (this.rewardList[i].code == "10001") {
  414. //if (this.isDoubleReward)
  415. // this.rewardCoin = Sciencen_M.instance.accMul(this.rewardCoin, "2");
  416. GameM.commonData.updateGold(this.rewardCoin);
  417. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false);
  418. //EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  419. rewardefts.push(10001);
  420. } else if (this.rewardList[i].code == "10002") {
  421. GameM.commonData.updateRedMoney(this.rewardList[i].count)
  422. } else if (this.rewardList[i].code == "20002") {
  423. GameM.commonData.roleData.turntableCard += this.rewardList[i].count;
  424. } else if (this.rewardList[i].code == "20001") {
  425. GameM.commonData.roleData.speedCard += this.rewardList[i].count;
  426. } else if (this.rewardList[i].code == "20003") {
  427. GameM.commonData.roleData.ticket += this.rewardList[i].count;
  428. } else if (this.rewardList[i].code == "20006") {
  429. MateData.Ins.talentCoin += this.rewardList[i].count;
  430. } else if (this.rewardList[i].code == "30001") {
  431. if (richDice == null) richDice = {};
  432. richDice.diceAdNum = this.rewardList[i].count;
  433. } else if (this.rewardList[i].code == "30002") {
  434. if (richDice == null) richDice = {};
  435. richDice.remoteCtrlNum = this.rewardList[i].count;
  436. rewardefts.push(30002);
  437. } else if (this.rewardList[i].code == "30004") {
  438. if (richDice == null) richDice = {};
  439. richDice.scriptureNum = this.rewardList[i].count;
  440. } else if (this.rewardList[i].code == "30005") {
  441. if (this.isClickRichAd) {
  442. if (richDice == null) richDice = {};
  443. richDice.doubleNum = this.rewardList[i].count;
  444. rewardefts.push(30005);
  445. AdM.onSendEvent('Qujing_GetDouble', '取经获得双倍卡', "qujing");
  446. }
  447. }
  448. }
  449. if (richDice != null) {
  450. //进入取经战斗 前提就是满足奖励条件下
  451. richDice.rewardNum = 1;
  452. RichData.Ins.UpdateItemCard2(richDice, () => {
  453. for (let i = 0; i < rewardefts.length; i++) {
  454. if (rewardefts[i] == 10001) {
  455. RichData.Ins.PlayParticleEft(10001, 1, this.node);
  456. } else if (rewardefts[i] == 30002) {
  457. RichData.Ins.PlayParticleEft(30002, 3, this.node);
  458. } else if (rewardefts[i] == 30005) {
  459. RichData.Ins.PlayParticleEft(30005, 4, this.node);
  460. }
  461. }
  462. }, false);
  463. console.log("---->RichDice:", richDice);
  464. } else {
  465. for (let i = 0; i < rewardefts.length; i++) {
  466. if (rewardefts[i] == 10001) {
  467. RichData.Ins.PlayParticleEft(10001, 1, this.node);
  468. }
  469. }
  470. }
  471. console.log("---->RichDice End:", richDice);
  472. GameM.commonData.updateRoleData();
  473. }
  474. //引导取经 大富翁
  475. GuideMng.Ins.CheckRichGuide22();
  476. EffectNode.instance.PlayTip("恭喜获得奖励");
  477. }
  478. }
  479. }
  480. private num: number = 0;
  481. private totalNum: number = 0
  482. private curNumIndex: number = 0;
  483. private leftPosX: number = 0;
  484. private boxPosY1: number = -80;
  485. private boxPosY2: number = -290;
  486. private isCanClick: boolean = false;
  487. InitRewardData() {
  488. this.num = this.rewardList.length; //除了天赋点的奖品
  489. this.totalNum = this.num + (this.result.talent > 0 ? 1 : 0);
  490. this.curNumIndex = 0;
  491. if (this.totalNum >= 3) {
  492. this.leftPosX = -180;
  493. } else {
  494. this.leftPosX = -((this.totalNum - 1) * 180 / 2);
  495. }
  496. this.isCanClick = true;
  497. }
  498. async Click_Box() {
  499. if (this.curNumIndex < this.totalNum && this.isCanClick) {
  500. this.isCanClick = false;
  501. if (this.box_qipao.active) this.box_qipao.active = false;
  502. if (this.curNumIndex < this.totalNum - 1) {
  503. this.boxs[this.rewardBoxIndex].setAnimation(0, "open", false);
  504. await Time.WaitForSeconds(0.3);
  505. GameM.audioM.playEffect(AUDIO_TYPE.box_open);
  506. this.rds[this.curNumIndex].active = true;
  507. if (this.curNumIndex <= 2)
  508. this.rds[this.curNumIndex].runAction(cc.jumpTo(0.2, cc.v2(this.leftPosX + 180 * this.curNumIndex, this.boxPosY1), 200, 1));
  509. else
  510. this.rds[this.curNumIndex].runAction(cc.jumpTo(0.2, cc.v2(this.leftPosX + 180 * (this.curNumIndex - 3), this.boxPosY2), 200, 1));
  511. this.curNumIndex++;
  512. this.isCanClick = true;
  513. } else {
  514. //最后一个奖励 如果有天赋石就放最后一个显示
  515. if (this.result.talent > 0) {
  516. this.boxs[this.rewardBoxIndex].setAnimation(0, "turn on", false);
  517. await Time.WaitForSeconds(0.3);
  518. GameM.audioM.playEffect(AUDIO_TYPE.box_open);
  519. this.rd_tianfu.active = true;
  520. if (this.totalNum <= 3)
  521. this.rd_tianfu.runAction(cc.jumpTo(0.2, cc.v2(this.leftPosX + 180 * this.curNumIndex, this.boxPosY1), 200, 1));
  522. else
  523. this.rd_tianfu.runAction(cc.jumpTo(0.2, cc.v2(this.leftPosX + 180 * (this.totalNum - 4), this.boxPosY2), 200, 1));
  524. } else {
  525. this.boxs[this.rewardBoxIndex].setAnimation(0, "turn on", false);
  526. await Time.WaitForSeconds(0.3);
  527. GameM.audioM.playEffect(AUDIO_TYPE.box_open);
  528. this.rds[this.curNumIndex].active = true;
  529. if (this.curNumIndex <= 2)
  530. this.rds[this.curNumIndex].runAction(cc.jumpTo(0.2, cc.v2(this.leftPosX + 180 * this.curNumIndex, this.boxPosY1), 200, 1));
  531. else
  532. this.rds[this.curNumIndex].runAction(cc.jumpTo(0.2, cc.v2(this.leftPosX + 180 * (this.curNumIndex - 3), this.boxPosY2), 200, 1));
  533. }
  534. await Time.WaitForSeconds(1);
  535. if (this.result.fightType == 2) {
  536. this.btnClose.active = true;
  537. this.btnAdSure.active = true;
  538. }
  539. else if (this.result.fightType == 3) {
  540. if (this.richDoubleIndex != -1) {
  541. this.btnClose.active = true;
  542. this.btnAdRich.active = true;
  543. }
  544. else {
  545. this.btnNor.active = true;
  546. }
  547. }
  548. }
  549. }
  550. }
  551. Click_CashBtn() {
  552. this.OnExit();
  553. //AdM.onSendEvent('click7', '提现点击')
  554. GameM.audioM.playEffect(AUDIO_TYPE.button)
  555. if (!GameM.commonData.redSwitch) {
  556. EffectNode.instance.PlayTip('敬请期待')
  557. return
  558. }
  559. if (GameM.commonData.maxCarLevel < GameM.commonData.cashOpenLevel) {
  560. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.cashOpenLevel}级武将可查看`)
  561. return
  562. }
  563. UiM.Instance.onPanel(PANEL_NAME.CashNode, true, () => {
  564. UiM.Instance.cashNode.getComponent(CashOut).showGuide()
  565. })
  566. }
  567. //双倍领取
  568. Click_AdSureBtn() {
  569. if (!this.isCanClickBtn) return;
  570. this.isCanClickBtn = false;
  571. this.scheduleOnce(() => {
  572. this.isCanClickBtn = true;
  573. }, 3);
  574. //this.AdDoubleEnd();
  575. GameM.adM.watchVideo(VIDEO_TYPE.fight2Double);
  576. GameM.audioM.playEffect(AUDIO_TYPE.button);
  577. this.scheduleOnce(() => {
  578. this.isCanClickBtn = true;
  579. }, 3);
  580. }
  581. AdDoubleEnd() {
  582. HttpM.Instance.SendData(HTTP_TYPE.battleDoubleAward, { battleId: this.result.fightId, getType: 2 }, (res) => {
  583. console.log("-->double:", res);
  584. if (res.errcode == 0) {
  585. this.isDoubleReward = true;
  586. this.OnExit();
  587. }
  588. this.isCanClickBtn = true;
  589. });
  590. // AdM.onSendEvent(`fight_award_double`, `战斗2双倍奖励`, 'fight_award_double');
  591. }
  592. /**大富翁 我全都要*/
  593. Click_AdRichBtn() {
  594. if (!this.isCanClickBtn) return;
  595. this.isCanClickBtn = false;
  596. this.scheduleOnce(() => {
  597. this.isCanClickBtn = true;
  598. }, 3);
  599. //this.AdDoubleEnd();
  600. GameM.adM.watchVideo(VIDEO_TYPE.richFightAd);
  601. GameM.audioM.playEffect(AUDIO_TYPE.button);
  602. this.scheduleOnce(() => {
  603. this.isCanClickBtn = true;
  604. }, 3);
  605. AdM.onSendEvent(`video_init_16`, `取经战斗-全部奖励视频拉起`, 'video_init');
  606. }
  607. /**大富翁 我全都要视频结束*/
  608. AdRichEnd() {
  609. //if (res.errcode == 0) {
  610. this.isClickRichAd = true;
  611. this.OnExit();
  612. //}
  613. this.isCanClickBtn = true;
  614. //AdM.onSendEvent(`fight_award_double`, `战斗2双倍奖励`, 'fight_award_double');
  615. }
  616. Click_CloseBtn() {
  617. if (!this.isCanClickBtn) return;
  618. this.isCanClickBtn = false;
  619. //UIMng.Ins.GetPanel(PanelType.FightUpPanel).OnEnter();
  620. if (this.result.fightType == 3) {
  621. if (this.richDoubleIndex != -1) {
  622. cc.tween(this.rds[this.richDoubleIndex])
  623. .to(0.5, { opacity: 0 })
  624. .call(() => {
  625. this.rds[this.richDoubleIndex].active = false; this.rds[this.richDoubleIndex].opacity = 255;
  626. for (let i = 0; i < this.richBoxList.length; i++) {
  627. this.rds[this.richBoxList[i]].runAction(cc.moveBy(0.5, cc.v2(90, 0)));
  628. }
  629. this.scheduleOnce(() => {
  630. this.isCanClickBtn = true;
  631. this.OnExit();
  632. if (this.result.result != 1) {
  633. //UIMng.Ins.GetPanel(PanelType.FightUpPanel).OnEnter();
  634. }
  635. }, 1);
  636. })
  637. .start();
  638. } else {
  639. this.scheduleOnce(() => {
  640. this.isCanClickBtn = true;
  641. }, 3);
  642. this.OnExit();
  643. if (this.result.result != 1) {
  644. //UIMng.Ins.GetPanel(PanelType.FightUpPanel).OnEnter();
  645. }
  646. }
  647. AdM.onSendEvent('Qujing_Fight_CommonReward', '取经战斗-普通奖励领取', "qujing");
  648. } else {
  649. this.scheduleOnce(() => {
  650. this.isCanClickBtn = true;
  651. }, 3);
  652. this.OnExit();
  653. if (this.result.result != 1) {
  654. //UIMng.Ins.GetPanel(PanelType.FightUpPanel).OnEnter();
  655. }
  656. }
  657. GameM.audioM.playEffect(AUDIO_TYPE.button);
  658. }
  659. }