RichData.ts 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  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 EffectNode from "../ui/EffectNode";
  12. import RichPanel from "../ui/RichPanel";
  13. import Task from "../ui/Task";
  14. import UIMng, { PanelType } from "../uiFrames/UIMng";
  15. import Sciencen_M from "../utils/Sciencen_M";
  16. import { Utils } from "../utils/Utils";
  17. import { HTTP_TYPE } from "./CommonData";
  18. export class RichData {
  19. //财神降临数据管理类
  20. private static _ins: RichData = null;
  21. public static get Ins(): RichData {
  22. if (this._ins == null) {
  23. this._ins = new RichData();
  24. }
  25. return this._ins;
  26. }
  27. Destroy() {
  28. RichData._ins = null;
  29. }
  30. richItemCardCfg: any = null;
  31. richCfg: any = null;
  32. /**骰子总次数*/
  33. diceTotalNum: number = 0;
  34. /**累加骰子数量*/
  35. diceAdNum: number = 0;
  36. /**免费骰子数量*/
  37. diceDailyNum: number = 0;
  38. /**免费骰子完全恢复时间*/
  39. diceRecoverTime: number = 0;
  40. /**免费骰子恢复一个的时间*/
  41. diceSingleRecoverTime: number = 0;
  42. /**重置骰子时间段标识*/
  43. diceResetValue: number = 0;
  44. /**双倍卡当日已获取数量*/
  45. doubleDailyGetNum: number = 0;
  46. /**双倍卡数量*/
  47. doubleNum: number = 0;
  48. /**双倍效果剩余次数*/
  49. doubleRemain: number = 0;
  50. /**红包币兑换记录*/
  51. fairyJade: number[] = null;
  52. //latticeEvent:
  53. /**当前格子id 1-48*/
  54. latticeIndex: number = 0;
  55. /**是否是新用户*/
  56. newPlayer: number = 0;
  57. /**页码*/
  58. pageIndex: number = 1;
  59. /**遥控卡当日已获取数量*/
  60. remoteCtrlDailyGetNum: number = 0;
  61. /**遥控卡数量*/
  62. remoteCtrlNum: number = 0;
  63. /**奖励次数*/
  64. rewardNum: number = 0;
  65. /**经书数量*/
  66. scriptureNum: number = 0;
  67. /**下一级领取兑换的经书数量*/
  68. scriptureNextNum: number = 0;
  69. /**骰子恢复时间计时器*/
  70. revertTimer: number = 0;
  71. /**视频观看次数 看视频获取骰子*/
  72. adDiceDaily: number = 0;
  73. richPanel: RichPanel = null;
  74. bg: cc.Node = null;
  75. bgRoot: cc.Node = null;
  76. /**已加载的地图路径上下边界Y坐标 x 为下坐标 y 为上坐标*/
  77. mapPosSide: cc.Vec2 = cc.v2();
  78. /**已加载的地图背景上下边界Y坐标 x 为下坐标 y 为上坐标*/
  79. mapBgPosSide: cc.Vec2 = cc.v2();
  80. /**视角背景坐标边界 this.bg 坐标边界 x 最下 y 最上*/
  81. viewBgPosSide: cc.Vec2 = cc.v2();
  82. /**棋盘上下页码边界 x 地图下页码 y 地图上页码 id 不是索引 最低 1 开始*/
  83. latticePageSide: cc.Vec2 = cc.v2(1, 1);
  84. roadsAry: Roads[] = [];
  85. roadItems: RoadItem[] = [];
  86. roadData: any[] = [];
  87. /**0 48 96 基本就是0 不改动*/
  88. curRoadStartIndex: number = 0;
  89. /**当前角色所在位置 索引*/
  90. curPosIndex: number = 0;
  91. /**当前骰子投掷的点数*/
  92. diceNum: number = 0;
  93. /**踩到武将时 该武将的type 奖励类型 用于请求boss挑战奖励接口*/
  94. masterType = "1";
  95. isNetEnd: boolean = true;
  96. isOpenRichPanel: boolean = false;
  97. //private isMoveUp: boolean = false;
  98. //private isMveDown: boolean = false;
  99. ServerInit(data: any) {
  100. console.log("------->Data:", data);
  101. this.diceAdNum = data.diceAdNum;
  102. this.diceDailyNum = data.diceDailyNum;
  103. this.diceRecoverTime = data.diceRecoverTime;
  104. this.diceSingleRecoverTime = data.diceSingleRecoverTime;
  105. this.diceResetValue = data.diceResetValue;
  106. this.doubleDailyGetNum = data.doubleDailyGetNum;
  107. this.doubleNum = data.doubleNum;
  108. this.doubleRemain = data.doubleRemain;
  109. this.fairyJade = data.fairyJade;
  110. this.latticeIndex = data.latticeIndex;
  111. this.newPlayer = data.newPlayer;
  112. this.pageIndex = data.pageIndex;
  113. this.remoteCtrlDailyGetNum = data.remoteCtrlDailyGetNum;
  114. this.remoteCtrlNum = data.remoteCtrlNum;
  115. this.rewardNum = data.rewardNum;
  116. this.scriptureNum = data.scriptureNum;
  117. this.adDiceDaily = data.diceDaily;
  118. this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
  119. this.curPosIndex = this.latticeIndex - 1;
  120. //TEST
  121. //this.curPosIndex = 6;
  122. this.latticePageSide.x = this.latticePageSide.y = data.pageIndex;
  123. }
  124. async MapInit(richpanel: RichPanel, bgRoot: cc.Node, bg: cc.Node, roads: Roads) {
  125. this.richPanel = richpanel;
  126. this.bgRoot = bgRoot;
  127. this.bg = bg;
  128. this.roadsAry.push(roads);
  129. this.mapPosSide = cc.v2(0, 0);
  130. this.mapBgPosSide = cc.v2(0, 1334);
  131. //获取数据
  132. await Utils.loadResPromise('prefabs/TransitNode')
  133. GameController.Ins.PlayTransitAniForHttp();
  134. HttpM.Instance.SendData(HTTP_TYPE.richManChessboar, { page: this.pageIndex }, (res) => {
  135. console.log("--->chess data:", res);
  136. if (res.data != null) {
  137. GameController.Ins.PlayCloseTransitAniForHttp(() => {
  138. roads.Init(res.data.LearningChessboardInfo);
  139. this.MapPosInit();
  140. this.richPanel.CheckLoadMap();
  141. //引导取经 大富翁
  142. GuideMng.Ins.CheckRichGuide26();
  143. });
  144. }
  145. }, null, null, false, false);
  146. //console.log("Items:", this.roadItems);
  147. }
  148. /**
  149. * 加载地图
  150. * @param loadType 1 向上加载 2 向下加载 0 不加载
  151. */
  152. LoadMap(loadType: number, roads: Roads) {
  153. //获取数据
  154. if (loadType == 1) {
  155. this.latticePageSide.y++;
  156. this.mapPosSide.y += 1936;
  157. this.roadsAry.push(roads);
  158. roads.node.setPosition(0, this.mapPosSide.y);
  159. //roads.Init(null);
  160. } else {
  161. this.latticePageSide.x--;
  162. this.mapPosSide.x -= 1936;
  163. this.roadsAry.unshift(roads);
  164. roads.node.setPosition(0, this.mapPosSide.x);
  165. this.curPosIndex += 48;
  166. //roads.Init(null);
  167. }
  168. let page = loadType == 1 ? this.latticePageSide.y : this.latticePageSide.x;
  169. //获取数据
  170. HttpM.Instance.SendData(HTTP_TYPE.richManChessboar, { page: page }, (res) => {
  171. console.log("--->chess data load:", res);
  172. if (res.data != null) {
  173. roads.Init(res.data.LearningChessboardInfo, loadType);
  174. }
  175. }, null, null, false, false);
  176. }
  177. /**检测是否加载地图
  178. * 1 向上加载 2 向下加载 0 不加载
  179. */
  180. CheckLoadMapType() {
  181. // max 18 min 6
  182. let a = this.roadItems.length + this.curRoadStartIndex;
  183. console.log("Cur::::" + this.curPosIndex + " A::" + (a - 20))
  184. if (this.curPosIndex >= a - 20) {
  185. //向上加载
  186. return 1;
  187. } else if (this.curPosIndex > 47 && this.curPosIndex > this.curRoadStartIndex && this.curPosIndex < this.curRoadStartIndex + 6) {
  188. //向下加载
  189. return 2;
  190. }
  191. return 0;
  192. }
  193. MapPosInit() {
  194. let pos = MyExtends.convetOtherNodeSpaceAR(this.roadItems[this.curPosIndex - this.curRoadStartIndex].node, this.bg);
  195. this.richPanel.tangSpine.node.setPosition(pos);
  196. if (this.roadItems[this.curPosIndex - this.curRoadStartIndex].standMode == 1) {
  197. this.richPanel.tangSpine.node.scaleX = 1;
  198. //this.richPanel.tangSpine.setAnimation(0, "idle", true);
  199. } else if (this.roadItems[this.curPosIndex - this.curRoadStartIndex].standMode == 2) {
  200. this.richPanel.tangSpine.node.scaleX = 1;
  201. //this.richPanel.tangSpine.setAnimation(0, "b_idle", true);
  202. }
  203. else {
  204. this.richPanel.tangSpine.node.scaleX = -1;
  205. //this.richPanel.tangSpine.setAnimation(0, "b_idle", true);
  206. }
  207. let pos2 = MyExtends.convetOtherNodeSpaceAR(this.richPanel.tangSpine.node, this.bgRoot);
  208. if (pos2.y > 0) {
  209. this.bg.setPosition(0, -pos2.y);
  210. }
  211. this.MapBgInit();
  212. //if (this.curPosIndex > 23) {
  213. // this.bg.setPosition(0, -968);
  214. //} else {
  215. // this.bg.setPosition(0, 0);
  216. //}
  217. }
  218. MapBgInit() {
  219. if (this.bg.y < -968) {
  220. this.mapBgPosSide.y += 1334;
  221. this.richPanel.LoadMapBg(cc.v2(0, this.mapBgPosSide.y));
  222. this.viewBgPosSide = cc.v2(-968, 0);
  223. } else {
  224. this.viewBgPosSide = cc.v2(0, 0);
  225. }
  226. }
  227. /**检测加载背景*/
  228. CheckLoadMapBg(targetBgPos: cc.Vec2) {
  229. if (targetBgPos.y < this.viewBgPosSide.x) {
  230. this.viewBgPosSide.x -= 968;
  231. this.mapBgPosSide.y += 1334;
  232. this.richPanel.LoadMapBg(cc.v2(0, this.mapBgPosSide.y));
  233. } else {
  234. if (targetBgPos.y > this.viewBgPosSide.y) {
  235. this.viewBgPosSide.y += 968;
  236. this.mapBgPosSide.x -= 1334;
  237. this.richPanel.LoadMapBg(cc.v2(0, this.mapBgPosSide.x));
  238. }
  239. }
  240. }
  241. /**更新加载背景与背景移动*/
  242. UpdateLoadMapBgAndMoveBg(targetNode: cc.Node) {
  243. let pos = MyExtends.convetOtherNodeSpaceAR(targetNode, this.bgRoot);
  244. if (Math.abs(pos.y) > 0) {
  245. this.bg.runAction(cc.moveBy(0.5, 0, -pos.y));
  246. this.CheckLoadMapBg(cc.v2(0, this.bg.y - pos.y));
  247. }
  248. }
  249. /**触发传送技能
  250. * @param roaditem roaditem
  251. * @param step 步骤数
  252. */
  253. async TriggerConveySkill(roaditem: RoadItem, step: number) {
  254. let targetRoadItem = this.GetConveyTargetRoad(roaditem, step);
  255. if (targetRoadItem != null) {
  256. if (this.richPanel != null)
  257. this.richPanel.PlayCSZEft(step);
  258. await Time.WaitForSeconds(0.5);
  259. let eftNode = cc.instantiate(await Utils.loadResPromise("prefabs/item/RichCSZEft"));
  260. eftNode.parent = this.bg;
  261. eftNode.setPosition(this.richPanel.tangSpine.node.getPosition());
  262. //eftNode.parent = roaditem.node;
  263. //eftNode.setPosition(0, 0);
  264. let ani = eftNode.getComponent(sp.Skeleton);
  265. let time = ani.findAnimation("xiaoshi").duration;
  266. ani.setAnimation(0, "xiaoshi", false);
  267. await Time.WaitForSeconds(time / 2);
  268. this.richPanel.tangSpine.node.active = false;
  269. await Time.WaitForSeconds(time / 2 + 0.5);
  270. let pos = RichData.Ins.GetPosForRoadItem(targetRoadItem.node);
  271. //eftNode.parent = targetRoadItem.node;
  272. //eftNode.setPosition(0, 0);
  273. eftNode.setPosition(pos);
  274. ani.setAnimation(0, "chuxian", false);
  275. let time2 = ani.findAnimation("chuxian").duration;
  276. this.richPanel.tangSpine.node.setPosition(pos);
  277. this.richPanel.tangSpine.node.active = true;
  278. if (targetRoadItem.standMode == 1) {
  279. this.richPanel.tangSpine.node.scaleX = 1;
  280. //this.richPanel.tangSpine.setAnimation(0, "idle", true);
  281. } else if (targetRoadItem.standMode == 2) {
  282. this.richPanel.tangSpine.node.scaleX = 1;
  283. //this.richPanel.tangSpine.setAnimation(0, "b_idle", true);
  284. } else {
  285. this.richPanel.tangSpine.node.scaleX = -1;
  286. //this.richPanel.tangSpine.setAnimation(0, "b_idle", true);
  287. }
  288. this.curPosIndex += step;
  289. let bgpos = MyExtends.convetOtherNodeSpaceAR(targetRoadItem.node, this.bgRoot);
  290. //console.log("----->pos:", pos);
  291. //console.log("------->bgpos:", bgpos);
  292. if (Math.abs(bgpos.y) > 0) {
  293. this.bg.stopAllActions();
  294. //let posy = this.bg.y - pos.y;
  295. //this.bg.setPosition(0,posy);
  296. //console.log("-------1>:" + bgpos.y + " bg Y:" + this.bg.y);
  297. //this.bg.setPosition(0, this.bg.y - bgpos.y);
  298. let a1 = cc.moveBy(0.5, 0, -bgpos.y);
  299. let a2 = cc.callFunc(() => {
  300. targetRoadItem.CheckReward();
  301. });
  302. this.bg.runAction(cc.sequence(a1, a2));
  303. this.CheckLoadMapBg(cc.v2(0, this.bg.y - bgpos.y));
  304. }
  305. console.log("-------------Time2:" + time2);
  306. setTimeout(() => {
  307. eftNode.destroy();
  308. eftNode = null;
  309. }, time2 * 1000);
  310. setTimeout(() => {
  311. }, 1500);
  312. AdM.onSendEvent('Qujing_Delivery', '取经传送阵触发', "qujing");
  313. }
  314. }
  315. /**获取移动的路段数据
  316. * @param diceNum 骰子点数 -表示向下 +表示向上
  317. */
  318. GetMoveRoads(diceNum: number) {
  319. this.diceNum = diceNum;
  320. return this.GetRoadItems(diceNum);
  321. }
  322. GetRoadItems(num: number) {
  323. let roads: RoadItem[] = [];
  324. for (let i = 1; i < num + 1; i++) {
  325. this.roadItems[this.curPosIndex + i].ActiveLight(true);
  326. roads.push(this.roadItems[this.curPosIndex + i]);
  327. //console.log("Get::::",this.roadItems[this.curPosIndex + i]);
  328. }
  329. return roads;
  330. }
  331. /**获取传送目标road*/
  332. GetConveyTargetRoad(roaditem: RoadItem, step: number) {
  333. let curindex = this.roadItems.indexOf(roaditem);
  334. if (curindex != -1) {
  335. return this.roadItems[curindex + step];
  336. }
  337. return null;
  338. }
  339. /**获取roaditem的坐标
  340. * @param roaditem roadItem
  341. */
  342. GetPosForRoadItem(roaditem: cc.Node) {
  343. return MyExtends.convetOtherNodeSpaceAR(roaditem, this.bg);
  344. }
  345. UpdatePlayPos() {
  346. this.curPosIndex += this.diceNum;
  347. this.diceNum = 0;
  348. }
  349. MoveEnd() {
  350. if (this.richPanel != null)
  351. this.richPanel.MoveEnd();
  352. }
  353. /**是否可以投掷骰子*/
  354. IsCanDice() {
  355. return this.diceTotalNum > 0;// && (this.curPosIndex - this.curRoadStartIndex) < (this.roadItems.length - 6);
  356. }
  357. /**使用骰子*/
  358. UseDice() {
  359. if (this.diceAdNum > 0) {
  360. //this.diceAdNum--;
  361. this.UpdateItemCard(-1, 0, 0, 0, 0, 0, 0);
  362. } else {
  363. //this.diceDailyNum--;
  364. this.UpdateItemCard(0, -1, 0, 0, 0, 0, 0);
  365. }
  366. //this.diceTotalNum = this.diceAdNum + this.diceDailyNum;
  367. AdM.onSendEvent('Qujing_UseDice', '取经骰子消耗', "qujing");
  368. }
  369. /**使用遥控卡
  370. * @param diceNum 点数
  371. */
  372. UseCtrlCard(diceNum: number) {
  373. if (this.diceAdNum > 0) {
  374. //this.diceAdNum--;
  375. this.UpdateItemCard(-1, 0, 0, -1, 0, 0, 0);
  376. } else {
  377. //this.diceDailyNum--;
  378. this.UpdateItemCard(0, -1, 0, -1, 0, 0, 0);
  379. }
  380. //this.UpdateItemCard(0,0,0,-1,0,0,0);
  381. //this.remoteCtrlNum--;
  382. this.richPanel.UseCtrlCardEnd(diceNum);
  383. //this.richPanel.UpdateInfo();
  384. }
  385. /**使用双倍卡*/
  386. UseDoubleCard() {
  387. this.UpdateItemCard(0, 0, -1, 0, 0, 0, RichData.Ins.richItemCardCfg.doubleTimes);
  388. this.CheckDoubleEft();
  389. if (this.richPanel != null)
  390. this.richPanel.Play2RewardEft();
  391. }
  392. TESTPlayDoubleEft() {
  393. this.CheckDoubleEft();
  394. if (this.richPanel != null)
  395. this.richPanel.Play2RewardEft();
  396. }
  397. /**显示双倍奖励*/
  398. CheckDoubleEft() {
  399. let startIndex = 0;
  400. let endIndex = this.curPosIndex + 12;
  401. let num = endIndex - startIndex;
  402. if (this.curPosIndex - 12 < 0) {
  403. startIndex = 0;
  404. } else {
  405. startIndex = this.curPosIndex - 12;
  406. }
  407. for (let i = startIndex; i < num; i++) {
  408. this.roadItems[i].CheckPlayDoubleEft();
  409. }
  410. this.roadItems.forEach(item => {
  411. item.DisplayDoubleEft(true);
  412. });
  413. }
  414. /**
  415. * 获取道具奖励 (弃用)
  416. * @param propType 道具类型 0 免费骰子 1 累加骰子 2 遥控卡 3 双倍卡 4 经书 5 奖励次数
  417. * @param opType 操作类型 0 添加 1 减少
  418. * @param num 数量
  419. */
  420. GetPropReward(propType: number, opType: number, num: number) {
  421. let opSign = opType == 0 ? 1 : -1;
  422. switch (propType) {
  423. case 0:
  424. this.diceDailyNum += num * opSign;
  425. this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
  426. break;
  427. case 1:
  428. this.diceAdNum += num * opSign;
  429. this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
  430. break;
  431. case 2:
  432. this.remoteCtrlNum += num * opSign;
  433. break;
  434. case 3:
  435. this.doubleNum += num * opSign;
  436. break;
  437. case 4:
  438. this.scriptureNum += num * opSign;
  439. break;
  440. case 5:
  441. this.rewardNum += num * opSign;
  442. break;
  443. }
  444. HttpM.Instance.SendData(HTTP_TYPE.richManUpdateItemCard, { type: propType, opType: opType, num: num }, (res) => {
  445. console.log("--->update item card:", res);
  446. });
  447. /*
  448. [
  449. {type:1,opType:2,num:1},
  450. {type:1,opType:2,num:1}
  451. {type:1,opType:2,num:1}
  452. {type:1,opType:2,num:1}
  453. ]
  454. {
  455. diceDailyNum:1000,
  456. diceAdNum:100000,
  457. ...
  458. }
  459. */
  460. }
  461. /**更新道具信息
  462. * @param pdiceAdNum 累加骰子变化量 +加 -减
  463. * @param pdiceDailyNUm 免费骰子变化量
  464. * @param pdoubleNum 双倍卡变化量
  465. * @param premoteCtrlNum 遥控卡变化量
  466. * @param prewardNum 奖励次数变化量
  467. * @param pscriptureNum 经书数变化量
  468. * @param pdoubleRemain 双倍奖励效果剩余次数
  469. * @param pdiceAdvertise 看视频获取骰子
  470. */
  471. UpdateItemCard(pdiceAdNum = 0, pdiceDailyNUm = 0, pdoubleNum = 0, premoteCtrlNum = 0, prewardNum = 0, pscriptureNum = 0, pdoubleRemain = 0, callback: Function = null, isupdateinfo: boolean = true) {
  472. let param: any = {};
  473. if (pdiceAdNum != 0)
  474. param.diceAdNum = pdiceAdNum;
  475. if (pdiceDailyNUm != 0)
  476. param.diceDailyNum = pdiceDailyNUm;
  477. if (pdoubleNum != 0)
  478. param.doubleNum = pdoubleNum;
  479. if (premoteCtrlNum != 0)
  480. param.remoteCtrlNum = premoteCtrlNum;
  481. if (prewardNum != 0)
  482. param.rewardNum = prewardNum;
  483. if (pscriptureNum != 0)
  484. param.scriptureNum = pscriptureNum;
  485. if (pdoubleRemain != 0)
  486. param.doubleRemain = pdoubleRemain;
  487. console.log("---->Update Item Card:", param);
  488. HttpM.Instance.SendData(HTTP_TYPE.richManUpdateItemCard, param, (res) => {
  489. console.log("--->update item card:", res);
  490. if (res.data.userLearningInfo != null) {
  491. this.diceAdNum = res.data.userLearningInfo.diceAdNum;
  492. this.diceDailyNum = res.data.userLearningInfo.diceDailyNum;
  493. this.diceRecoverTime = res.data.userLearningInfo.diceRecoverTime;
  494. this.diceSingleRecoverTime = res.data.userLearningInfo.diceSingleRecoverTime;
  495. //this.diceResetValue = res.data.userLearningInfo.diceResetValue;
  496. //this.doubleDailyGetNum = res.data.userLearningInfo.doubleDailyGetNum;
  497. this.doubleNum = res.data.userLearningInfo.doubleNum;
  498. this.doubleRemain = res.data.userLearningInfo.doubleRemain;
  499. //this.fairyJade = res.data.userLearningInfo.fairyJade;
  500. //this.latticeIndex = res.data.userLearningInfo.latticeIndex;
  501. //this.newPlayer = res.data.userLearningInfo.newPlayer;
  502. //this.pageIndex = res.data.userLearningInfo.pageIndex;
  503. //this.remoteCtrlDailyGetNum = res.data.userLearningInfo.remoteCtrlDailyGetNum;
  504. this.remoteCtrlNum = res.data.userLearningInfo.remoteCtrlNum;
  505. this.rewardNum = res.data.userLearningInfo.rewardNum;
  506. this.scriptureNum = res.data.userLearningInfo.scriptureNum;
  507. this.adDiceDaily = res.data.userLearningInfo.diceDaily;
  508. this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
  509. if (this.richPanel != null && !this.richPanel.CheckUpdateRevering())
  510. this.richPanel.CheckUpdateRevertTime();
  511. if (isupdateinfo)
  512. this.UpdateInfo();
  513. if (pscriptureNum != 0) {
  514. if (this.richPanel != null) {
  515. this.richPanel.CheckCanCollectBook();
  516. }
  517. }
  518. if (premoteCtrlNum > 0) {
  519. if (this.richPanel != null) {
  520. this.richPanel.CheckPanelActive(1);
  521. }
  522. }
  523. if (pdoubleNum > 0) {
  524. if (this.richPanel != null) {
  525. this.richPanel.CheckPanelActive(2);
  526. }
  527. }
  528. //console.log("-----------------------P:" + JSON.stringify(param) + " Data:" + res.data.userLearningInfo.scriptureNum);
  529. //console.log("----------------------------------------1:Param: " + pdoubleRemain + " Remain: " + this.doubleRemain);
  530. //取消显示双倍效果
  531. if (pdoubleRemain < 0 && this.doubleRemain <= 0) {
  532. this.roadItems.forEach(item => {
  533. item.DisplayDoubleEft(false);
  534. });
  535. }
  536. if (callback != null) {
  537. callback();
  538. }
  539. //if (UiM.Instance.taskNode) {
  540. // UiM.Instance.taskNode.getComponent(Task).freshDice()
  541. //}
  542. }
  543. }, null, () => {
  544. console.log("----->UpdateItemCard Error");
  545. }, null, false);
  546. }
  547. /**更新道具信息
  548. * @param param 道具变化量参数
  549. * @param callback 回调
  550. * @param isupdateinfo 是否更新界面道具信息
  551. */
  552. UpdateItemCardNew(param: RichPropItemParam, callback: Function = null, isupdateinfo: boolean = true) {
  553. console.log("---->Update Item Card New:", param);
  554. HttpM.Instance.SendData(HTTP_TYPE.richManUpdateItemCard, param, (res) => {
  555. console.log("--->update item card New:", res);
  556. if (res.data.userLearningInfo != null) {
  557. this.diceAdNum = res.data.userLearningInfo.diceAdNum;
  558. this.diceDailyNum = res.data.userLearningInfo.diceDailyNum;
  559. this.diceRecoverTime = res.data.userLearningInfo.diceRecoverTime;
  560. this.diceSingleRecoverTime = res.data.userLearningInfo.diceSingleRecoverTime;
  561. this.doubleNum = res.data.userLearningInfo.doubleNum;
  562. this.doubleRemain = res.data.userLearningInfo.doubleRemain;
  563. this.remoteCtrlNum = res.data.userLearningInfo.remoteCtrlNum;
  564. this.rewardNum = res.data.userLearningInfo.rewardNum;
  565. this.scriptureNum = res.data.userLearningInfo.scriptureNum;
  566. this.adDiceDaily = res.data.userLearningInfo.diceDaily;
  567. this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
  568. if (this.richPanel != null && !this.richPanel.CheckUpdateRevering())
  569. this.richPanel.CheckUpdateRevertTime();
  570. if (isupdateinfo)
  571. this.UpdateInfo();
  572. if (param.scriptureNum != 0) {
  573. if (this.richPanel != null) {
  574. this.richPanel.CheckCanCollectBook();
  575. }
  576. }
  577. if (param.remoteCtrlNum > 0) {
  578. if (this.richPanel != null) {
  579. this.richPanel.CheckPanelActive(1);
  580. }
  581. }
  582. if (param.doubleNum > 0) {
  583. if (this.richPanel != null) {
  584. this.richPanel.CheckPanelActive(2);
  585. }
  586. }
  587. //取消显示双倍效果
  588. if (param.doubleRemain < 0 && this.doubleRemain <= 0) {
  589. this.roadItems.forEach(item => {
  590. item.DisplayDoubleEft(false);
  591. });
  592. }
  593. if (callback != null) {
  594. callback();
  595. }
  596. }
  597. }, null, () => {
  598. console.log("----->UpdateItemCard Error");
  599. }, null, false);
  600. }
  601. /**
  602. *更新道具信息
  603. @param param 参数 各道具变化量 pdiceAdNum = 0, pdiceDailyNUm = 0, pdoubleNum = 0, premoteCtrlNum = 0, prewardNum = 0, pscriptureNum = 0,pdoubleRemain = 0
  604. */
  605. UpdateItemCard2(param: any, cb: Function = null, isupdateinfo: boolean = true) {
  606. //console.log("---->Update Item Card2:", param);
  607. HttpM.Instance.SendData(HTTP_TYPE.richManUpdateItemCard, param, (res) => {
  608. //console.log("--->update item card2:", res);
  609. if (res.data.userLearningInfo != null) {
  610. this.diceAdNum = res.data.userLearningInfo.diceAdNum;
  611. this.diceDailyNum = res.data.userLearningInfo.diceDailyNum;
  612. //this.diceRecoverTime = res.data.userLearningInfo.diceRecoverTime;
  613. //this.diceResetValue = res.data.userLearningInfo.diceResetValue;
  614. //this.doubleDailyGetNum = res.data.userLearningInfo.doubleDailyGetNum;
  615. this.doubleNum = res.data.userLearningInfo.doubleNum;
  616. this.doubleRemain = res.data.userLearningInfo.doubleRemain;
  617. //this.fairyJade = res.data.userLearningInfo.fairyJade;
  618. //this.latticeIndex = res.data.userLearningInfo.latticeIndex;
  619. //this.newPlayer = res.data.userLearningInfo.newPlayer;
  620. //this.pageIndex = res.data.userLearningInfo.pageIndex;
  621. //this.remoteCtrlDailyGetNum = res.data.userLearningInfo.remoteCtrlDailyGetNum;
  622. this.remoteCtrlNum = res.data.userLearningInfo.remoteCtrlNum;
  623. this.rewardNum = res.data.userLearningInfo.rewardNum;
  624. this.scriptureNum = res.data.userLearningInfo.scriptureNum;
  625. this.adDiceDaily = res.data.userLearningInfo.diceDaily;
  626. this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
  627. //console.log("----------------------------------------2: Remain: " + this.doubleRemain);
  628. if (isupdateinfo)
  629. this.UpdateInfo();
  630. if (param.remoteCtrlNum && param.remoteCtrlNum > 0) {
  631. if (this.richPanel != null) {
  632. this.richPanel.CheckPanelActive(1);
  633. }
  634. }
  635. if (param.doubleNum && param.doubleNum > 0) {
  636. if (this.richPanel != null) {
  637. this.richPanel.CheckPanelActive(2);
  638. }
  639. }
  640. if (cb != null) {
  641. cb();
  642. }
  643. }
  644. }, null, () => {
  645. console.log("----->UpdateItemCard Error");
  646. }, null, false);
  647. }
  648. /**获取boss奖励 弃用 调试 */
  649. GetBossRewards() {
  650. HttpM.Instance.SendData(HTTP_TYPE.richManBossReward, { type: "1" }, (res) => {
  651. //console.log("--->boss rewards:", res);
  652. }, null, null, null, false);
  653. }
  654. /**更新面板信息*/
  655. UpdateInfo() {
  656. if (this.richPanel != null)
  657. this.richPanel.UpdateInfo();
  658. }
  659. /**
  660. * 显示气泡提示
  661. * @param context 提示上下文
  662. */
  663. DisplayQiPao(context: string, item: cc.Node) {
  664. if (this.richPanel != null) {
  665. let pos = MyExtends.convetOtherNodeSpaceAR(item, this.bg);
  666. this.richPanel.DisplayTipQiPao(context, cc.v2(pos.x + 50, pos.y + 150));
  667. }
  668. }
  669. /**
  670. * 播放粒子效果
  671. * @param proptype 道具类型 10001 金币 10002 红包币 10004 武将宝盒 20001 加速卡 20002 转盘卡 20003 夺宝券 20006 天赋石 30001 骰子 30002 遥控卡 30003 传送阵 30004 经书 30005 双倍卡
  672. * @param type 播放类型 1 飞头像 2 飞骰子 3 飞遥控 4 飞双倍 5 飞经书
  673. * @param startNode 开始位置节点
  674. * @param cb 回调
  675. */
  676. PlayParticleEft(proptype: number, type: number, startNode: cc.Node, cb: Function = null) {
  677. if (this.richPanel != null) {
  678. let startpos = MyExtends.convetOtherNodeSpaceAR(startNode, this.bgRoot);
  679. this.richPanel.PlayParticleEft(proptype, type, startpos, cb);
  680. }
  681. }
  682. /**
  683. * 获取一道题
  684. */
  685. GetASubject() {
  686. HttpM.Instance.SendData(HTTP_TYPE.richManGetSubject, {}, (res) => {
  687. console.log("--->get subject:", res);
  688. if (res.data != null && res.data.code == 1) {
  689. UIMng.Ins.AsyncGetPanel(PanelType.RichBookPanel, (panel) => {
  690. panel.OnEnter(res.data.question);
  691. });
  692. //UIMng.Ins.GetPanel(PanelType.RichBookPanel).OnEnter(res.data.question);
  693. } else {
  694. console.log("request fail : msg:" + res.errmsg);
  695. }
  696. }, null, () => {
  697. console.log("get subject request error");
  698. }, null, false);
  699. }
  700. BookCollectInit() {
  701. HttpM.Instance.SendData(HTTP_TYPE.richManBookList, {}, (res) => {
  702. console.log("--->book list:", res);
  703. if (res.data != null && res.data.code == 1) {
  704. UIMng.Ins.AsyncGetPanel(PanelType.RichCollectPanel, (panel) => {
  705. panel.OnEnter(res.data.fairyjadec);
  706. });
  707. //UIMng.Ins.GetPanel(PanelType.RichCollectPanel).OnEnter(res.data.fairyjadec);
  708. } else {
  709. console.log("request fail : msg:" + res.errmsg);
  710. }
  711. });
  712. }
  713. /**大富翁数据更新*/
  714. RichPanelUpdateInit() {
  715. HttpM.Instance.SendData(HTTP_TYPE.richManInitCardInfo, {}, (res) => {
  716. console.log("--->Init Info:", res);
  717. if (res.data.cardInfo != null) {
  718. this.diceAdNum = res.data.cardInfo.diceAdNum;
  719. this.diceDailyNum = res.data.cardInfo.diceDailyNum;
  720. this.diceRecoverTime = res.data.cardInfo.diceRecoverTime;
  721. this.diceSingleRecoverTime = res.data.cardInfo.diceSingleRecoverTime;
  722. //this.diceResetValue = res.data.cardInfo.diceResetValue;
  723. //this.doubleDailyGetNum = res.data.cardInfo.doubleDailyGetNum;
  724. this.doubleNum = res.data.cardInfo.doubleNum;
  725. this.doubleRemain = res.data.cardInfo.doubleRemain;
  726. //this.fairyJade = res.data.cardInfo.fairyJade;
  727. //this.latticeIndex = res.data.cardInfo.latticeIndex;
  728. //this.newPlayer = res.data.cardInfo.newPlayer;
  729. //this.pageIndex = res.data.cardInfo.pageIndex;
  730. //this.remoteCtrlDailyGetNum = res.data.cardInfo.remoteCtrlDailyGetNum;
  731. this.remoteCtrlNum = res.data.cardInfo.remoteCtrlNum;
  732. this.rewardNum = res.data.cardInfo.rewardNum;
  733. this.scriptureNum = res.data.cardInfo.scriptureNum;
  734. this.adDiceDaily = res.data.cardInfo.diceDaily;
  735. this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
  736. if (this.richPanel != null)
  737. this.richPanel.CheckUpdateRevertTime();
  738. this.UpdateInfo();
  739. }
  740. });
  741. }
  742. /**经书是否可以兑换红包币*/
  743. CheckCanCollect(callback: Function) {
  744. let isCanCollect = false;
  745. HttpM.Instance.SendData(HTTP_TYPE.richManBookList, {}, (res) => {
  746. //console.log("--->book list1:", res);
  747. if (res.data != null && res.data.code == 1) {
  748. let data = res.data.fairyjadec;
  749. for (let i = 0; i < data.length; i++) {
  750. if (i == 0)
  751. this.scriptureNextNum = data[i].scripture;
  752. if (this.scriptureNum >= data[i].scripture) {
  753. isCanCollect = true;
  754. break;
  755. }
  756. }
  757. if (this.richPanel != null)
  758. this.richPanel.txtBook.string = Sciencen_M.instance.format(this.scriptureNum.toString()) + "/" + Sciencen_M.instance.format(this.scriptureNextNum.toString());
  759. callback(isCanCollect);
  760. } else {
  761. console.log("request fail : msg:" + res.errmsg);
  762. }
  763. });
  764. }
  765. /**经书是否可以兑换红包币2*/
  766. CheckCanCollectBook() {
  767. if (this.richPanel != null) {
  768. let isCanCollect = false;
  769. HttpM.Instance.SendData(HTTP_TYPE.richManBookList, {}, (res) => {
  770. //console.log("--->book list2:", res);
  771. if (res.data != null && res.data.code == 1) {
  772. let data = res.data.fairyjadec;
  773. for (let i = 0; i < data.length; i++) {
  774. if (i == 0)
  775. this.scriptureNextNum = data[i].scripture;
  776. if (this.scriptureNum >= data[i].scripture) {
  777. isCanCollect = true;
  778. break;
  779. }
  780. }
  781. this.richPanel.pointBook.active = isCanCollect;
  782. this.richPanel.txtBook.string = Sciencen_M.instance.format(this.scriptureNum.toString()) + "/" + Sciencen_M.instance.format(this.scriptureNextNum.toString());
  783. } else {
  784. console.log("request fail : msg:" + res.errmsg);
  785. }
  786. });
  787. }
  788. }
  789. /**是否可以领取奖励*/
  790. CheckCanReward() {
  791. let result = this.rewardNum < this.richCfg.rewardnumber;
  792. if (!result)
  793. EffectNode.instance.PlayTip("今日领取奖励次数已达上限");
  794. return result;
  795. }
  796. /**是否可以领取奖励2*/
  797. CheckCanReward2() {
  798. return this.rewardNum < this.richCfg.rewardnumber;
  799. }
  800. }
  801. /**更新道具参数*/
  802. export class RichPropItemParam {
  803. /**累加骰子变化量 +加 -减*/
  804. diceAdNum: number = 0;
  805. /**免费骰子变化量*/
  806. diceDailyNum: number = 0;
  807. /**双倍卡变化量*/
  808. doubleNum: number = 0;
  809. /**遥控卡变化量*/
  810. remoteCtrlNum: number = 0;
  811. /**奖励次数变化量*/
  812. rewardNum: number = 0;
  813. /**经书数变化量*/
  814. scriptureNum: number = 0;
  815. /**双倍奖励效果剩余次数*/
  816. doubleRemain: number = 0;
  817. /**看视频获取骰子 视频观看次数变化量*/
  818. diceAdvertise: number = 0;
  819. }
  820. /*
  821. 1.RedPackageNode jinrititle mingrititle null
  822. let targetPos: cc.Vec2 = this.target.getPosition();
  823. let bulletPos: cc.Vec2 = this.node.getPosition();
  824. let normalizeVec: cc.Vec2 = targetPos.subtract(bulletPos).normalize();
  825. //角度变化以y轴正方向为起点,逆时针角度递增
  826. this.node.angle = cc.v2(0, 1).signAngle(normalizeVec) * 180 / Math.PI;
  827. */