RichPropPanel.ts 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import { RichData, RichPropItemParam } from "../datas/RichData";
  2. import AdM from "../manager/AdM";
  3. import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM";
  4. import GuideMng from "../manager/GuideMng";
  5. import UiM from "../manager/UiM";
  6. import RoadItem from "../other/item/RoadItem";
  7. import Roads from "../other/item/Roads";
  8. import MyExtends from "../tools/MyExtends";
  9. import BasePanel from "../uiFrames/BasePanel";
  10. import Random from "../utils/Random";
  11. import EffectNode from "./EffectNode";
  12. const { ccclass, property } = cc._decorator;
  13. @ccclass
  14. export default class RichPropPanel extends BasePanel {
  15. @property(cc.Node)
  16. panelNode: cc.Node = null;
  17. @property(cc.Node)
  18. panel_ctrl: cc.Node = null;
  19. @property(cc.Node)
  20. panel_double: cc.Node = null;
  21. @property(cc.Node)
  22. panel_getdice: cc.Node = null;
  23. @property(cc.Node)
  24. panel_getCtrl: cc.Node = null;
  25. @property(cc.Label)
  26. txtDouble: cc.Label = null;
  27. @property(cc.Node)
  28. diceAry: cc.Node[] = [];
  29. @property(cc.Node)
  30. diceSelect: cc.Node = null;
  31. @property(cc.Node)
  32. txtNodeFreeOver: cc.Node = null;
  33. @property(cc.Node)
  34. txtNodeFree: cc.Node = null;
  35. @property(cc.Label)
  36. txtDiceAd: cc.Label = null;
  37. @property(cc.Label)
  38. txtRevertTimer: cc.Label = null;
  39. @property(cc.Label)
  40. txtRevertNum: cc.Label = null;
  41. @property(cc.Node)
  42. btnSure: cc.Node = null;
  43. revertUpdateTimer: number = 0;
  44. /**界面类型 1 使用遥控卡 2 使用双倍卡 3 获取骰子 4 获取遥控卡*/
  45. panelType: number = 1;
  46. diceNum: number = 0;
  47. OnEnter(type: number) {
  48. this.panelType = type;
  49. this.panelNode.scale = 0;
  50. this.node.active = true;
  51. cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" })
  52. .call(() => {
  53. if (type == 1) {
  54. //引导取经 大富翁
  55. GuideMng.Ins.CheckRichGuide24();
  56. } else if (type == 2) {
  57. //引导取经 大富翁
  58. GuideMng.Ins.CheckRichGuide25();
  59. }
  60. })
  61. .start();
  62. this.panel_ctrl.active = type == 1;
  63. this.panel_double.active = type == 2;
  64. this.panel_getdice.active = type == 3;
  65. this.panel_getCtrl.active = type == 4;
  66. switch (type) {
  67. case 1:
  68. this.diceNum = 0;
  69. this.diceSelect.active = false;
  70. this.btnSure.active = true;
  71. break;
  72. case 2:
  73. this.btnSure.active = true;
  74. this.txtDouble.string = RichData.Ins.richItemCardCfg.doubleTimes + "";
  75. break;
  76. case 3:
  77. let n = RichData.Ins.richItemCardCfg.diceDailyMax - RichData.Ins.adDiceDaily;
  78. this.txtNodeFreeOver.active = n == 0;
  79. this.txtNodeFree.active = n > 0;
  80. this.txtDiceAd.string = n > 0 ? n + "" : "";// "(" + RichData.Ins.adDiceDaily + "/" + RichData.Ins.richItemCardCfg.diceDailyMax + ")";
  81. this.txtRevertNum.string = RichData.Ins.richItemCardCfg.diceDailyTimes + "";
  82. this.txtRevertTimer.string = MyExtends.TimeToFormat(RichData.Ins.revertTimer, 3);
  83. this.revertUpdateTimer = 0;
  84. this.btnSure.active = false;
  85. break;
  86. case 4:
  87. this.btnSure.active = false;
  88. break;
  89. }
  90. }
  91. OnExit() {
  92. this.node.active = false;
  93. }
  94. update(dt) {
  95. this.TimerRevertDice(dt);
  96. }
  97. TimerRevertDice(dt) {
  98. if (RichData.Ins.revertTimer != 0) {
  99. this.revertUpdateTimer += dt;
  100. if (this.revertUpdateTimer > 1) {
  101. this.revertUpdateTimer = 0;
  102. this.txtRevertTimer.string = MyExtends.TimeToFormat(RichData.Ins.revertTimer, 3);
  103. }
  104. } else {
  105. this.revertUpdateTimer += dt;
  106. if (this.revertUpdateTimer > 1) {
  107. this.revertUpdateTimer = 0;
  108. this.txtRevertTimer.string = MyExtends.TimeToFormat(RichData.Ins.revertTimer, 3);
  109. }
  110. }
  111. }
  112. Click_DiceBtn(event, index) {
  113. if (!this.diceSelect.active) this.diceSelect.active = true;
  114. this.diceNum = parseInt(index) + 1;
  115. this.diceSelect.setPosition(this.diceAry[this.diceNum - 1].getPosition());
  116. GameM.audioM.playEffect(AUDIO_TYPE.button);
  117. }
  118. /**日常任务按钮*/
  119. Click_GoToTaskBtn() {
  120. console.log("go to task panel");
  121. this.OnExit();
  122. RichData.Ins.richPanel.OnExit();
  123. UiM.Instance.taskNode.active = true;
  124. GameM.audioM.playEffect(AUDIO_TYPE.button);
  125. }
  126. /**视频获取骰子按钮*/
  127. Click_DiceAdBtn() {
  128. //看广告
  129. if (RichData.Ins.adDiceDaily < RichData.Ins.richItemCardCfg.diceDailyMax) {
  130. GameM.adM.watchVideo(VIDEO_TYPE.richGetDiceAd);
  131. GameM.audioM.playEffect(AUDIO_TYPE.button);
  132. AdM.onSendEvent('video_init_18', '取经免费获得骰子拉起', 'video_init')
  133. } else {
  134. EffectNode.instance.PlayTip("观看次数已用完");
  135. }
  136. }
  137. /**视频获取骰子回调*/
  138. DiceAdEnd() {
  139. console.log("DiceAdEnd get dice");
  140. let p = new RichPropItemParam();
  141. p.diceAdvertise = 1;
  142. RichData.Ins.UpdateItemCardNew(p, () => {
  143. let n = RichData.Ins.richItemCardCfg.diceDailyMax - RichData.Ins.adDiceDaily;
  144. this.txtNodeFreeOver.active = n == 0;
  145. this.txtNodeFree.active = n > 0;
  146. this.txtDiceAd.string = n > 0 ? n + "" : "";// "(" + RichData.Ins.adDiceDaily + "/" + RichData.Ins.richItemCardCfg.diceDailyMax + ")";
  147. EffectNode.instance.PlayTip("恭喜获得" + RichData.Ins.richItemCardCfg.diceDailyTimes + "个骰子");
  148. this.OnExit();
  149. });
  150. //RichData.Ins.UpdateItemCard(this.num, 0, 0, 0, 1, 0, -1, () => {
  151. // RichData.Ins.MoveEnd();
  152. // RichData.Ins.PlayParticleEft(this.propType, 2, this.node);
  153. // this.ClearState();
  154. //},false);
  155. AdM.onSendEvent('video_end_18', '取经免费获得骰子拉起', 'video_end')
  156. }
  157. /**获取遥控卡*/
  158. Click_GetCtrlBtn() {
  159. //看广告
  160. GameM.adM.watchVideo(VIDEO_TYPE.richCtrlAd);
  161. GameM.audioM.playEffect(AUDIO_TYPE.button);
  162. AdM.onSendEvent(`video_init_17`, `取经免费获得遥控卡视频拉起`, 'video_init');
  163. }
  164. /**获取遥控卡 广告回调*/
  165. AdRichCtrlEnd() {
  166. RichData.Ins.UpdateItemCard(0, 0, 0, 1, 0, 0, 0);
  167. this.OnExit();
  168. }
  169. Click_SureBtn() {
  170. switch (this.panelType) {
  171. case 1:
  172. if (this.diceNum > 0) {
  173. RichData.Ins.UseCtrlCard(this.diceNum);
  174. this.OnExit();
  175. AdM.onSendEvent('Qujing_UseControl', '取经使用遥控卡', "qujing");
  176. } else {
  177. EffectNode.instance.PlayTip("请先选择掷骰子的点数");
  178. }
  179. break;
  180. case 2:
  181. if (RichData.Ins.doubleNum > 0) {
  182. RichData.Ins.UseDoubleCard();
  183. AdM.onSendEvent('Qujing_UseDouble', '取经使用双倍卡', "qujing");
  184. }
  185. this.OnExit();
  186. break;
  187. case 3:
  188. this.OnExit();
  189. break;
  190. }
  191. GameM.audioM.playEffect(AUDIO_TYPE.button);
  192. }
  193. Click_CloseBtn() {
  194. this.OnExit();
  195. GameM.audioM.playEffect(AUDIO_TYPE.button);
  196. }
  197. }
  198. /*
  199. IT 2.35
  200. Program Files 3.38
  201. Program Files 86 4.76
  202. ProgramData 1.42
  203. Windows 23.7
  204. Windows.old 34.7 (占用 28.9)
  205. 用户 31.5 (占用 25.9)
  206. hiberfil.sys 6.38
  207. pagefile.sys 10
  208. */