RedPackageNode.ts 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227
  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 GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM";
  8. import { RecordTYPE, HTTP_TYPE } from "../datas/CommonData";
  9. import EffectNode from "./EffectNode";
  10. import UiM, { PANEL_NAME } from "../manager/UiM";
  11. import CarSpace from "../prefabs/CarSpace";
  12. import Main from "../Main";
  13. import AdM from "../manager/AdM";
  14. import Daily from "./Daily";
  15. import LogUtil from "../utils/LogUtil";
  16. import DailyCashData from "../datas/DailyCashData";
  17. import UsualCaidanData from "../datas/UsualCaidanData";
  18. import { GameController } from "../manager/GameController";
  19. import GuideMng from "../manager/GuideMng";
  20. const { ccclass, property } = cc._decorator;
  21. @ccclass
  22. export default class RedPackageNode extends cc.Component {
  23. @property(cc.Node)
  24. bgNode: cc.Node = null;
  25. @property(cc.Node)
  26. backNode: cc.Node = null;
  27. @property(cc.Label)
  28. labRedMoney: cc.Label = null;
  29. @property(cc.Node)
  30. moneyLy: cc.Node = null;
  31. @property(cc.Label)
  32. labRedMoneyF: cc.Label = null;
  33. @property(cc.Label)
  34. labMoney: cc.Label = null;
  35. @property(cc.Node)
  36. frontNode: cc.Node = null;
  37. @property(cc.Node)
  38. frontCashNode: cc.Node = null;
  39. @property(cc.Node)
  40. btnClose: cc.Node = null;
  41. @property(cc.Animation)
  42. openAni: cc.Animation = null;
  43. @property(cc.Node)
  44. hongbaoTop: cc.Node = null;
  45. @property(cc.Node)
  46. hongbaoDown: cc.Node = null;
  47. @property(cc.Node)
  48. videoIcon: cc.Node = null;
  49. @property(cc.Node)
  50. btnCloseFront: cc.Node = null;
  51. // @property(cc.Label)
  52. // labTitle: cc.Label = null;
  53. @property(cc.Label)
  54. labTitleO: cc.Label = null;
  55. @property(cc.Node)
  56. btnDoubleGet: cc.Node = null;
  57. @property(cc.Node)
  58. videoIconDouble: cc.Node = null;
  59. @property(cc.Label)
  60. labGet: cc.Label = null;
  61. @property(cc.Label)
  62. labDouble: cc.Label = null;
  63. @property(cc.Node)
  64. btnCloseN: cc.Node = null;
  65. @property(cc.Node)
  66. redPart: cc.Node = null;
  67. @property(cc.Node)
  68. moneyPart: cc.Node = null;
  69. @property(cc.Label)
  70. labFade: cc.Label = null;
  71. @property(cc.Node)
  72. fiveLuckNode: cc.Node = null;
  73. @property(cc.Label)
  74. labPro: cc.Label = null;
  75. @property(cc.Sprite)
  76. spPro: cc.Sprite = null;
  77. @property(cc.Animation)
  78. cashOpenAni: cc.Animation = null;
  79. @property(cc.Node)
  80. cashHongbaoTop: cc.Node = null;
  81. @property(cc.Node)
  82. cashHongbaoDown: cc.Node = null;
  83. @property(cc.Node)
  84. redRain: cc.Node = null;
  85. @property(cc.Label)
  86. labCashCon: cc.Label = null;
  87. @property(cc.Node)
  88. desNode: cc.Node = null;
  89. @property(cc.Node)
  90. loadPart: cc.Node = null;
  91. @property(cc.Animation)
  92. loadAni: cc.Animation = null;
  93. @property(cc.Node)
  94. cashPro: cc.Node = null;
  95. @property(cc.Node)
  96. finishNode: cc.Node = null;
  97. @property(cc.Label)
  98. labMoney1: cc.Label = null;
  99. @property(cc.Label)
  100. labMoney2: cc.Label = null;
  101. @property(cc.Node)
  102. par: cc.Node = null
  103. @property(cc.Node)
  104. btnPos: cc.Node = null
  105. @property(cc.Node)
  106. iconOpen: cc.Node = null;
  107. @property(cc.Node)
  108. guideNode: cc.Node = null;
  109. @property(cc.Node)
  110. btnTixian: cc.Node = null;
  111. @property(cc.Node)
  112. btnAuth: cc.Node = null;
  113. @property(cc.Node)
  114. redHand: cc.Node = null;
  115. @property(cc.Node)
  116. guideHand: cc.Node = null;
  117. @property(cc.Node)
  118. jinriTitle: cc.Node = null;
  119. @property(cc.Node)
  120. mingriTitle: cc.Node = null;
  121. /** -------红包随机动画-------- */
  122. @property(cc.Animation)
  123. hongbaoAni: cc.Animation = null;
  124. @property(cc.Node)
  125. nodeTop: cc.Node = null;
  126. @property(cc.Node)
  127. nodeCenter: cc.Node = null;
  128. @property(cc.Node)
  129. labCheck: cc.Node = null;
  130. @property(cc.RichText)
  131. proShowLabel: cc.RichText = null;
  132. @property(cc.Sprite)
  133. titleSprite: cc.Sprite = null;
  134. @property([cc.SpriteFrame])
  135. titleSf: cc.SpriteFrame[] = [];
  136. //西游
  137. @property(cc.Node)
  138. xiYou_Panel: cc.Node = null;
  139. /**西游五福转盘*/
  140. @property(cc.Node)
  141. xiYouTurntable: cc.Node = null;
  142. @property(cc.Node)
  143. xiYou_lucks: cc.Node[] = [];
  144. @property(cc.Node)
  145. xiYou_rb: cc.Node = null;
  146. @property(cc.Label)
  147. xiYou_rbTxt: cc.Label = null;
  148. @property(sp.Skeleton)
  149. xiYou_ligth: sp.Skeleton = null;
  150. @property(cc.Node)
  151. xiYou_btn_check: cc.Node = null;
  152. @property(cc.Label)
  153. redMoneyLabel: cc.Label = null;
  154. @property(cc.Label)
  155. redMoneyInfo: cc.Label = null;
  156. private xiYou_luckPosAry: cc.Vec2[] = [
  157. cc.v2(271.05111, 88.06984),
  158. cc.v2(167.5188, -230.56984),
  159. cc.v2(-167.5188, -230.56984),
  160. cc.v2(-271.05111, 88.06984),
  161. cc.v2(0, 285)
  162. ];
  163. private redmoneyNum: number = 0
  164. /** 类型 0 不看视频 1看视频 */
  165. private isVideo = 0
  166. /** 类型 3 '惊喜红包', 4 '每日提现' */
  167. public type = 0
  168. /** 车位 */
  169. private carSp = null
  170. private canCash = false
  171. private dailyCash = null
  172. private coolTime = false
  173. private labAddNum = 0
  174. onLoad() {
  175. this.node.height = cc.winSize.height
  176. this.par.height = cc.winSize.height
  177. }
  178. onEnable() {
  179. }
  180. onDisable() {
  181. if (this.type == 4) {
  182. AdM.createInter(19)
  183. //每日提现成功后关闭,显示彩蛋
  184. if (DailyCashData.Instance.needShowUsualCaidan) {
  185. DailyCashData.Instance.needShowUsualCaidan = false
  186. setTimeout(() => {
  187. if (UsualCaidanData.Instance.userUsualEggInfo && UsualCaidanData.Instance.userUsualEggInfo.isEnd == 0 && UsualCaidanData.Instance.userUsualEggInfo.isOpen == 1) {
  188. // UiM.Instance.onPanel(PANEL_NAME.UsualCaidanNode, false, () => {
  189. // UiM.Instance.usualCaidanNode.getComponent(UsualCaidanNode).init()
  190. // })
  191. EffectNode.instance.playEggIn()
  192. }
  193. }, 1000);
  194. }
  195. UiM.Instance.hallNode.getComponent(Main).freshDailyPro()
  196. }
  197. }
  198. /** 初始化
  199. * @param redmoneyNum 红包金额
  200. * @param isVideo 是否视频
  201. * @param type 类型 3 '惊喜红包' 4 '每日提现'
  202. * @param carSp 车位
  203. * @param callBack 回调函数
  204. * @param needShow 每日提现显示接受任务引导
  205. * @param delayTime 每日提现指引延迟时间
  206. */
  207. init(redmoneyNum: number, isVideo: number = 0, type: number, carSp = null, needShow = false, delayTime = 0) {
  208. LogUtil.logV("RedPackageNode init", type)
  209. this.redmoneyNum = redmoneyNum
  210. this.isVideo = isVideo
  211. this.type = type
  212. this.carSp = carSp
  213. this.bgNode.active = true
  214. this.backNode.active = false
  215. this.btnClose.active = false
  216. this.btnCloseN.opacity = 0
  217. this.loadPart.active = false
  218. this.cashPro.active = false
  219. this.finishNode.active = false
  220. this.guideNode.active = false
  221. this.redHand.active = false
  222. this.guideHand.active = false
  223. this.cashOpenAni.node.getComponent(cc.Button).transition = cc.Button.Transition.NONE
  224. if (this.type == 4) {
  225. if (GuideMng.Ins.CurGuideId == 1) {
  226. this.scheduleOnce(() => {
  227. GuideMng.Ins.ResumeGuide();
  228. }, 0.6);
  229. }
  230. // //西游
  231. // this.xiYou_Panel.active = true;
  232. this.redRain.active = true
  233. //航海
  234. this.cashHongbaoTop.setScale(0.78, 0.78)
  235. this.cashHongbaoDown.setScale(0.78, 0.78)
  236. this.cashHongbaoTop.setPosition(0, -293.5)
  237. this.cashHongbaoDown.setPosition(0, -204)
  238. this.cashOpenAni.currentClip = null
  239. this.frontCashNode.active = true
  240. this.frontCashNode.x = 0
  241. this.frontNode.active = false
  242. this.redPart.active = false
  243. this.moneyPart.active = true
  244. this.labFade.node.active = false
  245. if (GameM.commonData.roleData.canDailyCash == 0) {
  246. this.proShowLabel.string = "今日任务:购买"
  247. this.titleSprite.spriteFrame = this.titleSf[0]
  248. this.titleSprite.node.scale = 1
  249. this.jinriTitle.active = true
  250. this.mingriTitle.active = false
  251. } else {
  252. this.proShowLabel.string = "<color=#FFFF00>明日任务:</c>购买"
  253. this.titleSprite.spriteFrame = this.titleSf[1]
  254. this.titleSprite.node.scale = 1
  255. this.jinriTitle.active = false
  256. this.mingriTitle.active = true
  257. this.scheduleOnce(() => {
  258. GuideMng.Ins.CheckNextDailyCashGuide19()
  259. }, 0.6);
  260. }
  261. this.dailyCash = DailyCashData.Instance.getTodayDailyCash()
  262. // console.log("--->DailyCfg:", this.dailyCash);
  263. LogUtil.logV('init ', GameM.commonData.roleData.dailyCashAniPlayed)
  264. if (GameM.commonData.roleData.dailyCashAniPlayed == 0) {
  265. this.labAddNum = 0
  266. this.canCash = false
  267. this.nodeCenter.opacity = 0
  268. this.nodeTop.scale = 0
  269. //航海
  270. this.labCheck.active = true
  271. // //西游
  272. // this.xiYou_btn_check.active = true;
  273. this.iconOpen.active = false
  274. this.desNode.active = true
  275. this.labCashCon.node.scale = 3
  276. this.labCashCon.node.setPosition(cc.v2(0, 464))
  277. this.labCashCon.string = '???'
  278. this.labCashCon.node.color = cc.color(235, 213, 148, 255)
  279. if (this.dailyCash.index > 1) {
  280. this.redHand.active = true
  281. }
  282. this.cashOpenAni.currentClip = null
  283. cc.loader.loadRes('gift/btnBg', cc.SpriteFrame, (err, assets) => {
  284. if (err) {
  285. cc.error(err);
  286. return;
  287. }
  288. this.cashOpenAni.node.getComponent(cc.Sprite).spriteFrame = assets;
  289. this.cashOpenAni.node.active = true
  290. })
  291. this.labPro.string = `0/0`
  292. this.spPro.fillRange = 0
  293. // //西游
  294. // this.spPro.fillRange = 0
  295. // this.xiYou_lucks[4].getChildByName("max").active = false;
  296. // this.xiYou_ligth.node.active = false;
  297. // this.xiYou_rb.active = false;
  298. // for (let i = 0; i < 5; i++) {
  299. // this.xiYou_lucks[i].getChildByName("get").active = false;
  300. // this.xiYou_lucks[i].scale = 1;
  301. // this.xiYou_lucks[i].setPosition(this.xiYou_luckPosAry[i]);
  302. // }
  303. // this.xiYou_lucks[4].angle = 0;
  304. }
  305. else {
  306. // let need = Number(this.dailyCash.buyTime) - GameM.commonData.roleData.dailyPro
  307. let need = DailyCashData.Instance.userDailyCashInfo.buyTime - GameM.commonData.roleData.dailyPro
  308. this.nodeCenter.opacity = 255
  309. this.nodeTop.scale = 1
  310. //航海
  311. this.labCheck.active = false
  312. // //西游
  313. // this.xiYou_btn_check.active = false;
  314. this.labCashCon.node.scale = 1
  315. this.labCashCon.node.setPosition(cc.v2(68, 281))
  316. if (need > 0) {
  317. this.desNode.active = true
  318. this.canCash = false
  319. this.iconOpen.active = true
  320. this.labCashCon.string = DailyCashData.Instance.userDailyCashInfo.buyTime.toString()
  321. }
  322. else {
  323. this.desNode.active = false
  324. this.labCashCon.node.color = cc.color(235, 213, 148, 255)
  325. this.labCashCon.node.x = 0
  326. this.labCashCon.node.scale = 0.8
  327. if (GameM.commonData.roleData.canDailyCash == 0) {
  328. this.labCashCon.string = '条件达成,点击提现'
  329. } else {
  330. this.labCashCon.string = '条件达成,明日提现'
  331. }
  332. this.labRedMoneyF.string = `¥ ${this.dailyCash.money}`
  333. // //西游
  334. // this.xiYou_rbTxt.string = `¥ ${this.dailyCash.money}`
  335. this.canCash = true
  336. console.log("---------------2")
  337. this.iconOpen.active = true
  338. this.labRedMoneyF.string = `¥ ${this.dailyCash.money}`
  339. if (this.dailyCash.index > 1) {
  340. this.redHand.active = true
  341. }
  342. }
  343. this.cashOpenAni.currentClip = null
  344. cc.loader.loadRes('gift/tongbi', cc.SpriteFrame, (err, assets) => {
  345. if (err) {
  346. cc.error(err);
  347. return;
  348. }
  349. this.cashOpenAni.node.getComponent(cc.Sprite).spriteFrame = assets;
  350. this.cashOpenAni.node.active = true
  351. })
  352. let pro = GameM.commonData.roleData.dailyPro / DailyCashData.Instance.userDailyCashInfo.buyTime
  353. this.spPro.fillRange = pro
  354. this.labPro.string = `${GameM.commonData.roleData.dailyPro}/ ${DailyCashData.Instance.userDailyCashInfo.buyTime}`
  355. // //西游
  356. // this.xiYou_lucks[4].getChildByName("max").active = false;
  357. // this.xiYou_ligth.node.active = false;
  358. // this.xiYou_rb.active = false;
  359. // let num = Math.floor(pro / 0.2);
  360. // console.log("--->Num:" + num + " value: " + pro);
  361. // for (let i = 0; i < 5; i++) {
  362. // if (i <= num - 1) {
  363. // this.xiYou_lucks[i].getChildByName("get").active = true;
  364. // } else {
  365. // this.xiYou_lucks[i].getChildByName("get").active = false;
  366. // }
  367. // this.xiYou_lucks[i].scale = 1;
  368. // this.xiYou_lucks[i].setPosition(this.xiYou_luckPosAry[i]);
  369. // }
  370. // this.xiYou_lucks[4].angle = 0;
  371. }
  372. // this.StopOpenLuckAni();
  373. }
  374. else {
  375. this.hongbaoTop.setScale(0.78, 0.78)
  376. this.hongbaoDown.setScale(0.78, 0.78)
  377. this.hongbaoTop.setPosition(0, -293.5)
  378. this.hongbaoDown.setPosition(0, -204)
  379. this.openAni.currentClip = null
  380. cc.loader.loadRes('gift/tongbi', cc.SpriteFrame, (err, assets) => {
  381. if (err) {
  382. cc.error(err);
  383. return;
  384. }
  385. this.openAni.node.getComponent(cc.Sprite).spriteFrame = assets;
  386. })
  387. this.openAni.node.active = true
  388. this.frontCashNode.active = false
  389. this.frontNode.active = true
  390. this.redPart.active = true
  391. this.moneyPart.active = false
  392. this.redMoneyInfo.string = redmoneyNum + " ≈ " + (redmoneyNum / 10000) + "元"
  393. this.redMoneyLabel.string = redmoneyNum + ""
  394. this.labTitleO.string = GameM.commonData.typeArr[this.type]
  395. this.moneyLy.active = true
  396. this.labRedMoney.string = this.redmoneyNum.toString()
  397. if (GameM.commonData.redSwitch) {
  398. this.labMoney.string = `≈ ${(this.redmoneyNum * 0.0001).toFixed(2)}元`
  399. }
  400. else {
  401. this.labMoney.string = ''
  402. }
  403. if (this.type == 0) {
  404. this.labGet.string = '领取'
  405. this.labDouble.string = ''
  406. this.labDouble.node.active = true
  407. this.btnDoubleGet.active = true
  408. this.btnCloseN.active = false
  409. this.videoIconDouble.active = false
  410. this.guideHand.active = true
  411. this.guideHand.setPosition(cc.v2(0, -300))
  412. }
  413. else {
  414. this.labGet.string = '额外获得300'
  415. this.labDouble.string = '已存入钱包,可进行提现>'
  416. this.labDouble.node.active = false
  417. this.btnDoubleGet.active = false
  418. this.btnCloseN.active = true
  419. this.videoIconDouble.active = true
  420. }
  421. if (this.isVideo) {
  422. this.videoIcon.active = true
  423. this.btnCloseFront.active = true
  424. }
  425. else {
  426. this.videoIcon.active = false
  427. this.btnCloseFront.active = false
  428. }
  429. }
  430. }
  431. clickOpen() {
  432. GameM.audioM.playEffect(AUDIO_TYPE.button)
  433. if (this.isVideo) {
  434. if (this.type == 3) {
  435. if (GameM.commonData.isVideoTest) {
  436. this.onOpenVideoEnd()
  437. }
  438. else {
  439. GameM.adM.watchVideo(VIDEO_TYPE.freshOpenRed)
  440. }
  441. }
  442. }
  443. else {
  444. this.onOpenVideoEnd()
  445. }
  446. if (this.type == 0) {
  447. this.guideHand.active = false
  448. }
  449. }
  450. onOpenVideoEnd() {
  451. this.coolTime = true
  452. this.videoIcon.active = false
  453. this.openAni.play('openAni', 0)
  454. this.scheduleOnce(this.schedueOpen, 0.9)
  455. }
  456. clickFinishNode() {
  457. let action1 = cc.scaleTo(0.8, 0.8)
  458. let action2 = cc.scaleTo(0.8, 0.8)
  459. cc.tween(this.finishNode)
  460. .to(0.6, { position: cc.v3(-800, 0) })
  461. .call(() => {
  462. if (cc.isValid(this.node)) {
  463. this.finishNode.active = false
  464. this.finishNode.x = 0
  465. this.init(0, 0, 4, null, true, 0.6)
  466. // if (GuideMng.Ins.CurGuideId == 12) {
  467. // this.scheduleOnce(() => {
  468. // GuideMng.Ins.ResumeGuide();
  469. // }, 0.6);
  470. // }
  471. this.frontCashNode.x = 800
  472. this.coolTime = true
  473. cc.tween(this.frontCashNode)
  474. // .to(0.2, { position: cc.v3(-20,0)})
  475. // .to(0.1,{position:cc.v3(20)}, { easing: "backOut" })
  476. .to(0.6, { position: cc.v3(0) })
  477. .call(() => {
  478. this.coolTime = false
  479. })
  480. .start();
  481. }
  482. })
  483. .start();
  484. }
  485. schedueOpen() {
  486. this.openAni.stop()
  487. this.openAni.node.active = false
  488. let toy = 473 + (cc.winSize.height - 1334) * 0.5
  489. cc.tween(this.hongbaoTop).to(0.3, { scale: 1, position: cc.v2(0, toy) }).start()
  490. cc.tween(this.hongbaoDown).to(0.3, { scale: 1, position: cc.v2(0, -1000) }).start()
  491. if (this.type == 0) {
  492. GameM.commonData.updateRoleNewUser()
  493. GameM.commonData.updateRedMoney(this.redmoneyNum, RecordTYPE.newUser)
  494. // GameM.commonData.updateRoleNewUser()
  495. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  496. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  497. this.scheduleOnce(() => {
  498. this.guideHand.active = true
  499. this.guideHand.setPosition(cc.v2(100, -250))
  500. }, 1)
  501. }
  502. else if (this.type == 1) {
  503. GameM.commonData.updateRedMoney(this.redmoneyNum, RecordTYPE.signIn)
  504. GameM.commonData.updateChatRed(this.redmoneyNum)
  505. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  506. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  507. }
  508. else if (this.type == 2) {
  509. GameM.commonData.updateRedMoney(this.redmoneyNum, RecordTYPE.online)
  510. GameM.commonData.updateChatRed(this.redmoneyNum)
  511. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  512. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  513. }
  514. else if (this.type == 3) {
  515. GameM.commonData.updateRedMoney(this.redmoneyNum, RecordTYPE.onlineGiftRed)
  516. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  517. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  518. if (this.carSp != null) {
  519. let s = this.carSp.getComponent(CarSpace)
  520. s.changeType(0)
  521. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  522. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  523. }
  524. GameM.commonData.hasRedMoney--
  525. if (GameM.commonData.hasRedMoney < 0) {
  526. GameM.commonData.hasRedMoney = 0
  527. }
  528. }
  529. this.scheduleOnce(() => {
  530. this.backNode.active = true
  531. }, 0.1)
  532. this.coolTime = false
  533. this.btnClose.active = true
  534. this.btnCloseN.opacity = 0
  535. cc.tween(this.btnCloseN).delay(0).to(0.7, { opacity: 255 }).start()
  536. }
  537. clickCashOpen() {
  538. GameM.audioM.playEffect(AUDIO_TYPE.button)
  539. if (this.coolTime) {
  540. return
  541. }
  542. this.coolTime = true
  543. if (GameM.commonData.roleData.dailyCashAniPlayed == 0) {
  544. this.redHand.active = false;
  545. DailyCashData.Instance.getDailyCashBuyTime()
  546. }
  547. else {
  548. if (this.canCash) {
  549. this.redHand.active = false;
  550. if (GameM.commonData.loginDays < this.dailyCash.time) {
  551. EffectNode.instance.PlayTip('每日提现次数已达上限,请明天再来!')
  552. this.coolTime = false
  553. return
  554. }
  555. // GameM.adM.watchVideo(VIDEO_TYPE.dailyCash)
  556. if (GameM.commonData.roleData.canDailyCash == 0) {
  557. console.log("---> canDailyCash = 0")
  558. DailyCashData.Instance.getDailyCashMoney()
  559. } else {
  560. console.log("---> canDailyCash = 1")
  561. let btnNode = this.cashOpenAni.node
  562. btnNode.stopAllActions()
  563. this.labCashCon.node.stopAllActions()
  564. cc.tween(btnNode).to(0.1, { scale: 1.2 })
  565. .to(0.1, { scale: 1 })
  566. .start()
  567. cc.tween(this.labCashCon.node).to(0.1, { scale: 1 })
  568. .to(0.1, { scale: 0.8 })
  569. .start()
  570. EffectNode.instance.PlayTip('今日已提现,请明天再来!')
  571. }
  572. }
  573. else {
  574. //航海
  575. //EffectNode.instance.PlayTip('购买武将次数不足')
  576. //西游
  577. EffectNode.instance.PlayTip('购买武将增加任务进度')
  578. cc.tween(this.labCashCon.node).to(0.15, { scale: 1.3 }).to(0.15, { scale: 1 }).start()
  579. cc.tween(this.desNode).to(0.15, { scale: 1.3 }).to(0.15, { scale: 1 }).start()
  580. }
  581. this.coolTime = false
  582. }
  583. }
  584. clickCashHelp() {
  585. GameM.audioM.playEffect(AUDIO_TYPE.button)
  586. this.frontCashNode.active = false
  587. this.guideNode.active = true
  588. }
  589. checkOpen() {
  590. this.cashOpenAni.stop()
  591. this.cashOpenAni.currentClip = null
  592. cc.loader.loadRes('gift/tongbi', cc.SpriteFrame, (err, assets) => {
  593. if (err) {
  594. cc.error(err);
  595. return;
  596. }
  597. this.cashOpenAni.node.getComponent(cc.Sprite).spriteFrame = assets;
  598. })
  599. this.cashOpenAni.node.active = true
  600. console.log("---------------3")
  601. this.iconOpen.active = true
  602. }
  603. onLabAdd() {
  604. if (this.labAddNum < DailyCashData.Instance.userDailyCashInfo.buyTime) {
  605. this.labAddNum++
  606. }
  607. else {
  608. this.labAddNum = DailyCashData.Instance.userDailyCashInfo.buyTime
  609. this.unschedule(this.onLabAdd)
  610. this.labCashCon.node.color = cc.color(255, 255, 0, 255)
  611. this.labFade.string = DailyCashData.Instance.userDailyCashInfo.buyTime.toString()
  612. this.labFade.node.opacity = 255
  613. this.labFade.node.scale = 3
  614. this.labFade.node.active = true
  615. this.checkOpen()
  616. cc.tween(this.labFade.node)
  617. .to(0.6, { scale: 8, opacity: 0 })
  618. .call(() => {
  619. this.labFade.node.active = false
  620. this.hongbaoAni.play('randomRed', 0)
  621. this.coolTime = true
  622. this.scheduleOnce(() => {
  623. this.scheduleOnce(() => {
  624. this.coolTime = false
  625. }, 1)
  626. this.spPro.fillRange = 0
  627. this.labPro.string = `${GameM.commonData.roleData.dailyPro}/ ${DailyCashData.Instance.userDailyCashInfo.buyTime}`
  628. if (GuideMng.Ins.CurGuideId == 1) {
  629. GuideMng.Ins.ResumeGuide();
  630. }
  631. if (GuideMng.Ins.CurGuideId == 13) {
  632. GuideMng.Ins.ResumeGuide();
  633. }
  634. // UiM.Instance.guideNode.getComponent(Guide).hideMask11()
  635. }, 1)
  636. })
  637. .start()
  638. }
  639. this.labCashCon.string = this.labAddNum.toString()
  640. }
  641. //xiyou
  642. xiyouOnLabAdd() {
  643. if (this.labAddNum < DailyCashData.Instance.userDailyCashInfo.buyTime) {
  644. this.labAddNum++
  645. this.labPro.string = `${this.labAddNum}`;
  646. }
  647. else {
  648. this.labAddNum = DailyCashData.Instance.userDailyCashInfo.buyTime
  649. this.unschedule(this.xiyouOnLabAdd)
  650. this.labPro.string = `${this.labAddNum}`;
  651. cc.tween(this.labPro.node)
  652. .delay(0.5)
  653. .to(0.6, { x: 25, y: -35, scale: 1 })
  654. .call(() => {
  655. this.fiveLuckNode.active = true
  656. this.labPro.node.x = 0
  657. this.labPro.string = `${GameM.commonData.roleData.dailyPro}/ ${this.labAddNum}`;
  658. })
  659. .start()
  660. }
  661. }
  662. onDailyCashVideoEnd() {
  663. this.iconOpen.active = false
  664. this.cashOpenAni.play('openAni', 0)
  665. this.scheduleOnce(this.schedueCashOpen, 0.9)
  666. }
  667. //每日提现红包打开动画
  668. schedueCashOpen() {
  669. this.cashOpenAni.stop()
  670. this.cashOpenAni.node.active = false
  671. //航海
  672. let toy = 473 + (cc.winSize.height - 1334) * 0.5
  673. this.redRain.active = false
  674. cc.tween(this.cashHongbaoTop).to(0.3, { scale: 1, position: cc.v2(0, toy) }).start()
  675. cc.tween(this.cashHongbaoDown).to(0.3, { scale: 1, position: cc.v2(0, -1000) }).start()
  676. // //西游
  677. // this.xiYou_Panel.active = false;
  678. this.scheduleOnce(() => {
  679. this.backNode.active = true
  680. }, 0.1)
  681. if (GameM.commonData.isAuth) {
  682. this.btnAuth.active = false
  683. this.btnTixian.active = true
  684. if (GuideMng.Ins.CurGuideId == 12) {
  685. GuideMng.Ins.FinishGuide()
  686. }
  687. }
  688. else {
  689. this.btnAuth.active = true
  690. this.btnTixian.active = false
  691. if (GuideMng.Ins.CurGuideId == 12) {
  692. this.scheduleOnce(() => {
  693. GuideMng.Ins.ResumeGuide();
  694. }, 0.6);
  695. }
  696. }
  697. this.btnClose.active = true
  698. }
  699. private hasTap = false
  700. clickAuth() {
  701. GameM.audioM.playEffect(AUDIO_TYPE.button)
  702. if (!this.hasTap) {
  703. console.log('clickGoAuth')
  704. this.hasTap = true
  705. AdM.WxLogin()
  706. this.scheduleOnce(() => {
  707. this.hasTap = false
  708. }, 1)
  709. }
  710. }
  711. /** 授权返回刷新 */
  712. authBack() {
  713. this.btnAuth.active = false
  714. this.btnTixian.active = true
  715. EffectNode.instance.PlayTip('授权成功,点击提现')
  716. }
  717. /** 点击提现 */
  718. clickCash() {
  719. GameM.audioM.playEffect(AUDIO_TYPE.button)
  720. if (!DailyCashData.Instance.dailyCashApplyCfg) {
  721. return
  722. }
  723. LogUtil.logV('dailyCash ', { 'index': this.dailyCash.index })
  724. GameM.httpM.sendDatas(HTTP_TYPE.dailyCash, { 'index': this.dailyCash.index }, DailyCashData.Instance.resultDailyCash.bind(DailyCashData.Instance),
  725. DailyCashData.Instance.resultDailyCashFail.bind(DailyCashData.Instance))
  726. this.loadPart.active = true
  727. this.loadAni.play('load', 0)
  728. }
  729. tiXianSuccess(showPro) {
  730. GameM.commonData.roleData.dailyCashAniPlayed = 0
  731. LogUtil.logV('tiXianSuccess ', GameM.commonData.roleData.dailyCashAniPlayed)
  732. GameM.commonData.updateDailyCash(1, 1, true)
  733. this.scheduleOnce(() => {
  734. this.loadPart.active = false
  735. this.showCashPro(showPro)
  736. }, 1.5)
  737. }
  738. tixianFail() {
  739. this.scheduleOnce(() => {
  740. this.loadPart.active = false
  741. this.btnClose.active = true
  742. }, 1.5)
  743. }
  744. showCashPro(showPro) {
  745. if (!DailyCashData.Instance.dailyCashApplyCfg) {
  746. return
  747. }
  748. // this.labMoney1.string = `¥${this.dailyCash.money}`
  749. if (showPro) {
  750. UiM.Instance.openPanel(this.cashPro)
  751. }
  752. }
  753. clickCloseCashPro() {
  754. GameM.audioM.playEffect(AUDIO_TYPE.button)
  755. UiM.Instance.closePanelM()
  756. this.backNode.active = false
  757. this.frontCashNode.active = false
  758. this.btnClose.active = false
  759. this.finishNode.active = true
  760. this.finishNode.x = 0
  761. this.guideHand.active = true
  762. this.guideHand.setPosition(cc.v2(73, -287))
  763. }
  764. clickClose() {
  765. GameM.audioM.playEffect(AUDIO_TYPE.button)
  766. if (this.coolTime) {
  767. return
  768. }
  769. if (this.type == 0 && !this.backNode.active) {
  770. return
  771. }
  772. if (this.type == 0) {
  773. UiM.Instance.hallNode.getComponent(Main).checkNewUser()
  774. }
  775. else if (this.type == 1) {
  776. if (UiM.Instance.dailyNode) {
  777. UiM.Instance.dailyNode.getComponent(Daily).hasOpen()
  778. }
  779. }
  780. if (this.type == 4) {
  781. this.hideEff()
  782. //西游
  783. GameController.Ins.SwitchAudio(1);
  784. this.xiYou_rb.active = false;
  785. }
  786. else {
  787. this.bgNode.active = false
  788. UiM.Instance.closePanelM()
  789. }
  790. if (GuideMng.Ins.CurGuideId == 12) {
  791. GuideMng.Ins.FinishGuide();
  792. }
  793. }
  794. clickDoubleGet() {
  795. GameM.audioM.playEffect(AUDIO_TYPE.button)
  796. if (this.type == 0) {
  797. UiM.Instance.hallNode.getComponent(Main).checkNewUser()
  798. this.bgNode.active = false
  799. UiM.Instance.closePanelM()
  800. return
  801. }
  802. GameM.adM.watchVideo(VIDEO_TYPE.freshGet)
  803. }
  804. onDoubleGetVideoFail() {
  805. if (this.type == 0) {
  806. }
  807. }
  808. onDoubleGetVideoEnd() {
  809. // this.node.active = false
  810. this.bgNode.active = false
  811. UiM.Instance.closePanelM()
  812. if (this.type == 0) {
  813. UiM.Instance.hallNode.getComponent(Main).checkNewUser()
  814. EffectNode.instance.PlayTip("双倍领取成功");
  815. GameM.commonData.updateRedMoney(this.redmoneyNum, RecordTYPE.newUser)
  816. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  817. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  818. }
  819. else if (this.type == 1) {
  820. GameM.commonData.updateRedMoney(300, RecordTYPE.signIn)
  821. GameM.commonData.updateChatRed(300)
  822. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  823. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  824. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  825. if (UiM.Instance.dailyNode) {
  826. UiM.Instance.dailyNode.getComponent(Daily).hasOpen()
  827. }
  828. }
  829. else if (this.type == 2) {
  830. GameM.commonData.updateRedMoney(300, RecordTYPE.online)
  831. GameM.commonData.updateChatRed(300)
  832. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  833. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  834. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  835. }
  836. else if (this.type == 3) {
  837. GameM.commonData.updateRedMoney(300, RecordTYPE.onlineGiftRed)
  838. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  839. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  840. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  841. if (this.carSp != null) {
  842. let s = this.carSp.getComponent(CarSpace)
  843. s.changeType(0)
  844. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  845. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  846. }
  847. GameM.commonData.hasRedMoney--
  848. if (GameM.commonData.hasRedMoney < 0) {
  849. GameM.commonData.hasRedMoney = 0
  850. }
  851. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  852. }
  853. }
  854. clickLabDouble() {
  855. if (this.type == 0) {
  856. this.clickDoubleGet()
  857. }
  858. else {
  859. GameM.audioM.playEffect(AUDIO_TYPE.button)
  860. // this.node.active = false
  861. this.bgNode.active = false
  862. UiM.Instance.closePanelM()
  863. // UiM.Instance.openPanel(UiM.Instance.cashNode)
  864. UiM.Instance.onPanel(PANEL_NAME.CashNode, true)
  865. }
  866. }
  867. clickGuideBtn() {
  868. GameM.audioM.playEffect(AUDIO_TYPE.button)
  869. this.hideEff()
  870. UiM.Instance.hallNode.getComponent(Main).showBuyCarHand()
  871. //西游
  872. GameController.Ins.SwitchAudio(1);
  873. }
  874. clickGuideBack() {
  875. console.log("RedPackageNode clickGuideBack")
  876. GameM.audioM.playEffect(AUDIO_TYPE.button)
  877. this.frontCashNode.active = true
  878. this.guideNode.active = false
  879. }
  880. clickBg() {
  881. if (this.coolTime) {
  882. return
  883. }
  884. if (this.guideNode.active) {
  885. this.clickGuideBack()
  886. }
  887. else {
  888. this.clickClose()
  889. }
  890. console.log("RedPackageNode clickBg")
  891. }
  892. hideEff() {
  893. let pos = this.btnPos.position
  894. if (cc.winSize.height > 1500) {
  895. pos.y = pos.y + 45
  896. }
  897. cc.tween(this.par).to(0.2, { scale: 0, position: pos }).call(() => {
  898. this.node.active = false
  899. this.par.scale = 1
  900. this.par.setPosition(cc.v2(0, 0))
  901. // this.node.hide = false
  902. if (GameM.commonData.richbank_noSave > 0) {
  903. UiM.Instance.hallNode.getComponent(Main).BankQipaoTip.creatPacketAnim(2)
  904. GameM.commonData.richbank_noSave = 0
  905. }
  906. if (GuideMng.Ins.CurGuideId == 1) {
  907. GuideMng.Ins.ResumeGuide();
  908. }
  909. }).start();
  910. }
  911. //西游
  912. Click_XiYouLuckBtn() {
  913. if (this.iconOpen.active) {
  914. if (GameM.commonData.roleData.canDailyCash == 0) {
  915. DailyCashData.Instance.getDailyCashMoney()
  916. } else {
  917. EffectNode.instance.PlayTip('明日五福第二天才能合成!')
  918. cc.tween(this.titleSprite.node)
  919. .to(0.25, { scale: 1.2 })
  920. .to(0.25, { scale: 1 })
  921. .start()
  922. }
  923. if (this.redHand.active) {
  924. this.redHand.active = false;
  925. }
  926. } else {
  927. this.clickCashOpen();
  928. }
  929. }
  930. Click_XiYouLuckRbOpenBtn() {
  931. this.clickCashOpen();
  932. }
  933. private deltadis = 240;
  934. /**停止播放开福动画*/
  935. StopOpenLuckAni() {
  936. cc.Tween.stopAllByTarget(this.xiYou_lucks[0]);
  937. cc.Tween.stopAllByTarget(this.xiYou_lucks[1]);
  938. cc.Tween.stopAllByTarget(this.xiYou_lucks[2]);
  939. cc.Tween.stopAllByTarget(this.xiYou_lucks[3]);
  940. cc.Tween.stopAllByTarget(this.xiYou_lucks[4]);
  941. cc.Tween.stopAllByTarget(this.xiYou_rb);
  942. }
  943. /**播放开福动画*/
  944. PlayOpenLuckAni() {
  945. this.StopOpenLuckAni();
  946. cc.tween(this.xiYou_lucks[0])
  947. .to(0.3, { scale: 1.1, position: cc.v2(this.deltadis, 0) })
  948. .delay(0.15)
  949. .to(0.1, { position: cc.v2(this.deltadis - 50, 0) })
  950. .to(0.15, { position: cc.v2(this.deltadis + 210, 0) })
  951. .to(0.2, { position: cc.v2(0, 0) })
  952. .start();
  953. cc.tween(this.xiYou_lucks[1])
  954. .to(0.3, { scale: 1.3, position: cc.v2(this.deltadis * 0.5, 0) })
  955. .delay(0.15)
  956. .to(0.1, { position: cc.v2(this.deltadis * 0.5 - 40, 0) })
  957. .to(0.15, { position: cc.v2(this.deltadis * 0.5 + 150, 0) })
  958. .to(0.15, { position: cc.v2(0, 0) })
  959. .start();
  960. cc.tween(this.xiYou_lucks[2])
  961. .to(0.3, { scale: 1.1, position: cc.v2(-this.deltadis, 0) })
  962. .delay(0.15)
  963. .to(0.1, { position: cc.v2(-this.deltadis + 50, 0) })
  964. .to(0.15, { position: cc.v2(-this.deltadis - 210, 0) })
  965. .to(0.2, { position: cc.v2(0, 0) })
  966. .start();
  967. cc.tween(this.xiYou_lucks[3])
  968. .to(0.3, { scale: 1.3, position: cc.v2(-110, 0) })
  969. .delay(0.15)
  970. .to(0.1, { position: cc.v2(-this.deltadis * 0.5 + 40, 0) })
  971. .to(0.15, { position: cc.v2(-this.deltadis * 0.5 - 150, 0) })
  972. .to(0.15, { position: cc.v2(0, 0) })
  973. .start();
  974. cc.tween(this.xiYou_lucks[4])
  975. .to(0.3, { scale: 1.7, position: cc.v2(0, 0) })
  976. .to(0.15, { scale: 2.2 })
  977. .to(0.15, { scale: 1.7 })
  978. .to(0.15, { scale: 2.2 })
  979. .to(0.15, { scale: 1.7 })
  980. .call(() => {
  981. this.xiYou_ligth.node.active = true;
  982. this.xiYou_ligth.clearTrack(0);
  983. this.xiYou_ligth.setAnimation(0, "animation", false);
  984. this.xiYou_lucks[4].getChildByName("max").active = true;
  985. GameM.audioM.playEffect(AUDIO_TYPE.fiveluck);
  986. })
  987. .delay(0.3)
  988. .to(0.15, { scale: 2 })
  989. .to(0.4, { scale: 0, angle: 400 })
  990. .call(() => {
  991. this.xiYou_rb.getChildByName("bg").active = false;
  992. this.xiYou_rb.scale = 0;
  993. this.xiYou_rb.angle = 0;
  994. this.xiYou_rb.active = true;
  995. //this.xiYou_rb.scaleX
  996. cc.tween(this.xiYou_rb)
  997. .to(0.15, { scaleX: -0.25, scaleY: 0.25 })
  998. .to(0.15, { scaleX: 0.5, scaleY: 0.5 })
  999. .to(0.15, { scaleX: -0.75, scaleY: 0.75 })
  1000. .to(0.15, { scaleX: 1, scaleY: 1 })
  1001. .call(() => { this.xiYou_rb.getChildByName("bg").active = true; })
  1002. .start();
  1003. })
  1004. .start();
  1005. //.to(0.2,{position:cc.v2(-110+30,0)})
  1006. //.to(0.4,{position:cc.v2(-110-50,0)})
  1007. //.to(0.5,{position:cc.v2(0,0)});
  1008. }
  1009. freshDailyCashMoney(cashMoney) {
  1010. let money = (cashMoney * 0.01).toFixed(2)
  1011. this.labRedMoneyF.string = `¥ ${money}`
  1012. this.xiYou_rbTxt.string = `¥ ${money}`
  1013. this.labMoney2.string = `¥ ${money}`
  1014. this.labMoney1.string = `¥ ${money}`
  1015. // this.PlayOpenLuckAni();
  1016. this.onDailyCashVideoEnd()
  1017. }
  1018. /** 刷新需要购买次数 */
  1019. freshNeedBuyTimes() {
  1020. //查看动画
  1021. this.redHand.active = false
  1022. this.labCheck.active = false
  1023. this.cashOpenAni.play('openAni', 0)
  1024. // this.scheduleOnce(this.checkOpen, 0.9)
  1025. this.schedule(this.onLabAdd, 0.03)
  1026. if (GameM.commonData.roleData.canDailyCash != 0) {
  1027. AdM.onSendEvent('nextcash_start', '开启明日提现', 'nextcash')
  1028. }
  1029. GameM.commonData.roleData.dailyCashAniPlayed = 1
  1030. GameM.commonData.updateRoleData()
  1031. }
  1032. }