TuCaoData.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import AdM from "../manager/AdM";
  2. import { GameController } from "../manager/GameController";
  3. import GameM from "../manager/GameM";
  4. import GuideMng from "../manager/GuideMng";
  5. import HttpM from "../manager/HttpM";
  6. import UiM from "../manager/UiM";
  7. import RoadItem from "../other/item/RoadItem";
  8. import Roads from "../other/item/Roads";
  9. import MyExtends from "../tools/MyExtends";
  10. import Time from "../tools/Time";
  11. import AdRbPanel from "../ui/AdRbPanel";
  12. import EffectNode from "../ui/EffectNode";
  13. import RichPanel from "../ui/RichPanel";
  14. import Task from "../ui/Task";
  15. import UIMng, { PanelType } from "../uiFrames/UIMng";
  16. import Sciencen_M from "../utils/Sciencen_M";
  17. import { HTTP_TYPE } from "./CommonData";
  18. export class TuCaoData {
  19. //三国战戟数据管理类
  20. private static _ins: TuCaoData = null;
  21. public static get Ins(): TuCaoData {
  22. if (this._ins == null) {
  23. this._ins = new TuCaoData();
  24. }
  25. return this._ins;
  26. }
  27. videoRbData: any = null;
  28. adRbPanel: AdRbPanel = null;
  29. bigRbNum: number = 0;
  30. taskRbId: number = 0;
  31. taskRbNum: number = 0;
  32. adsource_id_value = "";
  33. Destroy() {
  34. TuCaoData._ins = null;
  35. }
  36. ServerInit(data: any) {
  37. this.videoRbData = data;
  38. }
  39. /**
  40. * 打开任务红包页面
  41. * @param taskRbNum 红包金额
  42. * @param redMoneyId 任务红包id
  43. * @param type 打开红包类型 1 大额红包 2 任务红包
  44. * @param num 红包金额
  45. */
  46. OpenTaskRbPanel(taskRbNum: number, redMoneyId: number, type: number, num: number) {
  47. this.taskRbId = redMoneyId;
  48. this.taskRbNum = taskRbNum;
  49. if (this.adRbPanel != null) {
  50. this.adRbPanel.OpenRbPanel(type, num);
  51. }
  52. }
  53. /**更新视频进度*/
  54. async UpdateVideoProgress(data: any) {
  55. this.videoRbData = data.UserRedMoneyInfo;
  56. //console.log("UpdateVideoProgress:" + JSON.stringify(data));
  57. await Time.WaitForSeconds(0.5);
  58. if (this.adRbPanel != null) {
  59. //显示动画
  60. this.adRbPanel.UpdateInfo(true);
  61. this.adRbPanel.AdProgressEnd();
  62. }
  63. }
  64. /**更新视频进度失败*/
  65. UpdateVideoProgressFial() {
  66. }
  67. /**
  68. * 免费加进度
  69. * @param cb 提现回调
  70. */
  71. HttpNoAdProgress(cb: Function) {
  72. HttpM.Instance.SendData(HTTP_TYPE.adRbNoNeedVideo, {}, (res) => {
  73. //console.log("No Ad UpdateVideoProgress:" , JSON.stringify(res));
  74. if (res.data != null) {
  75. this.videoRbData = res.data.UserRedMoneyInfo;
  76. cb(res.data);
  77. }
  78. });
  79. }
  80. /**
  81. * 大额红包提现
  82. * @param cb 提现回调
  83. */
  84. HttpCashBig(cb: Function) {
  85. HttpM.Instance.SendData(HTTP_TYPE.adRbBigCash, {}, (res) => {
  86. if (res.data != null) {
  87. this.videoRbData = res.data.UserRedMoneyInfo;
  88. cb(res.data);
  89. }
  90. });
  91. }
  92. /**
  93. * 任务红包提现
  94. * @param cb 提现回调
  95. */
  96. HttpCashTask(cb: Function) {
  97. HttpM.Instance.SendData(HTTP_TYPE.adRbTaskCash, { redMoneyId: this.taskRbId }, (res) => {
  98. if (res.data != null) {
  99. this.videoRbData = res.data.UserRedMoneyInfo;
  100. cb(res.data);
  101. if (res.data.code == 1) {
  102. AdM.onSendEvent('VideoCash_' + this.taskRbId, '视频红包第' + this.taskRbId + '档领取成功', 'VideoCash');
  103. }
  104. }
  105. });
  106. }
  107. /**清空数据*/
  108. HttpInitAdRbData() {
  109. HttpM.Instance.SendData(HTTP_TYPE.adRbInit, {}, (res) => {
  110. console.log("--->Init", res);
  111. if (res.data != null) {
  112. this.videoRbData = res.data.UserRedMoneyInfo;
  113. if (this.adRbPanel != null) {
  114. this.adRbPanel.UpdateInfo();
  115. }
  116. if (res.data.code == 1) {
  117. AdM.onSendEvent('VideoCashBig_' + res.data.UserRedMoneyInfo.preLargeAmountCashId, ' 视频红包大额提现第' + res.data.UserRedMoneyInfo.preLargeAmountCashId + '档领取成功', 'VideoCashBig');
  118. }
  119. }
  120. });
  121. }
  122. }
  123. /*
  124. 1.RedPackageNode jinrititle mingrititle null
  125. let targetPos: cc.Vec2 = this.target.getPosition();
  126. let bulletPos: cc.Vec2 = this.node.getPosition();
  127. let normalizeVec: cc.Vec2 = targetPos.subtract(bulletPos).normalize();
  128. //角度变化以y轴正方向为起点,逆时针角度递增
  129. this.node.angle = cc.v2(0, 1).signAngle(normalizeVec) * 180 / Math.PI;
  130. */