Gift.ts 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501
  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, { VIDEO_TYPE, AUDIO_TYPE } from "../manager/GameM";
  8. import CarSpace from "../prefabs/CarSpace";
  9. import { HTTP_TYPE, MONEY_TYPE, RecordTYPE } from "../datas/CommonData";
  10. import EffectNode from "./EffectNode";
  11. import UiM, { PANEL_NAME } from "../manager/UiM";
  12. import Main from "../Main";
  13. import AdM from "../manager/AdM";
  14. import Sciencen_M from "../utils/Sciencen_M";
  15. import GlobalStorage, { STORAGE_KEY } from "../datas/GlobalStorage";
  16. import GuideManager from "../manager/GuideManager";
  17. import LogUtil from "../utils/LogUtil";
  18. import Treasure from "./Treasure";
  19. import RoleManageData from "../datas/RoleManageData";
  20. import Turntable from "./Turntable";
  21. import SwitchM from "../manager/SwitchM";
  22. import GuideMng from "../manager/GuideMng";
  23. import { FightData } from "../datas/FightData";
  24. import { MateData } from "../datas/MateData";
  25. import { Utils } from "../utils/Utils";
  26. import NativeAdAwardData from "../manager/NativeAdAwardData";
  27. import NativeADAwardNode from "./NativeAdAwardNode";
  28. import DailyData from "../datas/DailyData";
  29. import { RichData } from "../datas/RichData";
  30. import { PlayerPrefs } from "../tools/MyExtends";
  31. import MoreGameData from "../datas/MoreGameData";
  32. const { ccclass, property } = cc._decorator;
  33. @ccclass
  34. export default class Gift extends cc.Component {
  35. @property(cc.Node)
  36. light: cc.Node = null;
  37. @property(cc.Node)
  38. xing: cc.Node = null;
  39. @property(cc.Node)
  40. goldIcons: cc.Node = null;
  41. @property(cc.Node)
  42. redMoneyIcons: cc.Node = null;
  43. @property(cc.Node)
  44. offlineIcons: cc.Node = null;
  45. @property(cc.Node)
  46. boxIcons: cc.Node = null;
  47. @property(cc.Node)
  48. lvupcarIcons: cc.Node = null;
  49. @property(cc.Node)
  50. popVideoIcons: cc.Node = null;
  51. @property(cc.Node)
  52. icon: cc.Node = null;
  53. @property(cc.Label)
  54. labNum: cc.Label = null;
  55. @property(cc.Node)
  56. btnGetGold: cc.Node = null;
  57. @property(cc.RichText)
  58. labDayLeft: cc.RichText = null;
  59. @property(cc.Node)
  60. btnGetOffline: cc.Node = null;
  61. @property(cc.Node)
  62. lyGold: cc.Node = null;
  63. @property(cc.Node)
  64. newcarIcons: cc.Node = null;
  65. @property(cc.Sprite)
  66. car: cc.Sprite = null;
  67. //被动视频
  68. @property(cc.Node)
  69. popVideoIcon: cc.Node = null;
  70. //znh
  71. @property(cc.Label)
  72. maxCarLvTxt: cc.Label = null;
  73. @property(cc.Node)
  74. btn_close: cc.Node = null;
  75. @property(cc.Node)
  76. btn_offlineSingle: cc.Node = null;
  77. //new car
  78. @property(cc.Label)
  79. labCarNum: cc.Label = null;
  80. @property(cc.Label)
  81. labCarMoney: cc.Label = null;
  82. @property(cc.Node)
  83. newCarBg: cc.Node = null;
  84. @property(cc.Node)
  85. btnCarGet: cc.Node = null;
  86. @property(cc.Node)
  87. btnCarDouble: cc.Node = null;
  88. @property(cc.Node)
  89. btnCarSingle: cc.Node = null;
  90. @property(cc.Node)
  91. videoIcon: cc.Node = null;
  92. @property(cc.Label)
  93. labGoldBtnDes: cc.Label = null;
  94. @property(cc.Node)
  95. btnGet: cc.Node = null;
  96. @property(cc.Sprite)
  97. btnBanner: cc.Sprite = null;
  98. @property(cc.Node)
  99. newCarVideoIcon: cc.Node = null;
  100. //lvup
  101. @property(cc.Sprite)
  102. carTo: cc.Sprite = null;
  103. @property(cc.Sprite)
  104. carN: cc.Sprite = null;
  105. @property(cc.Label)
  106. labCarTo: cc.Label = null;
  107. @property(cc.Label)
  108. labCarN: cc.Label = null;
  109. @property(cc.RichText)
  110. labPercent: cc.RichText = null;
  111. @property(cc.Node)
  112. videoGetGold: cc.Node = null;
  113. @property(cc.RichText)
  114. videoLabPercent: cc.RichText = null;
  115. @property(cc.Label)
  116. labVideoGold: cc.Label = null;
  117. @property(cc.Label)
  118. labCurGold: cc.Label = null;
  119. //新增加底
  120. @property(cc.Node)
  121. giftBg: cc.Node = null;
  122. @property(cc.Node)
  123. titleBg: cc.Node = null;
  124. @property(cc.Node)
  125. treasureTicket: cc.Node = null;
  126. @property(cc.Node)
  127. propNode: cc.Node = null;
  128. @property(cc.Sprite)
  129. spriteProp: cc.Sprite = null;
  130. @property(cc.Label)
  131. treasureGold: cc.Label = null;
  132. @property(cc.Label)
  133. propNum: cc.Label = null;
  134. @property(cc.Node)
  135. labDrop: cc.Node = null;
  136. @property(cc.Node)
  137. clearCoolNode: cc.Node = null;
  138. @property(cc.Node)
  139. clearBtnNode: cc.Node = null;
  140. @property(cc.Node)
  141. clearCloseNode: cc.Node = null;
  142. /** 类型 10001:金币
  143. 10002:红包币
  144. 10003:时间段收益(当前的每秒收益*时间段)
  145. 10004:惊喜礼包(打开后获得对应等级的汽车)
  146. 10005:离线收益*/
  147. type = 0
  148. /** 数量 */
  149. num = '0'
  150. /** 车位 */
  151. carSp = null
  152. /** 是飞船 */
  153. isAirship = false
  154. isVideo = false //是否观看视频
  155. adType: VIDEO_TYPE = null; //视频类型
  156. countDown = 0
  157. turntable = false
  158. streamData = null
  159. onEnable() {
  160. }
  161. onDisable() {
  162. if (this.type == MONEY_TYPE.box) {
  163. AdM.createInter(2);
  164. }
  165. else if (this.type == MONEY_TYPE.offlineGold) {
  166. AdM.createInter(4);
  167. UiM.Instance.hallNode.getComponent(Main).checkPopSecretary()
  168. }
  169. else if (this.type == MONEY_TYPE.getNewCar) {
  170. AdM.createInter(9);
  171. }
  172. else if (this.type == MONEY_TYPE.gold) {
  173. AdM.createInter(11);
  174. }
  175. else if (this.type == MONEY_TYPE.carLvUp) {
  176. AdM.createInter(12);
  177. }
  178. AdM.destroyNative()
  179. AdM.destroyBanner()
  180. if (this.isAirship) {
  181. UiM.Instance.hallNode.getComponent(Main).resumeAirShip()
  182. }
  183. UiM.Instance.hallNode.getComponent(Main).CheckNormalGuide();
  184. }
  185. init(type, num, carSp = null, isAirship = false, isvideo = 0, adType: VIDEO_TYPE = null, percent = -1, turntable = false) {
  186. this.type = type
  187. this.num = num
  188. this.carSp = carSp
  189. this.isAirship = isAirship
  190. this.isVideo = (isvideo == 1)
  191. this.adType = adType
  192. this.turntable = turntable
  193. this.labNum.node.parent.scale = 1
  194. if (this.isAirship) {
  195. this.changeAir = false
  196. if (NativeAdAwardData.Instance.canGetAward(2)) {
  197. this.labDrop.active = true
  198. }
  199. else {
  200. this.labDrop.active = false
  201. this.labNum.node.parent.scale = 0
  202. cc.tween(this.labNum.node.parent)
  203. .to(0.6, { scale: 1 })
  204. .start()
  205. }
  206. }
  207. else {
  208. this.labDrop.active = false
  209. }
  210. this.labNum.string = Sciencen_M.instance.format(this.num)
  211. if (percent == -1) {
  212. this.labPercent.string = ''
  213. }
  214. else {
  215. let add
  216. if (GameM.commonData.loginDays <= 7) {
  217. add = GameM.commonData.loginDays * 10
  218. }
  219. else {
  220. add = 70
  221. }
  222. percent += add
  223. //航海
  224. //this.labPercent.string = `<color=#885A00>视频收益 ${percent}%</c><color=#028AC5>(登录${GameM.commonData.loginDays}天+${add}%)</color>`
  225. }
  226. this.light.active = true
  227. this.xing.active = true
  228. this.goldIcons.active = false
  229. this.redMoneyIcons.active = false
  230. this.offlineIcons.active = false
  231. this.lvupcarIcons.active = false
  232. this.popVideoIcons.active = false
  233. this.treasureTicket.active = false
  234. this.clearCoolNode.active = false
  235. this.icon.active = false
  236. this.lyGold.active = false
  237. this.newcarIcons.active = false
  238. this.boxIcons.active = false
  239. this.videoIcon.active = false
  240. this.btnGetGold.active = false
  241. this.btn_close.active = true
  242. // this.btn_close.y = 311
  243. // this.light.y = 149
  244. this.giftBg.active = false
  245. this.titleBg.active = false
  246. this.btnGet.active = false
  247. this.btnBanner.node.active = false
  248. this.videoGetGold.active = false
  249. this.labGoldBtnDes.string = '领取奖励'
  250. this.propNode.active = false
  251. GameM.audioM.playEffect(AUDIO_TYPE.open_interface)
  252. let self = this
  253. switch (this.type) {
  254. case MONEY_TYPE.gold: //金币
  255. this.giftBg.active = true
  256. this.btnGetGold.active = true
  257. if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) {
  258. this.labDayLeft.string = `<b>今日剩余次数:<color=#FF0000>${GameM.commonData.dayBuyCarVideoLimitTimes - 1}</color></b>`
  259. //西游
  260. //唐僧天赋3
  261. if (MateData.Ins.Mate1Talent3 > 0) {
  262. this.videoLabPercent.string = `<b><color=#885A00>金币加成</c> <size=60><color=red>${MateData.Ins.Mate1Talent3}%</c></size></b>`
  263. } else {
  264. this.videoLabPercent.string = "";
  265. }
  266. this.labVideoGold.string = Sciencen_M.instance.format(this.num);
  267. this.videoGetGold.active = true
  268. }
  269. else {
  270. this.labDayLeft.string = ''
  271. this.labNum.string = Sciencen_M.instance.format(this.num);
  272. this.goldIcons.active = true
  273. this.lyGold.active = true
  274. if (this.isVideo) {
  275. this.videoIcon.active = true;
  276. }
  277. }
  278. if (this.carSp != null) {
  279. NativeAdAwardData.Instance.setGetAward(3)
  280. if (NativeAdAwardData.Instance.canGetAward(3)) {
  281. this.labGoldBtnDes.string = `${NativeAdAwardData.Instance.nativeAwardTimes}倍领取`
  282. this.btnGet.active = true
  283. this.streamData = MoreGameData.Instance.getRandomSteam()
  284. if (this.streamData) {
  285. cc.loader.load(this.streamData.stream, (err, res) => {
  286. if (err) {
  287. console.log('err:', err);
  288. return;
  289. }
  290. if (this.btnBanner) {
  291. let tex: cc.Texture2D = res as cc.Texture2D;
  292. this.btnBanner.spriteFrame = new cc.SpriteFrame(tex);
  293. this.btnBanner.node.active = true
  294. }
  295. })
  296. }
  297. }
  298. else {
  299. this.labGoldBtnDes.string = '领取奖励'
  300. this.btnGet.active = false
  301. }
  302. }
  303. else {
  304. this.labGoldBtnDes.string = '领取奖励'
  305. this.btnGet.active = false
  306. }
  307. break
  308. case MONEY_TYPE.redMoney: //红包币 含飞船奖励
  309. this.giftBg.active = true
  310. this.btnGetGold.active = true
  311. this.redMoneyIcons.active = true
  312. this.lyGold.active = true
  313. if (this.isVideo) {
  314. this.videoIcon.active = true;
  315. }
  316. break
  317. case MONEY_TYPE.timespanGold:
  318. break
  319. case MONEY_TYPE.box: //含飞船奖励
  320. this.giftBg.active = true
  321. this.boxIcons.active = true
  322. this.lyGold.active = true
  323. this.icon.active = false
  324. if (isvideo) {
  325. this.videoIcon.active = true
  326. }
  327. this.btnGetGold.active = true
  328. this.labNum.string = '惊喜宝箱 x' + this.num.toString()
  329. break
  330. case MONEY_TYPE.turnTableCard:
  331. this.propNode.active = true
  332. this.btnGetGold.active = true
  333. this.giftBg.active = true
  334. this.propNum.string = "x" + this.num
  335. cc.loader.loadRes('gift/spriteZhuanpanka', cc.SpriteFrame, (err, assets) => {
  336. if (err) {
  337. cc.error(err);
  338. return;
  339. }
  340. this.spriteProp.spriteFrame = assets;
  341. this.spriteProp.node.scale = 0.8
  342. })
  343. if (this.isVideo) {
  344. this.videoIcon.active = true;
  345. }
  346. this.propNode.getChildByName("propName").getComponent(cc.Label).string = "转盘卡"
  347. // if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) {
  348. // this.labDayLeft.string = `今日剩余次数:<color=#0189C5>${GameM.commonData.dayBuyCarVideoLimitTimes - 1}</color>`
  349. // }
  350. // else {
  351. // this.labDayLeft.string = ''
  352. // }
  353. break
  354. case MONEY_TYPE.treasureCard:
  355. this.propNode.active = true
  356. this.btnGetGold.active = true
  357. this.giftBg.active = true
  358. this.propNum.string = "x" + this.num
  359. cc.loader.loadRes('gift/spriteDuobaoquan', cc.SpriteFrame, (err, assets) => {
  360. if (err) {
  361. cc.error(err);
  362. return;
  363. }
  364. this.spriteProp.spriteFrame = assets;
  365. this.spriteProp.node.scale = 0.8
  366. })
  367. if (this.isVideo) {
  368. this.videoIcon.active = true;
  369. }
  370. this.propNode.getChildByName("propName").getComponent(cc.Label).string = "夺宝券"
  371. break
  372. case MONEY_TYPE.speedCard:
  373. this.propNode.active = true
  374. this.btnGetGold.active = true
  375. this.giftBg.active = true
  376. this.propNum.string = "x" + this.num
  377. cc.loader.loadRes('gift/spriteJiasuka', cc.SpriteFrame, (err, assets) => {
  378. if (err) {
  379. cc.error(err);
  380. return;
  381. }
  382. this.spriteProp.spriteFrame = assets;
  383. this.spriteProp.node.scale = 0.8
  384. })
  385. if (this.isVideo) {
  386. this.videoIcon.active = true;
  387. }
  388. this.propNode.getChildByName("propName").getComponent(cc.Label).string = "加速券"
  389. break
  390. case MONEY_TYPE.talentCoin:
  391. this.propNode.active = true
  392. this.btnGetGold.active = true
  393. this.giftBg.active = true
  394. this.propNum.string = "x" + this.num
  395. LogUtil.logV("HTTP_TYPE.updateBattleStoneCount show", MateData.Ins.talentCoin)
  396. cc.loader.loadRes('xiyou/icon/1003', cc.SpriteFrame, (err, assets) => {
  397. if (err) {
  398. cc.error(err);
  399. return;
  400. }
  401. this.spriteProp.spriteFrame = assets;
  402. this.spriteProp.node.scale = 2
  403. })
  404. this.propNode.getChildByName("propName").getComponent(cc.Label).string = "天赋石"
  405. break
  406. case MONEY_TYPE.offlineGold: //离线收益
  407. this.giftBg.active = false
  408. this.titleBg.active = true
  409. this.btnGetGold.active = false
  410. this.offlineIcons.active = true
  411. this.icon.active = true
  412. this.btn_close.active = false
  413. this.lyGold.active = false
  414. this.btn_offlineSingle.active = false;
  415. this.light.active = false
  416. this.offlineIcons.getChildByName("offlineNumLab").getComponent(cc.Label).string = Sciencen_M.instance.format(this.num)
  417. //白龙马天赋2
  418. if (MateData.Ins.Mate3Talent2 > 0) {
  419. this.labPercent.string = `<outline color=#68310b width=2><color=#885A00>天赋加成 ${MateData.Ins.Mate3Talent2}%</c></outline>`
  420. } else {
  421. this.labPercent.string = "";
  422. }
  423. this.scheduleOnce(() => {
  424. // this.offlineIcons.getChildByName("offlineClose").active = true;
  425. // this.btn_offlineSingle.active = true;
  426. // this.btn_offlineSingle.opacity = 0;
  427. // cc.tween(this.btn_offlineSingle).to(0.5, { opacity: 255 }).start();
  428. }, 0);
  429. break
  430. case MONEY_TYPE.getNewCar:
  431. this.titleBg.active = false
  432. this.btn_close.active = false
  433. this.light.active = false
  434. this.xing.active = false
  435. this.btnCarDouble.active = true
  436. this.btnCarGet.active = false
  437. self.car.node.active = false
  438. cc.loader.loadRes('carPic/side/side_' + GameM.commonData.maxCarLevel, cc.SpriteFrame, (err, assets) => {
  439. if (err) {
  440. cc.error(err);
  441. return;
  442. }
  443. self.car.spriteFrame = assets;
  444. self.car.node.active = true
  445. })
  446. this.unschedule(this.getNewCarDelayCall);
  447. this.btn_close.active = false;
  448. this.btnCarSingle.active = false;
  449. this.maxCarLvTxt.string = GameM.commonData.maxCarLevel.toString();
  450. if (GameM.commonData.maxCarLevel <= 4) {
  451. this.btnCarDouble.active = false
  452. this.btnCarGet.active = true
  453. }
  454. else {
  455. this.btnCarDouble.active = true
  456. this.btnCarGet.active = false
  457. }
  458. this.newcarIcons.active = true
  459. this.labCarNum.string = this.num
  460. if (GameM.commonData.redSwitch) {
  461. this.labCarMoney.string = `可兑换${(Number(this.num) * 0.0001).toFixed(2)}元`
  462. }
  463. else {
  464. this.labCarMoney.string = ''
  465. }
  466. this.newCarBg.y = -90
  467. cc.tween(this.newCarBg)
  468. .delay(0.2)
  469. .to(0.5, { y: 100 }).start()
  470. let delayTime = 0
  471. if (SwitchM.forceMakeMoney) {
  472. // delayTime = 2
  473. }
  474. this.scheduleOnce(this.getNewCarDelayCall, delayTime);
  475. break
  476. case MONEY_TYPE.carLvUp:
  477. this.titleBg.active = true
  478. this.btn_close.active = false
  479. this.lvupcarIcons.active = true
  480. self.carTo.node.active = false
  481. this.light.active = false
  482. this.giftBg.active = false
  483. this.labCarTo.string = this.num.toString()
  484. this.labCarN.string = this.carSp.toString()
  485. cc.loader.loadRes('carPic/side/side_' + this.num, cc.SpriteFrame, (err, assets) => {
  486. if (err) {
  487. cc.error(err);
  488. return;
  489. }
  490. self.carTo.spriteFrame = assets;
  491. self.carTo.node.active = true
  492. })
  493. self.carN.node.active = false
  494. cc.loader.loadRes('carPic/side/side_' + this.carSp, cc.SpriteFrame, (err, assets) => {
  495. if (err) {
  496. cc.error(err);
  497. return;
  498. }
  499. self.carN.spriteFrame = assets;
  500. self.carN.node.active = true
  501. })
  502. // this.btn_close.active = false
  503. // this.scheduleOnce(() => {
  504. // this.btn_close.active = true;
  505. // }, 0);
  506. break
  507. case MONEY_TYPE.popVideo: //主动拉视频
  508. this.giftBg.active = true
  509. this.btnGetGold.active = false
  510. this.popVideoIcons.active = true
  511. // if (GameM.commonData.roleData.hangVideoFree == 0) {
  512. // this.popVideoIcon.active = false
  513. // }
  514. // else {
  515. // this.popVideoIcon.active = true
  516. // }
  517. this.popVideoIcon.active = true
  518. this.icon.active = true
  519. this.lyGold.active = true
  520. this.labCurGold.string = Sciencen_M.instance.format(GameM.commonData.gold)
  521. this.scheduleOnce(() => {
  522. this.btn_close.active = true;
  523. }, 0);
  524. break
  525. case MONEY_TYPE.buyCarGold: //点击购买汽车按钮,金币不足
  526. case MONEY_TYPE.mainBuyCarGold: //主界面点击购买汽车按钮,金币不足
  527. this.giftBg.active = true
  528. this.btnGetGold.active = true
  529. this.videoIcon.active = true
  530. // this.goldIcons.active = true
  531. // this.lyGold.active = true
  532. this.labVideoGold.string = Sciencen_M.instance.format(this.num);
  533. this.videoGetGold.active = true
  534. this.labDayLeft.string = `<b>今日剩余次数:<color=#FF0000>${GameM.commonData.dayBuyCarVideoLimitTimes}</color></b>`
  535. //西游
  536. //唐僧天赋3
  537. if (MateData.Ins.Mate1Talent3 > 0) {
  538. // this.labPercent.string = `<color=#885A00>天赋加成 ${MateData.Ins.Mate1Talent3}%</c>`
  539. this.videoLabPercent.string = `<b><color=#885A00>金币加成</c> <size=60><color=red>${MateData.Ins.Mate1Talent3}%</c></size></b>`
  540. } else {
  541. // this.labPercent.string = ""
  542. this.videoLabPercent.string = `<b><color=#885A00>金币加成</c> <size=60><color=red>${0}%</c></size></b>`
  543. }
  544. break
  545. case MONEY_TYPE.treasureTicket: //视频获得兑奖券
  546. this.titleBg.active = false
  547. this.treasureTicket.active = true
  548. this.giftBg.active = true
  549. this.light.active = false
  550. this.treasureGold.string = Sciencen_M.instance.format(this.num)
  551. break
  552. case MONEY_TYPE.clearCooltime: //清除所有罢工时间
  553. this.giftBg.active = false
  554. this.titleBg.active = false
  555. this.btn_close.active = false
  556. this.clearCoolNode.active = true
  557. this.light.active = false
  558. this.unschedule(this.showCleartime)
  559. this.clearBtnNode.active = false
  560. this.clearCloseNode.active = false
  561. let closeTime = 1//显示关闭时间
  562. if (GameM.commonData.adShowConfig && GameM.commonData.adShowConfig.is_show_banner == 1) {
  563. closeTime = 0
  564. }
  565. this.scheduleOnce(this.showCleartime, closeTime)
  566. break
  567. }
  568. AdM.destroyNative()
  569. if (this.adType != VIDEO_TYPE.hangUp) {
  570. this.node.x = 0
  571. }
  572. if (this.giftBg.active) {
  573. // if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn
  574. // || this.type == MONEY_TYPE.buyCarGold || this.type == MONEY_TYPE.mainBuyCarGold
  575. // || this.btnGet.active) {
  576. if (this.btnGet.active || (this.type == MONEY_TYPE.gold && this.adType == VIDEO_TYPE.buyCarMainBtn)) {
  577. // if (GameM.commonData.checkShowMainPop()) {
  578. // AdM.showNative(0)
  579. // }
  580. }
  581. else {
  582. AdM.showNative(0)
  583. }
  584. }
  585. if (!this.btnGet.active) {
  586. AdM.showBanner()
  587. }
  588. }
  589. getNewCarDelayCall() {
  590. // this.btn_close.active = true;
  591. this.btnCarSingle.active = true;
  592. this.btnCarSingle.opacity = 0;
  593. cc.tween(this.btnCarSingle).to(0.5, { opacity: 255 }).start();
  594. }
  595. clickLvUp() {
  596. GameM.audioM.playEffect(AUDIO_TYPE.button)
  597. GameM.adM.watchVideo(this.adType);
  598. }
  599. showCleartime() {
  600. this.clearBtnNode.active = true
  601. this.clearCloseNode.active = true
  602. }
  603. clickClearCoolTime() {
  604. GameM.audioM.playEffect(AUDIO_TYPE.button)
  605. if (GameM.commonData.isVideoTest) {
  606. this.clearCoolTime()
  607. } else {
  608. GameM.adM.watchVideo(this.adType);
  609. }
  610. }
  611. //清除所有罢工
  612. clearCoolTime() {
  613. this.node.active = false
  614. EffectNode.instance.PlayTip(`成功清除所有武将罢工`)
  615. UiM.Instance.hallNode.getComponent(Main).clearAllCoolTime()
  616. }
  617. clickGetGold() {
  618. GameM.audioM.playEffect(AUDIO_TYPE.button)
  619. if (this.turntable) {
  620. UiM.Instance.turntableNode.getComponent(Turntable).updateCurrentNum()
  621. }
  622. switch (this.type) {
  623. case MONEY_TYPE.gold:
  624. if (this.carSp != null) {
  625. if (!NativeAdAwardData.Instance.canGetAward(3)) {
  626. let s = this.carSp.getComponent(CarSpace)
  627. s.changeType(0)
  628. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  629. this.scheduleOnce(() => {
  630. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  631. }, 0.1)
  632. }
  633. }
  634. if (this.isVideo) {
  635. if (this.isAirship) {
  636. GameM.adM.watchVideo(VIDEO_TYPE.gift_gold);
  637. }
  638. }
  639. else {
  640. if (this.isAirship) {
  641. GameM.commonData.updateAirShipTimes()
  642. }
  643. if (this.carSp != null) {
  644. if (!NativeAdAwardData.Instance.canGetAward(3)) {
  645. GameM.commonData.updateGold(this.num)
  646. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  647. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  648. }
  649. else {
  650. UiM.Instance.onPanel(PANEL_NAME.NativeAdAwardNode, false, () => {
  651. UiM.Instance.nativeAdAwardNode.getComponent(NativeADAwardNode).init(3, this.num, this.carSp)
  652. })
  653. }
  654. }
  655. else {
  656. GameM.commonData.updateGold(this.num)
  657. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  658. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  659. }
  660. this.node.active = false
  661. }
  662. if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) {
  663. this.adType = null
  664. let key = 'dddddddddddddddddddddddddddddddd'
  665. GameM.commonData.dayBuyCarVideoLimitTimes--
  666. let d = Utils.Encrypt(GameM.commonData.dayBuyCarVideoLimitTimes, key, GameM.commonData.appid)
  667. GameM.globalStorage.setStorage(STORAGE_KEY.dayBuyCarVideoLimitTimes, d, 1)
  668. EffectNode.instance.PlayTip(`今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes}`)
  669. }
  670. break
  671. case MONEY_TYPE.redMoney: //含飞船奖励
  672. this.node.active = false
  673. //if (this.isAirship) {
  674. if (this.isVideo) {
  675. if (this.isAirship) {
  676. //飞船奖励400元宝看广告获取
  677. GameM.adM.watchVideo(VIDEO_TYPE.gift_redMoney);
  678. } else {
  679. //车位元宝视频
  680. //最高等级车奖励视频
  681. GameM.adM.watchVideo(this.adType);
  682. }
  683. } else {
  684. GameM.commonData.updateRedMoney(Number(this.num), RecordTYPE.onlineGiftRed)
  685. if (this.carSp != null) {
  686. let s = this.carSp.getComponent(CarSpace)
  687. s.changeType(0)
  688. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  689. this.scheduleOnce(() => {
  690. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  691. }, 0.1)
  692. }
  693. if (this.isAirship) {
  694. GameM.commonData.updateAirShipTimes()
  695. }
  696. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  697. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  698. }
  699. break
  700. case MONEY_TYPE.offlineGold:
  701. GameM.commonData.updateGold(this.num)
  702. this.node.active = false
  703. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  704. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  705. break
  706. case MONEY_TYPE.box: //含飞船奖励
  707. if (this.isVideo) {
  708. GameM.adM.watchVideo(VIDEO_TYPE.gift_box)
  709. }
  710. else {
  711. this.node.active = false
  712. if (this.isAirship) {
  713. GameM.commonData.updateAirShipTimes()
  714. }
  715. //立刻生成
  716. for (let i = 0; i < Number(this.num); i++) {
  717. UiM.Instance.hallNode.getComponent(Main).addBoxGiftNow();
  718. }
  719. }
  720. break
  721. case MONEY_TYPE.buyCarGold:
  722. GameM.adM.watchVideo(VIDEO_TYPE.shopBuyCarBtn);
  723. break
  724. case MONEY_TYPE.mainBuyCarGold:
  725. GameM.adM.watchVideo(VIDEO_TYPE.buyCarMainBtn);
  726. break
  727. case MONEY_TYPE.turnTableCard:
  728. if (this.isVideo) {
  729. if (GameM.commonData.isVideoTest) {
  730. this.onPropADEnd()
  731. } else {
  732. GameM.adM.watchVideo(VIDEO_TYPE.gift_Prop);
  733. }
  734. // return
  735. } else {
  736. if (this.carSp != null) {
  737. let s = this.carSp.getComponent(CarSpace)
  738. s.changeType(0)
  739. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  740. this.scheduleOnce(() => {
  741. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  742. }, 0.1)
  743. }
  744. if (this.isAirship) {
  745. GameM.commonData.updateAirShipTimes()
  746. GameM.commonData.roleData.airshipTurntableCard++
  747. }
  748. this.node.active = false
  749. RoleManageData.Instance.addTurntableCardCount(Number(this.num).valueOf())
  750. EffectNode.instance.PlayTip(`转盘卡+${this.num}`)
  751. }
  752. // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  753. // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  754. break
  755. case MONEY_TYPE.treasureCard:
  756. if (this.isVideo) {
  757. if (GameM.commonData.isVideoTest) {
  758. this.onPropADEnd()
  759. } else {
  760. GameM.adM.watchVideo(VIDEO_TYPE.gift_Prop);
  761. }
  762. // return
  763. } else {
  764. if (this.carSp != null) {
  765. let s = this.carSp.getComponent(CarSpace)
  766. s.changeType(0)
  767. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  768. this.scheduleOnce(() => {
  769. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  770. }, 0.1)
  771. }
  772. if (this.isAirship) {
  773. GameM.commonData.updateAirShipTimes()
  774. GameM.commonData.roleData.airshipTicket++
  775. }
  776. this.node.active = false
  777. RoleManageData.Instance.addTreasureCard(Number(this.num).valueOf())
  778. EffectNode.instance.PlayTip(`夺宝券+${this.num}`)
  779. }
  780. // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  781. // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  782. break
  783. case MONEY_TYPE.speedCard:
  784. if (this.isVideo) {
  785. if (GameM.commonData.isVideoTest) {
  786. this.onPropADEnd()
  787. } else {
  788. GameM.adM.watchVideo(VIDEO_TYPE.gift_Prop);
  789. }
  790. // return
  791. } else {
  792. if (this.isAirship) {
  793. GameM.commonData.updateAirShipTimes()
  794. GameM.commonData.roleData.airshipSpeedCard++
  795. }
  796. if (this.carSp != null) {
  797. let s = this.carSp.getComponent(CarSpace)
  798. s.changeType(0)
  799. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  800. this.scheduleOnce(() => {
  801. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  802. }, 0.1)
  803. }
  804. this.node.active = false
  805. RoleManageData.Instance.addInvestCard(Number(this.num).valueOf())
  806. EffectNode.instance.PlayTip(`加速券+${this.num}`)
  807. }
  808. break
  809. case MONEY_TYPE.talentCoin:
  810. if (this.isVideo) {
  811. // if (GameM.commonData.isVideoTest) {
  812. // this.onPropADEnd()
  813. // } else {
  814. // GameM.adM.watchVideo(VIDEO_TYPE.gift_Prop);
  815. // }
  816. // return
  817. } else {
  818. if (this.isAirship) {
  819. // GameM.commonData.updateAirShipTimes()
  820. // GameM.commonData.roleData.airshipSpeedCard++
  821. }
  822. // if (this.carSp != null) {
  823. // let s = this.carSp.getComponent(CarSpace)
  824. // s.changeType(0)
  825. // GameM.commonData.updateBagCarData(s.index.toString(), 0)
  826. // this.scheduleOnce(() => {
  827. // UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  828. // }, 0.1)
  829. // }
  830. this.node.active = false
  831. MateData.Ins.talentCoin += Number(this.num)
  832. LogUtil.logV("HTTP_TYPE.updateBattleStoneCount one", MateData.Ins.talentCoin)
  833. GameM.httpM.SendData(HTTP_TYPE.updateBattleStoneCount, { "count": MateData.Ins.talentCoin })
  834. //更新红点
  835. MateData.Ins.checkMateRedPoint()
  836. EffectNode.instance.PlayTip(`天赋石+${this.num}`)
  837. }
  838. break
  839. }
  840. //显示界面
  841. UiM.Instance.displayPanel();
  842. }
  843. // /**购买按钮视频广告回调*/
  844. // onBuyCarAdEnd() {
  845. // EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  846. // // this.type = MONEY_TYPE.gold
  847. // // this.videoIcon.active = false
  848. // GameM.commonData.updateClickVideoTimes()
  849. // GameM.commonData.updateGold(this.num)
  850. // UiM.Instance.hallNode.getComponent(Main).updateBuyBtnState();
  851. // this.node.active = false
  852. // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  853. // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  854. // }
  855. //飞船看广告后得宝箱
  856. onGiftBoxWatchEnd() {
  857. GameM.commonData.updateGiftCacheNum(this.num)
  858. this.node.active = false
  859. if (this.isAirship) {
  860. GameM.commonData.updateAirShipTimes()
  861. }
  862. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  863. //显示界面
  864. UiM.Instance.displayPanel();
  865. }
  866. //飞船看广告后奖励元宝
  867. onGiftRedMoneyAdEnd() {
  868. GameM.commonData.updateRedMoney(Number(this.num), RecordTYPE.airship)
  869. GameM.commonData.updateAirShipTimes()
  870. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  871. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  872. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  873. }
  874. //飞船看广告后得金币
  875. onGiftGoldADEnd() {
  876. GameM.commonData.updateAirShipTimes()
  877. this.node.active = false
  878. GameM.commonData.updateGold(this.num)
  879. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  880. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  881. }
  882. /** 双倍领取离线收益 */
  883. clickGetOffline() {
  884. GameM.audioM.playEffect(AUDIO_TYPE.button)
  885. GameM.adM.watchVideo(VIDEO_TYPE.offLineDouble)
  886. }
  887. onOfflineWatchEnd() {
  888. this.num = Sciencen_M.instance.accMul(this.num, '2')
  889. GameM.commonData.updateGold(this.num)
  890. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  891. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300))
  892. this.node.active = false
  893. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  894. //显示界面
  895. UiM.Instance.displayPanel();
  896. }
  897. //飞船看广告后获得物品 //夺宝券,加速卡,转盘卡
  898. onPropADEnd() {
  899. if (this.isAirship) {
  900. GameM.commonData.updateAirShipTimes()
  901. switch (this.type) {
  902. case MONEY_TYPE.turnTableCard:
  903. GameM.commonData.roleData.airshipTurntableCard++
  904. break;
  905. case MONEY_TYPE.treasureCard:
  906. GameM.commonData.roleData.airshipTicket++
  907. break;
  908. case MONEY_TYPE.speedCard:
  909. GameM.commonData.roleData.airshipSpeedCard++
  910. break;
  911. }
  912. }
  913. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  914. switch (this.type) {
  915. case MONEY_TYPE.turnTableCard:
  916. if (this.carSp != null) {
  917. let s = this.carSp.getComponent(CarSpace)
  918. s.changeType(0)
  919. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  920. this.scheduleOnce(() => {
  921. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  922. }, 0.1)
  923. }
  924. RoleManageData.Instance.addTurntableCardCount(Number(this.num).valueOf())
  925. EffectNode.instance.PlayTip(`转盘卡+${this.num}`)
  926. // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  927. // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  928. break
  929. case MONEY_TYPE.treasureCard:
  930. if (this.carSp != null) {
  931. let s = this.carSp.getComponent(CarSpace)
  932. s.changeType(0)
  933. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  934. this.scheduleOnce(() => {
  935. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  936. }, 0.1)
  937. }
  938. RoleManageData.Instance.addTreasureCard(Number(this.num).valueOf())
  939. EffectNode.instance.PlayTip(`夺宝券+${this.num}`)
  940. // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  941. // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  942. break
  943. case MONEY_TYPE.speedCard:
  944. if (this.carSp != null) {
  945. let s = this.carSp.getComponent(CarSpace)
  946. s.changeType(0)
  947. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  948. this.scheduleOnce(() => {
  949. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  950. }, 0.1)
  951. }
  952. RoleManageData.Instance.addInvestCard(Number(this.num).valueOf())
  953. EffectNode.instance.PlayTip(`加速券+${this.num}`)
  954. break
  955. }
  956. this.node.active = false
  957. }
  958. //直接领取
  959. clickGetCarSingle() {
  960. GameM.audioM.playEffect(AUDIO_TYPE.button)
  961. GameM.commonData.updateRedMoney(Number(this.num), RecordTYPE.carLevelup)
  962. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  963. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  964. this.node.active = false
  965. console.log("----> clickGetCarSingle")
  966. this.checkShowGuide()
  967. UiM.Instance.hallNode.getComponent(Main).playCarProEff()
  968. }
  969. checkShowGuide() {
  970. // if (GameM.commonData.maxCarLevel == GameM.commonData.cashCft[0].type_value && UiM.Instance.hallNode) {
  971. // UiM.Instance.hallNode.getComponent(Main).checkNewUser()
  972. // }
  973. let setColor = false
  974. if (GameM.commonData.maxCarLevel == 2) {
  975. if (GameM.commonData.redSwitch) {
  976. // UiM.Instance.guideNode.getComponent(Guide).showMask4();
  977. setColor = true
  978. }
  979. }
  980. else if (GameM.commonData.maxCarLevel == 3) {
  981. if (GameM.commonData.redSwitch) {
  982. // UiM.Instance.guideNode.getComponent(Guide).showGuide10();
  983. setColor = true
  984. }
  985. }
  986. else if (GameM.commonData.maxCarLevel == GameM.commonData.dailyCashOpenLevel) {
  987. setColor = true
  988. if (GameM.commonData.redSwitch) {
  989. GuideManager.Instance.createFullGuide(cc.find("Canvas"), 2, () => {
  990. // UiM.Instance.guideNode.getComponent(Guide).showGuide9(0)
  991. })
  992. }
  993. }
  994. // else if (GameM.commonData.maxCarLevel == GameM.commonData.investOpenLevel) {
  995. // //投资引导
  996. // UiM.Instance.hallNode.getComponent(Main).showInvestHand()
  997. // setColor = true
  998. // }
  999. //else if (GameM.commonData.maxCarLevel == GameM.commonData.factoryOpenLevel) {
  1000. else if (GameM.commonData.maxCarLevel == GameM.commonData.unlockStrikeLv) {
  1001. //工厂开启 改为 开启西游点击生成金币
  1002. //西游 点击武将生成金币引导 放到最新引导模块
  1003. if (!GuideMng.Ins.IsUnlockStrike()) {
  1004. let name = UiM.Instance.hallNode.getComponent(Main).GetRoleSpaceIndex();
  1005. console.log("-->StrikeGuideName:" + name);
  1006. GuideMng.Ins.UpdateGuideStrikeFile(name);
  1007. GuideMng.Ins.CheckUnlockStrike();
  1008. }
  1009. //航海
  1010. //UiM.Instance.guideNode.getComponent(Guide).showFacGuide()
  1011. //setColor = true
  1012. }
  1013. else if (GameM.commonData.maxCarLevel == GameM.commonData.loginRewardOpenLevel) {
  1014. if (GameM.commonData.redSwitch) {
  1015. // UiM.Instance.guideNode.getComponent(Guide).showDailyGuide()
  1016. setColor = true
  1017. }
  1018. }
  1019. else if (GameM.commonData.maxCarLevel == GameM.commonData.trerasureOpenLevel) {
  1020. setColor = true
  1021. if (GameM.commonData.redSwitch) {
  1022. // GuideManager.Instance.createFullGuide(cc.find("Canvas"), 3, () => {
  1023. // UiM.Instance.guideNode.getComponent(Guide).showTreasureStep1();
  1024. // })
  1025. }
  1026. }
  1027. // else if (GameM.commonData.maxCarLevel == GameM.commonData.richBankUnLockLevel) {
  1028. // setColor = true
  1029. // if (GameM.commonData.redSwitch) {
  1030. // LogUtil.logV("HTTP_TYPE.bankCashRecord", "")
  1031. // GameM.httpM.sendDatas(HTTP_TYPE.backIsOpenRichBank, {})
  1032. // // UiM.Instance.guideNode.getComponent(Guide).bankGuideStep1();
  1033. // // to do
  1034. // // GuideManager.Instance.createFullGuide(cc.find("Canvas"), 3, () => {
  1035. // // UiM.Instance.guideNode.getComponent(Guide).showTreasureStep1();
  1036. // // })
  1037. // }
  1038. // }
  1039. else if (GameM.commonData.maxCarLevel == GameM.commonData.taskOpenLevel) {
  1040. setColor = true
  1041. // UiM.Instance.guideNode.getComponent(Guide).showTask1();
  1042. }
  1043. else {
  1044. //显示界面
  1045. UiM.Instance.displayPanel();
  1046. }
  1047. if (setColor) {
  1048. UiM.Instance.setPanelCool()
  1049. UiM.Instance.hallNode.getComponent(Main).setUnlockBtnColor()
  1050. }
  1051. //西游
  1052. //若解锁新车不进入该界面 getNewCar 此处不会被执行
  1053. //第一次合成战斗判断
  1054. FightData.Ins.CheckComposeFight();
  1055. }
  1056. //双倍奖励 黄色按钮
  1057. clickGetCarDouble() {
  1058. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1059. GameM.adM.watchVideo(VIDEO_TYPE.newCarAward)
  1060. }
  1061. clickGetTreasureCard() {
  1062. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1063. if (GameM.commonData.isVideoTest) {
  1064. UiM.Instance.giftNode.getComponent(Gift).onGetTicketAdEnd()
  1065. } else {
  1066. GameM.adM.watchVideo(VIDEO_TYPE.getTicket)
  1067. }
  1068. }
  1069. onGetTicketAdEnd() {
  1070. LogUtil.logV(" onGetTicketAdEndt", "start")
  1071. GameM.commonData.roleData.ticket++
  1072. GameM.commonData.updateRoleData()
  1073. GameM.commonData.updateGold(this.num)
  1074. GameM.commonData.updateClickVideoTimes()
  1075. let str = Sciencen_M.instance.format(this.num)
  1076. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  1077. EffectNode.instance.PlayTip(`获得金币${str},夺宝券+1`)
  1078. UiM.Instance.treasureNode.getComponent(Treasure).onGetTicketAdEnd()
  1079. this.node.active = false
  1080. }
  1081. onGetCarDoubleWatchEnd() {
  1082. this.btnCarGet.active = true
  1083. this.btnCarDouble.active = false
  1084. this.btnCarSingle.active = false
  1085. this.num = Sciencen_M.instance.addition(this.num, this.num)
  1086. this.labCarNum.string = this.num
  1087. if (GameM.commonData.redSwitch) {
  1088. this.labCarMoney.string = `可兑换${(Number(this.num) * 0.0001).toFixed(2)}元`
  1089. }
  1090. else {
  1091. this.labCarMoney.string = ''
  1092. }
  1093. cc.tween(this.labCarNum.node)
  1094. .delay(0.3)
  1095. .to(0.2, { scale: 1.5 })
  1096. .to(0.2, { scale: 1 })
  1097. .start()
  1098. }
  1099. //领取奖励 黄色按钮 双倍奖励广告后 出现
  1100. clickCarGet() {
  1101. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1102. GameM.commonData.updateRedMoney(Number(this.num), RecordTYPE.carLevelup)
  1103. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  1104. EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300));
  1105. this.node.active = false
  1106. console.log("----> clickCarGet")
  1107. this.checkShowGuide()
  1108. UiM.Instance.hallNode.getComponent(Main).playCarProEff()
  1109. }
  1110. clickBg() {
  1111. if (this.type == MONEY_TYPE.offlineGold) {
  1112. GameM.commonData.updateGold(this.num)
  1113. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  1114. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  1115. this.node.active = false
  1116. }
  1117. else if (this.type == MONEY_TYPE.gold) {
  1118. if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) {
  1119. this.adType = null
  1120. let key = 'dddddddddddddddddddddddddddddddd'
  1121. GameM.commonData.dayBuyCarVideoLimitTimes--
  1122. let d = Utils.Encrypt(GameM.commonData.dayBuyCarVideoLimitTimes, key, GameM.commonData.appid)
  1123. GameM.globalStorage.setStorage(STORAGE_KEY.dayBuyCarVideoLimitTimes, d, 1)
  1124. EffectNode.instance.PlayTip(`今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes}`)
  1125. }
  1126. }
  1127. //显示界面
  1128. UiM.Instance.displayPanel();
  1129. }
  1130. clickBgClose() {
  1131. //车辆升级 解锁新车时 无效
  1132. if (this.type == MONEY_TYPE.carLvUp || this.type == MONEY_TYPE.getNewCar) {
  1133. return
  1134. }
  1135. this.clickClose()
  1136. }
  1137. //关闭按钮
  1138. clickClose() {
  1139. // // test
  1140. // this.checkShowGuide()
  1141. LogUtil.logV("gift", "clickClose")
  1142. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1143. if (this.type == MONEY_TYPE.offlineGold) {
  1144. GameM.commonData.updateGold(this.num)
  1145. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  1146. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  1147. if (DailyData.Instance.checkHasGet() && GameM.commonData.maxCarLevel >= GameM.commonData.loginRewardOpenLevel) {
  1148. UiM.Instance.onPanel(PANEL_NAME.DailyNode)
  1149. } else {
  1150. if (GameM.commonData.loginDays >= 2) {
  1151. UiM.Instance.hallNode.getComponent(Main).checkShowClubGuideNode()
  1152. }
  1153. }
  1154. }
  1155. if (this.turntable) {
  1156. UiM.Instance.turntableNode.getComponent(Turntable).updateCurrentNum()
  1157. this.clickGetGold()
  1158. } else if (this.type == MONEY_TYPE.gold) {
  1159. if (!this.isVideo) {
  1160. if (this.isAirship) {
  1161. GameM.commonData.updateAirShipTimes()
  1162. }
  1163. GameM.commonData.updateGold(this.num)
  1164. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  1165. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  1166. }
  1167. if (this.carSp != null) {
  1168. let s = this.carSp.getComponent(CarSpace)
  1169. s.changeType(0)
  1170. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  1171. this.scheduleOnce(() => {
  1172. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  1173. }, 0.1)
  1174. }
  1175. if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) {
  1176. this.adType = null
  1177. let key = 'dddddddddddddddddddddddddddddddd'
  1178. GameM.commonData.dayBuyCarVideoLimitTimes--
  1179. let d = Utils.Encrypt(GameM.commonData.dayBuyCarVideoLimitTimes, key, GameM.commonData.appid)
  1180. GameM.globalStorage.setStorage(STORAGE_KEY.dayBuyCarVideoLimitTimes, d, 1)
  1181. EffectNode.instance.PlayTip(`今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes}`)
  1182. }
  1183. }
  1184. else if (this.type == MONEY_TYPE.popVideo) {
  1185. GameM.commonData.hasPopVideo = false
  1186. }
  1187. else if (this.type == MONEY_TYPE.getNewCar) {
  1188. //若新车解锁 不进入该界面 则该处不会被执行到
  1189. console.log("----> clickClose")
  1190. this.checkShowGuide()
  1191. this.node.active = false
  1192. UiM.Instance.hallNode.getComponent(Main).playCarProEff()
  1193. return
  1194. }
  1195. else if (this.type == MONEY_TYPE.treasureTicket) {
  1196. LogUtil.logV("gift", "MONEY_TYPE.treasureTicket one")
  1197. // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  1198. // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  1199. } else if (this.type == MONEY_TYPE.clearCooltime) {
  1200. LogUtil.logV("gift", "MONEY_TYPE.clearCooltime one")
  1201. if (this.clearCloseNode.active == false) {
  1202. return
  1203. }
  1204. }
  1205. else if (this.type == MONEY_TYPE.mainBuyCarGold) {
  1206. // //引导取经 大富翁
  1207. // if (RichData.Ins.richCfg.richmanopen == 1) {
  1208. // let hasGuide = PlayerPrefs.GetInt("GGuide20", 0) == 1
  1209. // if (!hasGuide) {
  1210. // GuideMng.Ins.CheckRichGuide20();
  1211. // }
  1212. // else {
  1213. // this.ifPopCoinTipNode()
  1214. // }
  1215. // }
  1216. // else {
  1217. // this.ifPopCoinTipNode()
  1218. // }
  1219. this.ifPopCoinTipNode()
  1220. }
  1221. this.node.active = false
  1222. //显示界面
  1223. UiM.Instance.displayPanel();
  1224. }
  1225. ifPopCoinTipNode() {
  1226. let hasShow = GlobalStorage.Instance.getStorage(STORAGE_KEY.CoinTipTotay, 0)
  1227. if (!hasShow) {
  1228. UiM.Instance.onPanel(PANEL_NAME.CoinTipNode)
  1229. GlobalStorage.Instance.setStorage(STORAGE_KEY.CoinTipTotay, 1, 0)
  1230. }
  1231. }
  1232. // update (dt) {}
  1233. clickOfflineSingle() {
  1234. GameM.commonData.updateGold(this.num)
  1235. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  1236. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300))
  1237. this.node.active = false
  1238. //显示界面
  1239. UiM.Instance.displayPanel();
  1240. }
  1241. clickPopVideo() {
  1242. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1243. // if (GameM.commonData.roleData.hangVideoFree == 0) {
  1244. // GameM.commonData.updateHangVideoFree()
  1245. // GameM.commonData.updateGold(this.num)
  1246. // this.node.active = false
  1247. // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  1248. // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  1249. // GameM.commonData.hasPopVideo = false
  1250. // }
  1251. // else {
  1252. // let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.4 - 2))
  1253. // let gift = UiM.Instance.giftNode.getComponent(Gift)
  1254. // let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold
  1255. // num = Sciencen_M.instance.accMul(num, percent.toString())
  1256. // percent = Math.floor(percent * 100)
  1257. // gift.init(MONEY_TYPE.gold, num, null, false, 0, null, percent)
  1258. // UiM.Instance.giftNode.active = true
  1259. // UiM.Instance.giftNode.x = 1000
  1260. GameM.commonData.hasTouch = true
  1261. if (GameM.commonData.isVideoTest) {
  1262. UiM.Instance.hallNode.getComponent(Main).onHangUpAdEnd()
  1263. }
  1264. else {
  1265. GameM.adM.watchVideo(VIDEO_TYPE.hangUp)
  1266. }
  1267. // }
  1268. }
  1269. /** 放弃热气球 */
  1270. clickDropAirShip() {
  1271. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1272. this.node.active = false
  1273. UiM.Instance.hallNode.getComponent(Main).dropAirShip()
  1274. }
  1275. /** 工厂过热冷却时间减半 */
  1276. clickFacReduceTime() {
  1277. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1278. this.node.active = false
  1279. UiM.Instance.onPanel(PANEL_NAME.NativeAdAwardNode, false, () => {
  1280. UiM.Instance.nativeAdAwardNode.getComponent(NativeADAwardNode).init(1)
  1281. })
  1282. }
  1283. changeAir = false
  1284. /** 换一个热气球奖励 */
  1285. clickChangeAirShip() {
  1286. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1287. this.changeAir = true
  1288. this.node.active = false
  1289. UiM.Instance.onPanel(PANEL_NAME.NativeAdAwardNode, false, () => {
  1290. UiM.Instance.nativeAdAwardNode.getComponent(NativeADAwardNode).init(2)
  1291. })
  1292. }
  1293. /** 车位金币普通领取 */
  1294. clickGet() {
  1295. let s = this.carSp.getComponent(CarSpace)
  1296. s.changeType(0)
  1297. GameM.commonData.updateBagCarData(s.index.toString(), 0)
  1298. this.scheduleOnce(() => {
  1299. UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
  1300. }, 0.1)
  1301. this.node.active = false
  1302. GameM.commonData.updateGold(this.num)
  1303. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  1304. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  1305. }
  1306. cool = false
  1307. clickBanner() {
  1308. GameM.audioM.playEffect(AUDIO_TYPE.button)
  1309. if (this.cool) {
  1310. return
  1311. }
  1312. this.cool = true
  1313. this.scheduleOnce(() => {
  1314. this.cool = false
  1315. }, 3)
  1316. MoreGameData.Instance.createNewTask(this.streamData)
  1317. }
  1318. }