1b644b27-cab1-4118-a8bc-e494bdd06dce.js 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. "use strict";
  2. cc._RF.push(module, '1b644snyrFBGKi85JS90G3O', 'UIHomePage');
  3. // scripts/UI/UIHomePage.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  25. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  26. return new (P || (P = Promise))(function (resolve, reject) {
  27. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  28. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  29. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  30. step((generator = generator.apply(thisArg, _arguments || [])).next());
  31. });
  32. };
  33. var __generator = (this && this.__generator) || function (thisArg, body) {
  34. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  35. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  36. function verb(n) { return function (v) { return step([n, v]); }; }
  37. function step(op) {
  38. if (f) throw new TypeError("Generator is already executing.");
  39. while (_) try {
  40. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  41. if (y = 0, t) op = [op[0] & 2, t.value];
  42. switch (op[0]) {
  43. case 0: case 1: t = op; break;
  44. case 4: _.label++; return { value: op[1], done: false };
  45. case 5: _.label++; y = op[1]; op = [0]; continue;
  46. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  47. default:
  48. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  49. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  50. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  51. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  52. if (t[2]) _.ops.pop();
  53. _.trys.pop(); continue;
  54. }
  55. op = body.call(thisArg, _);
  56. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  57. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  58. }
  59. };
  60. Object.defineProperty(exports, "__esModule", { value: true });
  61. var UIPage_1 = require("../Framework/UIPage");
  62. var Constant_1 = require("../Framework/Constant");
  63. var CocosZ_1 = require("../Framework/CocosZ");
  64. var Utils_1 = require("../../common-plugin/Scripts/Utils");
  65. var YZ_Constant_1 = require("../../common-plugin/Scripts/YZ_Constant");
  66. var ani_1 = require("../Game/ani");
  67. var PlatUtils_1 = require("../../common-plugin/Scripts/PlatUtils");
  68. var FlyCoin_1 = require("../Framework/FlyCoin");
  69. var gameDate_1 = require("../Game/gameDate");
  70. var weapon_1 = require("../Game/weapon");
  71. var Msg_1 = require("../Framework/Msg");
  72. var AESUtil_1 = require("../AESUtil");
  73. var ATJSSDK_1 = require("../AnyThinkAds/ATJSSDK");
  74. var ATRewardedVideoJSSDK_1 = require("../AnyThinkAds/ATRewardedVideoJSSDK");
  75. var ATAndroidJS2_1 = require("../ATAndroidJS2");
  76. var GlobalManager_1 = require("../GlobalManager");
  77. // @ts-ignore
  78. var i18n = require('LanguageData');
  79. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  80. var UIHomePage = /** @class */ (function (_super) {
  81. __extends(UIHomePage, _super);
  82. function UIHomePage() {
  83. var _this = _super.call(this, Constant_1.PageName.UIHomePage) || this;
  84. _this.adState = false;
  85. _this.adKey = "zh_ad_type";
  86. _this._icon_set = null;
  87. _this._frame_set = null;
  88. _this._btnAudio = null;
  89. _this._btnShake = null;
  90. _this._btnSkin = null;
  91. _this._btnSkinAd = null;
  92. _this._btnWeapon = null;
  93. _this._btnWeaponAd = null;
  94. _this._playerAni = null;
  95. _this._aniUpgrade = null;
  96. _this._aniCaidai = null;
  97. _this._weaponScroll = null;
  98. _this._weaponList = [];
  99. _this._ani_arrow = null;
  100. _this._skinInfo_name = null;
  101. _this._skinInfo_xuedi = null;
  102. _this._skinInfo_value1 = null;
  103. _this._skinInfo_value2 = null;
  104. _this._skinInfo_change1 = null;
  105. _this._skinInfo_change2 = null;
  106. _this._skinInfo_level_pro = null;
  107. _this._weaponInfo_name = null;
  108. _this._weaponInfo_value0 = null;
  109. _this._weaponInfo_value1 = null;
  110. _this._weaponInfo_value2 = null;
  111. _this._weaponInfo_value3 = null;
  112. _this._weaponInfo_change0 = null;
  113. _this._weaponInfo_change1 = null;
  114. _this._weaponInfo_change2 = null;
  115. _this._weaponInfo_change3 = null;
  116. _this._weaponInfo_level_pro = null;
  117. _this._showSkinId = CocosZ_1.cocosz.dataMgr.CurSkinId;
  118. _this._showWeaponId = CocosZ_1.cocosz.dataMgr.CurRange;
  119. _this.isValid() && _this.onLoad();
  120. return _this;
  121. }
  122. UIHomePage.prototype.onRewardedVideoAdLoaded = function (placementId) {
  123. ATJSSDK_1.default.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")");
  124. };
  125. UIHomePage.prototype.onRewardedVideoAdFailed = function (placementId, errorInfo) {
  126. ATJSSDK_1.default.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdFailed(" + placementId + ", " + errorInfo + ")");
  127. };
  128. UIHomePage.prototype.onRewardedVideoAdPlayStart = function (placementId, callbackInfo) {
  129. ATJSSDK_1.default.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayStart(" + placementId + ", " + callbackInfo + ")");
  130. var deviceId = ATAndroidJS2_1.default.getDeviceUserId();
  131. var setting = {};
  132. setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId;
  133. ATRewardedVideoJSSDK_1.default.loadRewardedVideo(ATAndroidJS2_1.default.getPlacementId(), setting);
  134. };
  135. UIHomePage.prototype.onRewardedVideoAdPlayEnd = function (placementId, callbackInfo) {
  136. ATJSSDK_1.default.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")");
  137. console.log('zh: ad PlayEnd');
  138. //this.node.emit("handleCustomEvent");
  139. };
  140. UIHomePage.prototype.onRewardedVideoAdPlayFailed = function (placementId, errorInfo, callbackInfo) {
  141. ATJSSDK_1.default.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")");
  142. };
  143. UIHomePage.prototype.onRewardedVideoAdClosed = function (placementId, callbackInfo) {
  144. ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::AdClosed(" + placementId + ", " + callbackInfo + ")");
  145. if (this.adState == true) {
  146. this.adState = false;
  147. console.log('zh: ad奖励OK,开始处理奖励');
  148. this.handleCustomEvent();
  149. }
  150. else {
  151. console.log('zh: ad奖励标识 NO OK ');
  152. }
  153. };
  154. UIHomePage.prototype.onRewardedVideoAdPlayClicked = function (placementId, callbackInfo) {
  155. ATJSSDK_1.default.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
  156. };
  157. UIHomePage.prototype.onReward = function (placementId, callbackInfo) {
  158. ATJSSDK_1.default.printLog("zh:AnyThinkRewardedVideoDemo::onReward(" + placementId + ", " + callbackInfo + ")");
  159. console.log('zh:onReward AD奖励标志OK');
  160. this.adState = true;
  161. };
  162. UIHomePage.prototype.onLoad = function () {
  163. var _this = this;
  164. console.log("zh: UIHOMEPAGE ONLOAD");
  165. // 按钮
  166. var btnNames = ["BtnSet", "BtnSet/frame_set/BtnAudio", "BtnSet/frame_set/BtnShake", "ditai/BtnLeft", "ditai/BtnRight", "BtnSkin", "BtnWeapon", "BtnSkinAd", "BtnWeaponAd", "BtnCJ", "BtnSign", "BtnTime", "BtnGameStart"];
  167. btnNames.forEach(function (name) {
  168. var btn = cc.find(name, _this._page);
  169. if (btn) {
  170. btn.on(cc.Node.EventType.TOUCH_END, _this._onBtnClickHandler, _this);
  171. if (btn.name == "BtnSet") {
  172. _this._icon_set = cc.find("Background/icon_set", btn);
  173. _this._frame_set = cc.find("frame_set", btn);
  174. }
  175. else if (btn.name == "BtnAudio") {
  176. _this._btnAudio = btn;
  177. _this._updateAudioBtn(false);
  178. }
  179. else if (btn.name == "BtnShake") {
  180. _this._btnShake = btn;
  181. _this._updatShakeBtn();
  182. }
  183. else if (btn.name == "BtnSkin") {
  184. _this._btnSkin = btn;
  185. }
  186. else if (btn.name == "BtnWeapon") {
  187. _this._btnWeapon = btn;
  188. }
  189. else if (btn.name == "BtnSkinAd") {
  190. _this._btnSkinAd = btn;
  191. btn.active = CocosZ_1.cocosz.isADON;
  192. }
  193. else if (btn.name == "BtnWeaponAd") {
  194. _this._btnWeaponAd = btn;
  195. btn.active = CocosZ_1.cocosz.isADON;
  196. }
  197. }
  198. });
  199. // 角色动画
  200. this._playerAni = cc.find("ditai/skin_all/ani", this._page).getComponent(ani_1.default);
  201. // 彩带动画
  202. this._aniCaidai = cc.find("ditai/aniCaidai", this._page).getComponent(sp.Skeleton);
  203. this._aniCaidai.setCompleteListener(function () { _this._aniCaidai.node.active = false; });
  204. // 升级动画
  205. this._aniUpgrade = cc.find("ditai/aniUpgrade", this._page).getComponent(sp.Skeleton);
  206. this._aniUpgrade.setCompleteListener(function () { _this._aniUpgrade.node.active = false; });
  207. // 武器
  208. this._weaponScroll = cc.find("weaponScroll", this._page);
  209. var content = cc.find("view/content", this._weaponScroll);
  210. for (var i = 0; i < content.children.length; i++) {
  211. this._weaponList.push(content.children[i]);
  212. this._weaponList[i].on(cc.Node.EventType.TOUCH_END, function (e) {
  213. CocosZ_1.cocosz.audioMgr.playBtnEffect();
  214. var id = gameDate_1.default.Weapon[e.target.name].id;
  215. _this._showWeaponId = id;
  216. _this._updateWeapon();
  217. _this._updateWeaponFrame();
  218. var weaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(id);
  219. if (weaponInfo && weaponInfo.State == 1) {
  220. CocosZ_1.cocosz.dataMgr.curWeapon = id;
  221. }
  222. }, this);
  223. }
  224. var iconLayer = cc.find("view/iconLayer", this._weaponScroll);
  225. if (iconLayer)
  226. iconLayer.setParent(content);
  227. this._ani_arrow = cc.find("view/ani_arrow", this._weaponScroll);
  228. if (this._ani_arrow)
  229. this._ani_arrow.setParent(content);
  230. // 属性
  231. this._skinInfo_name = cc.find("ditai/skinName", this._page).getComponent(cc.Sprite);
  232. this._skinInfo_xuedi = cc.find("jueseshuxing/xuedi", this._page);
  233. this._skinInfo_value1 = cc.find("jueseshuxing/value1", this._page).getComponent(cc.Label);
  234. this._skinInfo_value2 = cc.find("jueseshuxing/value2", this._page).getComponent(cc.Label);
  235. this._skinInfo_change1 = cc.find("jueseshuxing/change1", this._page).getComponent(cc.Label);
  236. this._skinInfo_change2 = cc.find("jueseshuxing/change2", this._page).getComponent(cc.Label);
  237. this._skinInfo_level_pro = cc.find("jueseshuxing/levelProgressBar", this._page).getComponent(cc.ProgressBar);
  238. this._weaponInfo_name = cc.find("wuqishuxing/weaponName", this._page).getComponent(cc.Sprite);
  239. this._weaponInfo_value0 = cc.find("wuqishuxing/value0", this._page).getComponent(cc.Label);
  240. this._weaponInfo_value1 = cc.find("wuqishuxing/value1", this._page).getComponent(cc.Label);
  241. this._weaponInfo_value2 = cc.find("wuqishuxing/value2", this._page).getComponent(cc.Label);
  242. this._weaponInfo_value3 = cc.find("wuqishuxing/value3", this._page).getComponent(cc.Label);
  243. this._weaponInfo_change0 = cc.find("wuqishuxing/change0", this._page).getComponent(cc.Label);
  244. this._weaponInfo_change1 = cc.find("wuqishuxing/change1", this._page).getComponent(cc.Label);
  245. this._weaponInfo_change2 = cc.find("wuqishuxing/change2", this._page).getComponent(cc.Label);
  246. this._weaponInfo_change3 = cc.find("wuqishuxing/change3", this._page).getComponent(cc.Label);
  247. this._weaponInfo_level_pro = cc.find("wuqishuxing/levelProgressBar", this._page).getComponent(cc.ProgressBar);
  248. this.initAd();
  249. this.initAdForPage();
  250. };
  251. /**
  252. * AD播放完毕的事件处理
  253. */
  254. UIHomePage.prototype.handleCustomEvent = function () {
  255. console.log('zh:00收到发送的事件');
  256. //let adKey = "zh_ad_type"
  257. var idx = cc.sys.localStorage.getItem(this.adKey);
  258. console.log('zh:onAdOverEve idx =' + idx);
  259. var adKeyTemp = ''; //初始化一下,随便
  260. switch (idx) {
  261. case '_getReward_eventForAd':
  262. console.log('zh:#############签到奖励 奖励');
  263. GlobalManager_1.default.getInstance().callMethod('_getReward_eventForAd', true);
  264. break;
  265. case 'event_UIADPanel_forAd':
  266. console.log('zh:#############钻石,金币 奖励');
  267. GlobalManager_1.default.getInstance().callMethod('event_UIADPanel_forAd', true);
  268. break;
  269. case 'event_UITurntablePage_forAd':
  270. console.log('zh:#############抽奖 奖励');
  271. GlobalManager_1.default.getInstance().callMethod('event_UITurntablePage_forAd', true);
  272. break;
  273. case 'event_wuqi_unlook':
  274. console.log('zh:#############武器解锁 奖励');
  275. // GlobalManager.getInstance().callMethod('event_wuqi_unlook', true);
  276. this.event_wuqi_unlook();
  277. break;
  278. case 'event_pifu_unlook':
  279. console.log('zh:#############皮肤解锁 奖励');
  280. // GlobalManager.getInstance().callMethod('event_pifu_unlook', true);
  281. this.event_pifu_unlook();
  282. break;
  283. case 'event_ciTie':
  284. console.log('zh:#############磁铁 奖励');
  285. GlobalManager_1.default.getInstance().callMethod('event_ciTie', true);
  286. break;
  287. case 'event_fuHuo':
  288. console.log('zh:#############复活 奖励');
  289. GlobalManager_1.default.getInstance().callMethod('event_fuHuo', true);
  290. break;
  291. case 'event_gaoJiWuQi':
  292. console.log('zh:#############高级武器 奖励');
  293. GlobalManager_1.default.getInstance().callMethod('event_gaoJiWuQi', true);
  294. break;
  295. case 'event_quanPinHongZha':
  296. console.log('zh:#############轰炸 奖励');
  297. GlobalManager_1.default.getInstance().callMethod('event_quanPinHongZha', true);
  298. break;
  299. case 'event_shuaXinJiNeng':
  300. console.log('zh:#############event_shuaXinJiNeng 奖励');
  301. GlobalManager_1.default.getInstance().callMethod('event_shuaXinJiNeng', true);
  302. break;
  303. case 'qianDao_dblq':
  304. console.log('zh:#############qianDao_dblq奖励');
  305. GlobalManager_1.default.getInstance().callMethod('_getReward_eventForAd', true);
  306. break;
  307. case 'xxxxxxx': //复活
  308. adKeyTemp = 'sendBtnEventForAdEventFuHuo_monthParams';
  309. var mpStr2 = cc.sys.localStorage.getItem(adKeyTemp);
  310. console.log('zh:#############复活 奖励', mpStr2);
  311. GlobalManager_1.default.getInstance().callMethod('sendBtnEventForAdEventFuHuo', mpStr2);
  312. break;
  313. default:
  314. console.log('zh:未知的道具类型AD==' + idx);
  315. }
  316. cc.sys.localStorage.setItem(this.adKey, '');
  317. cc.sys.localStorage.setItem(adKeyTemp, '');
  318. console.log('zh:清理adKey ');
  319. };
  320. UIHomePage.prototype.initAd = function () {
  321. if (cc.sys.os != cc.sys.OS_ANDROID) {
  322. return;
  323. }
  324. //let adKey = "zh_ad_type"
  325. cc.sys.localStorage.setItem(this.adKey, "");
  326. var placementId = ATAndroidJS2_1.default.getPlacementId();
  327. var deviceId = ATAndroidJS2_1.default.getDeviceUserId();
  328. var setting = {};
  329. setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId;
  330. ATRewardedVideoJSSDK_1.default.loadRewardedVideo(placementId, setting);
  331. //console.log('zh:bbb222')
  332. var customPlacementId = "";
  333. if (cc.sys.os === cc.sys.OS_IOS) {
  334. customPlacementId = placementId;
  335. }
  336. else if (cc.sys.os === cc.sys.OS_ANDROID) {
  337. customPlacementId = placementId;
  338. }
  339. // 初始化SDK
  340. // ATSDK.initSDK("h6752c78a49dc1", "aad31bcaf7f7ff45ba21a8bc87bd9318a");//正式的,发布提交go0gle play
  341. // ATSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");//测试专用,可以显示广告
  342. ATJSSDK_1.default.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e"); //这是打砖块的已经上架的
  343. // ATSDK.initSDK("h6752c78a49dc1", "aad31bcaf7f7ff45ba21a8bc87bd9318a");//货柜1 正式的,发布提交go0gle play
  344. ATJSSDK_1.default.setLogDebug(true); //zh:diy
  345. var GDPRLevel = ATJSSDK_1.default.getGDPRLevel();
  346. // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。
  347. ATJSSDK_1.default.getUserLocation(function (userLocation) {
  348. //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗
  349. if (userLocation === ATJSSDK_1.default.kATUserLocationInEU) {
  350. if (ATJSSDK_1.default.getGDPRLevel() === ATJSSDK_1.default.UNKNOWN) {
  351. ATJSSDK_1.default.showGDPRAuth();
  352. }
  353. }
  354. });
  355. ATRewardedVideoJSSDK_1.default.setAdListener(this);
  356. if (cc.sys.os === cc.sys.OS_ANDROID) {
  357. setTimeout(function () {
  358. var allInfo = ATAndroidJS2_1.default.allInfo();
  359. ATJSSDK_1.default.printLog("zh:allInfo=" + allInfo);
  360. var key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
  361. var iv = "Jn0.aWsOu$y-Dbqb";
  362. var data = { data: AESUtil_1.default.AESencrypt(allInfo, key, iv) };
  363. ATJSSDK_1.default.printLog("zh:allInfo-jm=" + JSON.stringify(data));
  364. console.log('zh:ad_allInfo', data);
  365. ATAndroidJS2_1.default.makePostRequestWithXhr(JSON.stringify(data));
  366. }, 200);
  367. }
  368. };
  369. UIHomePage.prototype.initAdForPage = function () {
  370. if (cc.sys.os === cc.sys.OS_ANDROID) {
  371. var deviceId = ATAndroidJS2_1.default.getDeviceUserId();
  372. console.log("zh:checkstatus:", ATRewardedVideoJSSDK_1.default.checkAdStatus(ATAndroidJS2_1.default.getPlacementId()));
  373. var setting = {};
  374. setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId;
  375. ATRewardedVideoJSSDK_1.default.loadRewardedVideo(ATAndroidJS2_1.default.getPlacementId(), setting);
  376. }
  377. };
  378. UIHomePage.prototype._canGetBonus = function () {
  379. return (new Date().toDateString() != CocosZ_1.cocosz.dataMgr.LastDailyBonusTime);
  380. };
  381. UIHomePage.prototype._aniEffect = function (type) {
  382. switch (type) {
  383. case 1: {
  384. if (this._aniUpgrade) {
  385. this._aniUpgrade.node.active = true;
  386. this._aniUpgrade.setAnimation(0, "animation", false);
  387. CocosZ_1.cocosz.audioMgr.playEffect("ui_upgrade");
  388. }
  389. break;
  390. }
  391. case 2: {
  392. if (this._aniCaidai) {
  393. this._aniCaidai.node.active = true;
  394. this._aniCaidai.setAnimation(0, "animation", false);
  395. CocosZ_1.cocosz.audioMgr.playEffect("ui_caidai");
  396. }
  397. break;
  398. }
  399. }
  400. };
  401. UIHomePage.prototype.onOpen = function () {
  402. var _this = this;
  403. cc.log("home open !");
  404. // 上报游戏首页
  405. Utils_1.utils.umaEvent("gamehome");
  406. Utils_1.utils.SendEvent("页面-首页");
  407. this._updatePlayer();
  408. this._updateWeapon();
  409. this._updateWeaponFrame();
  410. // 广告
  411. Utils_1.utils.showYzRealNameAuthPanel();
  412. Utils_1.utils.showPrivacyPanel({ group: "default", parent: this._page });
  413. Utils_1.utils.registerServerInitEvent(function () {
  414. // 验证服务器配置为自动弹签到,并且当前可以签到
  415. if (Utils_1.utils.checkAutoSign() && _this._canGetBonus()) {
  416. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UISignPanel);
  417. }
  418. _this.showAd();
  419. }, this);
  420. cc.game.on(Constant_1.default.E_GAME_LOGIC, this._onGameMessageHandler, this);
  421. };
  422. UIHomePage.prototype.onClose = function () {
  423. cc.game.targetOff(this);
  424. Utils_1.utils.hideVivoGamePortalWidget();
  425. Utils_1.utils.hideOppoGameDrawerAdWidget();
  426. Utils_1.utils.adManager.hideBlockAd();
  427. Utils_1.utils.adManager.hideNativeTryGameWidget();
  428. Utils_1.utils.adManager.HideSingleNativeAd();
  429. if (PlatUtils_1.default.IsWechat) {
  430. Utils_1.utils.adManager.hideCustomAd({ location: 1 });
  431. Utils_1.utils.adManager.hideCustomAd({ location: 2 });
  432. }
  433. else if (PlatUtils_1.default.IsVIVO) {
  434. Utils_1.utils.adManager.hideCustomAd({ location: YZ_Constant_1.BannerLocation.Home });
  435. }
  436. };
  437. UIHomePage.prototype.showAd = function () {
  438. if (CocosZ_1.cocosz.isShowAd) {
  439. if (PlatUtils_1.default.IsWechat) {
  440. Utils_1.utils.adManager.HideBanner(YZ_Constant_1.BannerLocation.Home);
  441. }
  442. else {
  443. Utils_1.utils.adManager.ShowBanner(YZ_Constant_1.BannerLocation.Home, { width: 0.1, bottom: 1 });
  444. }
  445. // 原生广告
  446. if (PlatUtils_1.default.IsWechat) {
  447. Utils_1.utils.adManager.showCustomAd({ location: 1 });
  448. Utils_1.utils.adManager.showCustomAd({ location: 2 });
  449. }
  450. else if (PlatUtils_1.default.IsVIVO) {
  451. Utils_1.utils.adManager.showCustomAd({ location: YZ_Constant_1.BannerLocation.Home });
  452. }
  453. Utils_1.utils.adManager.showNativeTryGameWidget({ right: 50, top: 800, scale: 1, parent: this._page });
  454. Utils_1.utils.adManager.ShowSingleNativeAd({});
  455. Utils_1.utils.adManager.showBlockAd({ right: 50, top: 500, showNum: 1 });
  456. Utils_1.utils.showMoreGamesWidget({ group: 'default', scale: 1, bottom: 300, left: 50, parent: this._page, location: YZ_Constant_1.BannerLocation.Home });
  457. Utils_1.utils.showTryGamesWidget({ group: 'default', scale: 1, bottom: 350, right: 50, parent: this._page, location: YZ_Constant_1.BannerLocation.Home });
  458. Utils_1.utils.showVivoGamePortalWidget({ top: 500, location: YZ_Constant_1.BannerLocation.Home });
  459. Utils_1.utils.showOppoGameDrawerAdWidget({ top: 500, location: YZ_Constant_1.BannerLocation.Home });
  460. Utils_1.utils.showCreateShortcutWidget(null, { group: 'default', scale: 1, left: 0, top: 500, parent: this._page });
  461. Utils_1.utils.showPrivacyWidget({ group: "default", top: 0, left: 0, parent: this._page.getChildByName("PrivacyWidget"), color: cc.Color.BLACK });
  462. }
  463. };
  464. UIHomePage.prototype._onGameMessageHandler = function (event) {
  465. switch (event.type) {
  466. case Constant_1.default.E_Fly_Coin: {
  467. this._flyCoins(event.iconName, event.frameNodeName);
  468. break;
  469. }
  470. case Constant_1.default.E_CJ_SKIN: {
  471. this._showSkinId = CocosZ_1.cocosz.dataMgr.CurSkinId;
  472. this._updatePlayer();
  473. break;
  474. }
  475. case Constant_1.default.E_CJ_Weapon: {
  476. this._showWeaponId = CocosZ_1.cocosz.dataMgr.curWeapon;
  477. this._updateWeapon();
  478. this._updateWeaponFrame();
  479. break;
  480. }
  481. }
  482. };
  483. UIHomePage.prototype._onBtnClickHandler = function (event) {
  484. return __awaiter(this, void 0, void 0, function () {
  485. var skinInfo, skinInfo, showSkinInfo, showSKinKey, showWeaponInfo, showWeaponKey, t;
  486. var _this = this;
  487. return __generator(this, function (_a) {
  488. switch (_a.label) {
  489. case 0: return [4 /*yield*/, CocosZ_1.cocosz.audioMgr.playBtnEffect().catch()];
  490. case 1:
  491. _a.sent();
  492. switch (event.target.name) {
  493. case "BtnGameStart": {
  494. console.log('zh:BtnGameStart');
  495. CocosZ_1.cocosz.gameMode = 6;
  496. CocosZ_1.cocosz.gameMgr.gameStart(CocosZ_1.cocosz.getLevelId());
  497. break;
  498. }
  499. case "BtnLeft": {
  500. console.log('zh:BtnLeft');
  501. this._showSkinId--;
  502. if (this._showSkinId < 0)
  503. this._showSkinId = 11;
  504. this._updatePlayer();
  505. skinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  506. if (skinInfo && skinInfo.State == 1) {
  507. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  508. }
  509. break;
  510. }
  511. case "BtnRight": {
  512. console.log('zh:BtnRight');
  513. this._showSkinId++;
  514. if (this._showSkinId > 11)
  515. this._showSkinId = 0;
  516. this._updatePlayer();
  517. skinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  518. if (skinInfo && skinInfo.State == 1) {
  519. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  520. }
  521. break;
  522. }
  523. case "BtnSkin": {
  524. console.log('zh:BtnSkin');
  525. showSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  526. showSKinKey = "" + (this._showSkinId + 1);
  527. if (showSkinInfo.State == 0) {
  528. // 金币
  529. if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Gold) {
  530. if (CocosZ_1.cocosz.dataMgr.CoinCount >= gameDate_1.default.SkinMess[showSKinKey].price) {
  531. CocosZ_1.cocosz.dataMgr.CoinCount -= gameDate_1.default.SkinMess[showSKinKey].price;
  532. Msg_1.default.Show(i18n.t("msg.gxhdxjs")); //恭喜获得新角色
  533. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  534. this._updatePlayer();
  535. this._aniEffect(2);
  536. }
  537. else {
  538. this.showCoinPanel(false);
  539. }
  540. }
  541. // 钻石
  542. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Diamond) {
  543. if (CocosZ_1.cocosz.dataMgr.DiamondCount >= gameDate_1.default.SkinMess[showSKinKey].price) {
  544. CocosZ_1.cocosz.dataMgr.DiamondCount -= gameDate_1.default.SkinMess[showSKinKey].price;
  545. Msg_1.default.Show(i18n.t("msg.gxhdxjs")); //恭喜获得新角色
  546. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  547. this._updatePlayer();
  548. this._aniEffect(2);
  549. }
  550. else {
  551. this.showCoinPanel(true);
  552. }
  553. }
  554. // 转盘奖励
  555. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  556. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UITurntablePanel);
  557. }
  558. }
  559. // 升级
  560. else if (showSkinInfo.Level < 6) {
  561. if (CocosZ_1.cocosz.dataMgr.CoinCount >= Constant_1.default.skinLevelPriceArr[showSkinInfo.Level]) {
  562. CocosZ_1.cocosz.dataMgr.CoinCount -= Constant_1.default.skinLevelPriceArr[showSkinInfo.Level];
  563. showSkinInfo.Level++;
  564. CocosZ_1.cocosz.dataMgr.setSkinInfo(showSkinInfo.Id, showSkinInfo);
  565. this._updatePlayer();
  566. this._aniEffect(1);
  567. }
  568. else {
  569. this.showCoinPanel(false);
  570. }
  571. }
  572. break;
  573. }
  574. case "BtnWeapon": {
  575. console.log('zh:BtnWeapon');
  576. showWeaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(this._showWeaponId);
  577. showWeaponKey = weapon_1.default.WeaponName[this._showWeaponId];
  578. if (showWeaponInfo.State == 0) {
  579. // 金币
  580. if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Gold) {
  581. if (CocosZ_1.cocosz.dataMgr.CoinCount >= gameDate_1.default.Weapon[showWeaponKey].price) {
  582. CocosZ_1.cocosz.dataMgr.CoinCount -= gameDate_1.default.Weapon[showWeaponKey].price;
  583. Msg_1.default.Show(i18n.t("msg.gxhdxwq"));
  584. CocosZ_1.cocosz.dataMgr.curWeapon = this._showWeaponId;
  585. this._updateWeapon();
  586. this._updateWeaponFrame();
  587. this._aniEffect(2);
  588. }
  589. else {
  590. this.showCoinPanel(false);
  591. }
  592. }
  593. // 钻石
  594. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Diamond) {
  595. if (CocosZ_1.cocosz.dataMgr.DiamondCount >= gameDate_1.default.Weapon[showWeaponKey].price) {
  596. CocosZ_1.cocosz.dataMgr.DiamondCount -= gameDate_1.default.Weapon[showWeaponKey].price;
  597. Msg_1.default.Show(i18n.t("msg.gxhdxwq"));
  598. CocosZ_1.cocosz.dataMgr.curWeapon = this._showWeaponId;
  599. this._updateWeapon();
  600. this._updateWeaponFrame();
  601. this._aniEffect(2);
  602. }
  603. else {
  604. this.showCoinPanel(true);
  605. }
  606. }
  607. // 转盘奖励
  608. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  609. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UITurntablePanel);
  610. }
  611. }
  612. // 升级
  613. else if (showWeaponInfo.Level < 3) {
  614. if (CocosZ_1.cocosz.dataMgr.CoinCount >= Constant_1.default.weaponLevelPriceArr[showWeaponInfo.Level]) {
  615. CocosZ_1.cocosz.dataMgr.CoinCount -= Constant_1.default.weaponLevelPriceArr[showWeaponInfo.Level];
  616. showWeaponInfo.Level++;
  617. CocosZ_1.cocosz.dataMgr.setGunInfo(showWeaponInfo.Id, showWeaponInfo);
  618. this._updateWeapon();
  619. this._updateWeaponFrame();
  620. this._aniEffect(1);
  621. }
  622. else {
  623. this.showCoinPanel(false);
  624. }
  625. }
  626. break;
  627. }
  628. case "BtnSkinAd": {
  629. console.log('zh:BtnSkinAd');
  630. Utils_1.utils.SendEvent("视频-皮肤解锁-播放");
  631. // 注册方法 , this.ClickClose.bind(this));
  632. //GlobalManager.getInstance().registerMethod('event_wuqi_unlook', this.event_wuqi_unlook.bind(this));
  633. cc.sys.localStorage.setItem(this.adKey, 'event_pifu_unlook'); //
  634. if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
  635. console.log('zh:AD ready for idx2');
  636. ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
  637. }
  638. else {
  639. console.log('zh:AD not ready for idx2');
  640. this.event_pifu_unlook();
  641. this.initAdForPage();
  642. }
  643. if (2 > 1) {
  644. return [2 /*return*/]; //下面是原始的代码
  645. }
  646. CocosZ_1.cocosz.watchAD(function () {
  647. // 视频成功
  648. Utils_1.utils.SendEvent("视频-皮肤解锁-成功");
  649. var showSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(_this._showSkinId);
  650. var showSkinKey = "" + (_this._showSkinId + 1);
  651. if (!!showSkinInfo && !!gameDate_1.default.SkinMess[showSkinKey] && !!gameDate_1.default.SkinMess[showSkinKey].videoCount) {
  652. showSkinInfo.VideoCount++;
  653. CocosZ_1.cocosz.dataMgr.setSkinInfo(_this._showSkinId, showSkinInfo);
  654. if (showSkinInfo.VideoCount >= gameDate_1.default.SkinMess[showSkinKey].videoCount) {
  655. Msg_1.default.Show(i18n.t("msg.gxhdxjs")); //恭喜获得新角色
  656. CocosZ_1.cocosz.dataMgr.CurSkinId = _this._showSkinId;
  657. _this._aniEffect(2);
  658. }
  659. else {
  660. Msg_1.default.Show(i18n.t("msg.jswc") + showSkinInfo.VideoCount + "/" + gameDate_1.default.SkinMess[showSkinKey].videoCount);
  661. }
  662. // 更新玩家信息
  663. _this._updatePlayer();
  664. }
  665. }, function () {
  666. // 视频失败
  667. Utils_1.utils.SendEvent("视频-皮肤解锁-失败");
  668. });
  669. break;
  670. }
  671. case "BtnWeaponAd": {
  672. console.log('zh:BtnWeaponAd');
  673. Utils_1.utils.SendEvent("视频-武器解锁-播放");
  674. // 注册方法 , this.ClickClose.bind(this));
  675. //GlobalManager.getInstance().registerMethod('event_wuqi_unlook', this.event_wuqi_unlook.bind(this));
  676. cc.sys.localStorage.setItem(this.adKey, 'event_wuqi_unlook'); //
  677. if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
  678. console.log('zh:AD ready for idx2');
  679. ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
  680. }
  681. else {
  682. console.log('zh:AD not ready for idx2');
  683. this.event_wuqi_unlook();
  684. this.initAdForPage();
  685. }
  686. if (2 > 1) {
  687. return [2 /*return*/]; //下面是原始的代码
  688. }
  689. CocosZ_1.cocosz.watchAD(function () {
  690. // 视频成功
  691. Utils_1.utils.SendEvent("视频-武器解锁-成功");
  692. _this.event_wuqi_unlook();
  693. }, function () {
  694. // 视频失败
  695. Utils_1.utils.SendEvent("视频-武器解锁-失败");
  696. });
  697. break;
  698. }
  699. case "BtnCJ": {
  700. console.log('zh:BtnCJ');
  701. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UITurntablePanel);
  702. break;
  703. }
  704. case "BtnSign": {
  705. console.log('zh:BtnSign');
  706. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UISignPanel);
  707. break;
  708. }
  709. case "BtnTime": {
  710. console.log('zh:BtnTime');
  711. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UITimePanel);
  712. break;
  713. }
  714. case "BtnSet": {
  715. console.log('zh:BtnSet');
  716. this._icon_set.stopAllActions();
  717. this._frame_set.stopAllActions();
  718. t = (this._frame_set.scaleY ? this._frame_set.scaleY : 1) / 2;
  719. cc.tween(this._icon_set)
  720. .to(t, { angle: (this._frame_set.scaleY ? 90 : -90) }, { easing: "sineInOut" })
  721. .start();
  722. cc.tween(this._frame_set)
  723. .to(t, { scaleY: this._frame_set.scaleY ? 0 : 1 }, { easing: "sineInOut" })
  724. .start();
  725. break;
  726. }
  727. case "BtnAudio": {
  728. console.log('zh:BtnAudio');
  729. CocosZ_1.cocosz.dataMgr.AudioOn = !CocosZ_1.cocosz.dataMgr.AudioOn;
  730. this._updateAudioBtn();
  731. break;
  732. }
  733. case "BtnShake": {
  734. console.log('zh:BtnShake');
  735. CocosZ_1.cocosz.dataMgr.ShakeOn = !CocosZ_1.cocosz.dataMgr.ShakeOn;
  736. this._updatShakeBtn();
  737. break;
  738. }
  739. }
  740. return [2 /*return*/];
  741. }
  742. });
  743. });
  744. };
  745. //武器结算
  746. UIHomePage.prototype.event_wuqi_unlook = function () {
  747. console.log('zh:event_wuqi_unlook 被触发');
  748. var showWeaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(this._showWeaponId);
  749. var showWeaponKey = weapon_1.default.WeaponName[this._showWeaponId];
  750. if (!!showWeaponInfo && !!gameDate_1.default.Weapon[showWeaponKey] && !!gameDate_1.default.Weapon[showWeaponKey].videoCount) {
  751. showWeaponInfo.VideoCount++;
  752. CocosZ_1.cocosz.dataMgr.setGunInfo(this._showWeaponId, showWeaponInfo);
  753. if (showWeaponInfo.VideoCount >= gameDate_1.default.Weapon[showWeaponKey].videoCount) {
  754. Msg_1.default.Show(i18n.t("msg.gxhdxwq"));
  755. CocosZ_1.cocosz.dataMgr.curWeapon = this._showWeaponId;
  756. this._aniEffect(2);
  757. }
  758. else {
  759. Msg_1.default.Show(i18n.t("msg.jswc") + showWeaponInfo.VideoCount + "/" + gameDate_1.default.Weapon[showWeaponKey].videoCount);
  760. }
  761. // 更新武器信息
  762. this._updateWeapon();
  763. this._updateWeaponFrame();
  764. }
  765. };
  766. //皮肤解锁
  767. UIHomePage.prototype.event_pifu_unlook = function () {
  768. console.log('zh:event_pifu_unlook 被触发');
  769. // 视频成功
  770. Utils_1.utils.SendEvent("视频-皮肤解锁-成功");
  771. var showSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  772. var showSkinKey = "" + (this._showSkinId + 1);
  773. if (!!showSkinInfo && !!gameDate_1.default.SkinMess[showSkinKey] && !!gameDate_1.default.SkinMess[showSkinKey].videoCount) {
  774. showSkinInfo.VideoCount++;
  775. CocosZ_1.cocosz.dataMgr.setSkinInfo(this._showSkinId, showSkinInfo);
  776. if (showSkinInfo.VideoCount >= gameDate_1.default.SkinMess[showSkinKey].videoCount) {
  777. Msg_1.default.Show(i18n.t("msg.gxhdxjs")); //恭喜获得新角色
  778. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  779. this._aniEffect(2);
  780. }
  781. else {
  782. Msg_1.default.Show(i18n.t("msg.jswc") + showSkinInfo.VideoCount + "/" + gameDate_1.default.SkinMess[showSkinKey].videoCount);
  783. }
  784. // 更新玩家信息
  785. this._updatePlayer();
  786. }
  787. };
  788. UIHomePage.prototype._updatePlayer = function () {
  789. var _this = this;
  790. cc.log("showSkinID: ", this._showSkinId);
  791. this._playerAni.setSkinById(this._showSkinId);
  792. // 属性
  793. // 角色名字
  794. this._skinInfo_name.spriteFrame = CocosZ_1.cocosz.resMgr.getRes("p_" + (this._showSkinId + 1), cc.SpriteFrame);
  795. // 角色属性
  796. var curSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(CocosZ_1.cocosz.dataMgr.CurSkinId);
  797. var showSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  798. var curLevel = curSkinInfo.Level;
  799. var showLevel = showSkinInfo.Level;
  800. var curSkinKey = "" + (CocosZ_1.cocosz.dataMgr.CurSkinId + 1);
  801. var showSKinKey = "" + (this._showSkinId + 1);
  802. // 血滴
  803. this._skinInfo_xuedi.children.forEach(function (v, i) {
  804. if (i < gameDate_1.default.SkinMess[showSKinKey].xuedi) {
  805. _this._skinInfo_xuedi.children[i].opacity = 255;
  806. }
  807. else {
  808. _this._skinInfo_xuedi.children[i].opacity = 0;
  809. }
  810. });
  811. // 攻击力
  812. this._skinInfo_value1.string = "" + gameDate_1.default.SkinMess[showSKinKey].atk[showLevel];
  813. // 移动
  814. this._skinInfo_value2.string = "" + gameDate_1.default.SkinMess[showSKinKey].speed[showLevel];
  815. // 攻击变化
  816. var num1 = gameDate_1.default.SkinMess[showSKinKey].atk[showLevel] - gameDate_1.default.SkinMess[curSkinKey].atk[curLevel];
  817. if (num1 < 0) {
  818. this._skinInfo_change1.string = "" + num1;
  819. this._skinInfo_change1.node.children[0].active = false;
  820. this._skinInfo_change1.node.children[1].active = true;
  821. this._skinInfo_change1.node.color = cc.Color.RED;
  822. this._skinInfo_change1.node.opacity = 255;
  823. }
  824. else if (num1 == 0) {
  825. this._skinInfo_change1.node.opacity = 0;
  826. }
  827. else {
  828. this._skinInfo_change1.string = "+" + num1;
  829. this._skinInfo_change1.node.children[0].active = true;
  830. this._skinInfo_change1.node.children[1].active = false;
  831. this._skinInfo_change1.node.color = cc.Color.GREEN;
  832. this._skinInfo_change1.node.opacity = 255;
  833. }
  834. // 移动变化
  835. var num2 = gameDate_1.default.SkinMess[showSKinKey].speed[showLevel] - gameDate_1.default.SkinMess[curSkinKey].speed[curLevel];
  836. if (num2 < 0) {
  837. this._skinInfo_change2.string = "" + num2;
  838. this._skinInfo_change2.node.children[0].active = false;
  839. this._skinInfo_change2.node.children[1].active = true;
  840. this._skinInfo_change2.node.color = cc.Color.RED;
  841. this._skinInfo_change2.node.opacity = 255;
  842. }
  843. else if (num2 == 0) {
  844. this._skinInfo_change2.node.opacity = 0;
  845. }
  846. else {
  847. this._skinInfo_change2.string = "+" + num2;
  848. this._skinInfo_change2.node.children[0].active = true;
  849. this._skinInfo_change2.node.children[1].active = false;
  850. this._skinInfo_change2.node.color = cc.Color.GREEN;
  851. this._skinInfo_change2.node.opacity = 255;
  852. }
  853. // 等级
  854. this._skinInfo_level_pro.progress = showLevel / 6;
  855. // 按钮变化
  856. if (showSkinInfo) {
  857. this._btnSkin.children.forEach(function (v) { return v.active = false; });
  858. var btn_huang = this._btnSkin.getChildByName("btn_huang");
  859. var btn_huang_small = this._btnSkin.getChildByName("btn_huang_small");
  860. var btn_hong = this._btnSkin.getChildByName("btn_hong");
  861. var txt_buy = this._btnSkin.getChildByName("txt_buy");
  862. var txt_sjwc = this._btnSkin.getChildByName("txt_sjwc");
  863. var txt_upgrade = this._btnSkin.getChildByName("txt_upgrade");
  864. var txt_zpjl = this._btnSkin.getChildByName("txt_zpjl");
  865. var icon_jinbi = this._btnSkin.getChildByName("icon_jinbi");
  866. var icon_zuanshi = this._btnSkin.getChildByName("icon_zuanshi");
  867. var price = this._btnSkin.getChildByName("price");
  868. // 购买
  869. if (showSkinInfo.State == 0) {
  870. if (gameDate_1.default.SkinMess[showSKinKey] && gameDate_1.default.SkinMess[showSKinKey].videoCount) {
  871. this._btnSkin.x = -350;
  872. this._btnSkin.width = 169;
  873. if (btn_huang_small)
  874. btn_huang_small.active = true;
  875. // 金币
  876. if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Gold) {
  877. if (icon_jinbi) {
  878. icon_jinbi.active = true;
  879. icon_jinbi.x = -50;
  880. }
  881. if (price) {
  882. price.active = true;
  883. price.x = -10;
  884. price.getComponent(cc.Label).string = '' + gameDate_1.default.SkinMess[showSKinKey].price;
  885. }
  886. }
  887. // 钻石
  888. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Diamond) {
  889. if (icon_zuanshi) {
  890. icon_zuanshi.active = true;
  891. icon_zuanshi.x = -50;
  892. }
  893. if (price) {
  894. price.active = true;
  895. price.x = -10;
  896. price.getComponent(cc.Label).string = '' + gameDate_1.default.SkinMess[showSKinKey].price;
  897. }
  898. }
  899. // 转盘奖励
  900. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  901. if (txt_zpjl)
  902. txt_zpjl.active = true;
  903. }
  904. // 视频解锁
  905. this._btnSkinAd.active = true;
  906. var videoCount = this._btnSkinAd.getChildByName("videoCount");
  907. if (videoCount)
  908. videoCount.getComponent(cc.Label).string = showSkinInfo.VideoCount + "/" + gameDate_1.default.SkinMess[showSKinKey].videoCount;
  909. }
  910. else {
  911. this._btnSkinAd.active = false;
  912. this._btnSkin.x = -250;
  913. this._btnSkin.width = 252;
  914. if (btn_huang)
  915. btn_huang.active = true;
  916. // 金币
  917. if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Gold) {
  918. if (txt_buy)
  919. txt_buy.active = true;
  920. if (icon_jinbi) {
  921. icon_jinbi.active = true;
  922. icon_jinbi.x = 0;
  923. }
  924. if (price) {
  925. price.active = true;
  926. price.x = 30;
  927. price.getComponent(cc.Label).string = '' + gameDate_1.default.SkinMess[showSKinKey].price;
  928. }
  929. }
  930. // 钻石
  931. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Diamond) {
  932. if (txt_buy)
  933. txt_buy.active = true;
  934. if (icon_zuanshi) {
  935. icon_zuanshi.active = true;
  936. icon_zuanshi.x = 0;
  937. }
  938. if (price) {
  939. price.active = true;
  940. price.x = 30;
  941. price.getComponent(cc.Label).string = '' + gameDate_1.default.SkinMess[showSKinKey].price;
  942. }
  943. }
  944. // 转盘奖励
  945. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  946. if (txt_zpjl)
  947. txt_zpjl.active = true;
  948. }
  949. }
  950. }
  951. // 升级
  952. else if (showSkinInfo.Level < 6) {
  953. this._btnSkinAd.active = false;
  954. this._btnSkin.x = -250;
  955. this._btnSkin.width = 252;
  956. if (btn_hong)
  957. btn_hong.active = true;
  958. if (txt_upgrade)
  959. txt_upgrade.active = true;
  960. if (icon_jinbi) {
  961. icon_jinbi.active = true;
  962. icon_jinbi.x = 0;
  963. }
  964. if (price) {
  965. price.active = true;
  966. price.x = 30;
  967. price.getComponent(cc.Label).string = '' + Constant_1.default.skinLevelPriceArr[showSkinInfo.Level];
  968. }
  969. }
  970. // 最大等级
  971. else {
  972. this._btnSkinAd.active = false;
  973. this._btnSkin.x = -250;
  974. this._btnSkin.width = 252;
  975. if (txt_sjwc)
  976. txt_sjwc.active = true;
  977. }
  978. }
  979. };
  980. UIHomePage.prototype._updateWeapon = function () {
  981. cc.log("showWeaponID: ", this._showWeaponId);
  982. this._playerAni.setWeaponById(this._showWeaponId);
  983. // 武器名字
  984. this._weaponInfo_name.spriteFrame = CocosZ_1.cocosz.resMgr.getRes("w_" + (this._showWeaponId + 1), cc.SpriteFrame);
  985. // 武器属性
  986. var curWeaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(CocosZ_1.cocosz.dataMgr.CurRange);
  987. var showWeaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(this._showWeaponId);
  988. var curLevel = curWeaponInfo.Level;
  989. var showLevel = showWeaponInfo.Level;
  990. var curWeaponKey = weapon_1.default.WeaponName[CocosZ_1.cocosz.dataMgr.CurRange];
  991. var showWeaponKey = weapon_1.default.WeaponName[this._showWeaponId];
  992. // 攻击力
  993. this._weaponInfo_value0.string = "" + gameDate_1.default.Weapon[showWeaponKey].atk[showLevel];
  994. // 攻击频率
  995. this._weaponInfo_value1.string = (1 / gameDate_1.default.Weapon[showWeaponKey].atkSpeed[showLevel]).toFixed(1);
  996. // 攻击范围
  997. this._weaponInfo_value2.string = "" + gameDate_1.default.Weapon[showWeaponKey].atkRange;
  998. // 弹药量
  999. this._weaponInfo_value3.string = "" + gameDate_1.default.Weapon[showWeaponKey].bulletTotal[showLevel];
  1000. // 变化
  1001. var num0 = gameDate_1.default.Weapon[showWeaponKey].atk[showLevel] - gameDate_1.default.Weapon[curWeaponKey].atk[curLevel];
  1002. var num1 = 1 / gameDate_1.default.Weapon[showWeaponKey].atkSpeed[showLevel] - 1 / gameDate_1.default.Weapon[curWeaponKey].atkSpeed[curLevel];
  1003. var num2 = gameDate_1.default.Weapon[showWeaponKey].atkRange - gameDate_1.default.Weapon[curWeaponKey].atkRange;
  1004. var num3 = gameDate_1.default.Weapon[showWeaponKey].bulletTotal[showLevel] - gameDate_1.default.Weapon[curWeaponKey].bulletTotal[curLevel];
  1005. // 攻击力变化
  1006. if (num0 < 0) {
  1007. this._weaponInfo_change0.string = "" + num0;
  1008. this._weaponInfo_change0.node.children[0].active = false;
  1009. this._weaponInfo_change0.node.children[1].active = true;
  1010. this._weaponInfo_change0.node.color = cc.Color.RED;
  1011. this._weaponInfo_change0.node.opacity = 255;
  1012. }
  1013. else if (num0 == 0) {
  1014. this._weaponInfo_change0.node.opacity = 0;
  1015. }
  1016. else {
  1017. this._weaponInfo_change0.string = "+" + num0;
  1018. this._weaponInfo_change0.node.children[0].active = true;
  1019. this._weaponInfo_change0.node.children[1].active = false;
  1020. this._weaponInfo_change0.node.color = cc.Color.GREEN;
  1021. this._weaponInfo_change0.node.opacity = 255;
  1022. }
  1023. // 攻击频率变化
  1024. if (num1 < 0) {
  1025. this._weaponInfo_change1.string = "" + num1;
  1026. this._weaponInfo_change1.node.children[0].active = false;
  1027. this._weaponInfo_change1.node.children[1].active = true;
  1028. this._weaponInfo_change1.node.color = cc.Color.RED;
  1029. this._weaponInfo_change1.node.opacity = 255;
  1030. }
  1031. else if (num1 == 0) {
  1032. this._weaponInfo_change1.node.opacity = 0;
  1033. }
  1034. else {
  1035. this._weaponInfo_change1.string = "+" + num1;
  1036. this._weaponInfo_change1.node.children[0].active = true;
  1037. this._weaponInfo_change1.node.children[1].active = false;
  1038. this._weaponInfo_change1.node.color = cc.Color.GREEN;
  1039. this._weaponInfo_change1.node.opacity = 255;
  1040. }
  1041. // 攻击范围变化
  1042. if (num2 < 0) {
  1043. this._weaponInfo_change2.string = "" + num2;
  1044. this._weaponInfo_change2.node.children[0].active = false;
  1045. this._weaponInfo_change2.node.children[1].active = true;
  1046. this._weaponInfo_change2.node.color = cc.Color.RED;
  1047. this._weaponInfo_change2.node.opacity = 255;
  1048. }
  1049. else if (num2 == 0) {
  1050. this._weaponInfo_change2.node.opacity = 0;
  1051. }
  1052. else {
  1053. this._weaponInfo_change2.string = "+" + num2;
  1054. this._weaponInfo_change2.node.children[0].active = true;
  1055. this._weaponInfo_change2.node.children[1].active = false;
  1056. this._weaponInfo_change2.node.color = cc.Color.GREEN;
  1057. this._weaponInfo_change2.node.opacity = 255;
  1058. }
  1059. // 弹药量变化
  1060. if (num3 < 0) {
  1061. this._weaponInfo_change3.string = "" + num3;
  1062. this._weaponInfo_change3.node.children[0].active = false;
  1063. this._weaponInfo_change3.node.children[1].active = true;
  1064. this._weaponInfo_change3.node.color = cc.Color.RED;
  1065. this._weaponInfo_change3.node.opacity = 255;
  1066. }
  1067. else if (num3 == 0) {
  1068. this._weaponInfo_change3.node.opacity = 0;
  1069. }
  1070. else {
  1071. this._weaponInfo_change3.string = "+" + num3;
  1072. this._weaponInfo_change3.node.children[0].active = true;
  1073. this._weaponInfo_change3.node.children[1].active = false;
  1074. this._weaponInfo_change3.node.color = cc.Color.GREEN;
  1075. this._weaponInfo_change3.node.opacity = 255;
  1076. }
  1077. // 等级
  1078. this._weaponInfo_level_pro.progress = showLevel / 3;
  1079. // 按钮变化
  1080. if (showWeaponInfo) {
  1081. this._btnWeapon.children.forEach(function (v) { return v.active = false; });
  1082. var btn_huang = this._btnWeapon.getChildByName("btn_huang");
  1083. var btn_huang_small = this._btnWeapon.getChildByName("btn_huang_small");
  1084. var btn_hong = this._btnWeapon.getChildByName("btn_hong");
  1085. var txt_buy = this._btnWeapon.getChildByName("txt_buy");
  1086. var txt_sjwc = this._btnWeapon.getChildByName("txt_sjwc");
  1087. var txt_upgrade = this._btnWeapon.getChildByName("txt_upgrade");
  1088. var txt_zpjl = this._btnWeapon.getChildByName("txt_zpjl");
  1089. var icon_jinbi = this._btnWeapon.getChildByName("icon_jinbi");
  1090. var icon_zuanshi = this._btnWeapon.getChildByName("icon_zuanshi");
  1091. var price = this._btnWeapon.getChildByName("price");
  1092. if (showWeaponInfo.State == 0) {
  1093. // 视频解锁
  1094. if (gameDate_1.default.Weapon[showWeaponKey] && gameDate_1.default.Weapon[showWeaponKey].videoCount) {
  1095. this._btnWeapon.x = 150;
  1096. this._btnWeapon.width = 169;
  1097. if (btn_huang_small)
  1098. btn_huang_small.active = true;
  1099. // 金币
  1100. if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Gold) {
  1101. if (icon_jinbi) {
  1102. icon_jinbi.active = true;
  1103. icon_jinbi.x = -50;
  1104. }
  1105. if (price) {
  1106. price.active = true;
  1107. price.x = -10;
  1108. price.getComponent(cc.Label).string = '' + gameDate_1.default.Weapon[showWeaponKey].price;
  1109. }
  1110. }
  1111. // 钻石
  1112. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Diamond) {
  1113. if (icon_zuanshi) {
  1114. icon_zuanshi.active = true;
  1115. icon_zuanshi.x = -50;
  1116. }
  1117. if (price) {
  1118. price.active = true;
  1119. price.x = -10;
  1120. price.getComponent(cc.Label).string = '' + gameDate_1.default.Weapon[showWeaponKey].price;
  1121. }
  1122. }
  1123. // 转盘奖励
  1124. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  1125. if (txt_zpjl)
  1126. txt_zpjl.active = true;
  1127. }
  1128. // 视频解锁
  1129. this._btnWeaponAd.active = true;
  1130. var videoCount = this._btnWeaponAd.getChildByName("videoCount");
  1131. if (videoCount)
  1132. videoCount.getComponent(cc.Label).string = showWeaponInfo.VideoCount + "/" + gameDate_1.default.Weapon[showWeaponKey].videoCount;
  1133. }
  1134. // 购买
  1135. else {
  1136. this._btnWeaponAd.active = false;
  1137. this._btnWeapon.x = 250;
  1138. this._btnWeapon.width = 252;
  1139. if (btn_huang)
  1140. btn_huang.active = true;
  1141. // 金币
  1142. if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Gold) {
  1143. if (txt_buy)
  1144. txt_buy.active = true;
  1145. if (icon_jinbi) {
  1146. icon_jinbi.active = true;
  1147. icon_jinbi.x = 0;
  1148. }
  1149. if (price) {
  1150. price.active = true;
  1151. price.x = 30;
  1152. price.getComponent(cc.Label).string = '' + gameDate_1.default.Weapon[showWeaponKey].price;
  1153. }
  1154. }
  1155. // 钻石
  1156. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Diamond) {
  1157. if (txt_buy)
  1158. txt_buy.active = true;
  1159. if (icon_zuanshi) {
  1160. icon_zuanshi.active = true;
  1161. icon_zuanshi.x = 0;
  1162. }
  1163. if (price) {
  1164. price.active = true;
  1165. price.x = 30;
  1166. price.getComponent(cc.Label).string = '' + gameDate_1.default.Weapon[showWeaponKey].price;
  1167. }
  1168. }
  1169. // 转盘奖励
  1170. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  1171. if (txt_zpjl)
  1172. txt_zpjl.active = true;
  1173. }
  1174. }
  1175. }
  1176. // 升级
  1177. else if (showWeaponInfo.Level < 3) {
  1178. this._btnWeaponAd.active = false;
  1179. this._btnWeapon.x = 250;
  1180. this._btnWeapon.width = 252;
  1181. if (btn_hong)
  1182. btn_hong.active = true;
  1183. if (txt_upgrade)
  1184. txt_upgrade.active = true;
  1185. if (icon_jinbi) {
  1186. icon_jinbi.active = true;
  1187. icon_jinbi.x = 0;
  1188. }
  1189. if (price) {
  1190. price.active = true;
  1191. price.x = 30;
  1192. price.getComponent(cc.Label).string = '' + Constant_1.default.weaponLevelPriceArr[showWeaponInfo.Level];
  1193. }
  1194. }
  1195. // 最大等级
  1196. else {
  1197. this._btnWeaponAd.active = false;
  1198. this._btnWeapon.x = 250;
  1199. this._btnWeapon.width = 252;
  1200. if (txt_sjwc)
  1201. txt_sjwc.active = true;
  1202. }
  1203. }
  1204. this._updateWeaponFrame();
  1205. };
  1206. UIHomePage.prototype._updateWeaponFrame = function () {
  1207. var gunInfos = CocosZ_1.cocosz.dataMgr.getItem(Constant_1.default.ST_GunInfo, "");
  1208. if (gunInfos) {
  1209. var gunInfoArr = JSON.parse(gunInfos);
  1210. if (gunInfoArr) {
  1211. for (var i = 0; i < this._weaponList.length; i++) {
  1212. var node = this._weaponList[i];
  1213. if (gameDate_1.default.Weapon[node.name] && gameDate_1.default.Weapon[node.name].id >= 0) {
  1214. var id = gameDate_1.default.Weapon[node.name].id;
  1215. if (gunInfoArr[id]) {
  1216. var state = gunInfoArr[id].State;
  1217. if (state >= 1) {
  1218. node.getChildByName("kuang_hui").active = false;
  1219. }
  1220. else {
  1221. node.getChildByName("kuang_hui").active = true;
  1222. }
  1223. // 选中
  1224. if (node.name == weapon_1.default.WeaponName[this._showWeaponId]) {
  1225. node.getChildByName("kuang_huang").active = true;
  1226. if (this._ani_arrow) {
  1227. if (gunInfoArr[id].State > 0 && gunInfoArr[id].Level < 3) {
  1228. this._ani_arrow.x = node.x + 30;
  1229. this._ani_arrow.active = true;
  1230. }
  1231. else {
  1232. this._ani_arrow.active = false;
  1233. }
  1234. }
  1235. }
  1236. else {
  1237. node.getChildByName("kuang_huang").active = false;
  1238. }
  1239. }
  1240. else {
  1241. node.getChildByName("kuang_hui").active = false;
  1242. node.getChildByName("kuang_huang").active = false;
  1243. }
  1244. }
  1245. else {
  1246. node.getChildByName("kuang_hui").active = false;
  1247. node.getChildByName("kuang_huang").active = false;
  1248. }
  1249. }
  1250. }
  1251. }
  1252. };
  1253. /** 金币/钻石弹窗 */
  1254. UIHomePage.prototype.showCoinPanel = function (isDiamond) {
  1255. var node = cc.instantiate(CocosZ_1.cocosz.resMgr.getRes("UIADPanel", cc.Prefab));
  1256. cc.find("Canvas").addChild(node);
  1257. if (isDiamond) {
  1258. node.getComponent("UIADPanel").setDiamond();
  1259. }
  1260. };
  1261. /** 飞金币/钻石 */
  1262. UIHomePage.prototype._flyCoins = function (iconName, frameNodeName) {
  1263. var posNode = cc.find(frameNodeName, this._page);
  1264. if (!posNode)
  1265. return;
  1266. var pos = posNode.parent.convertToWorldSpaceAR(posNode.position);
  1267. FlyCoin_1.default.Show(iconName, pos);
  1268. };
  1269. /** 更新音频开关 */
  1270. UIHomePage.prototype._updateAudioBtn = function (isPlay) {
  1271. if (isPlay === void 0) { isPlay = true; }
  1272. var offImg = cc.find("Background/off", this._btnAudio);
  1273. offImg.active = CocosZ_1.cocosz.dataMgr.AudioOn == false;
  1274. if (isPlay) {
  1275. //判断开关,重新播放背景音乐
  1276. if (CocosZ_1.cocosz.dataMgr.AudioOn) {
  1277. CocosZ_1.cocosz.audioMgr.playBgm();
  1278. }
  1279. else {
  1280. CocosZ_1.cocosz.audioMgr.stopAll();
  1281. }
  1282. }
  1283. };
  1284. /** 更新震动开关 */
  1285. UIHomePage.prototype._updatShakeBtn = function () {
  1286. var offImg = cc.find("Background/off", this._btnShake);
  1287. offImg.active = CocosZ_1.cocosz.dataMgr.ShakeOn == false;
  1288. };
  1289. UIHomePage = __decorate([
  1290. ccclass
  1291. ], UIHomePage);
  1292. return UIHomePage;
  1293. }(UIPage_1.default));
  1294. exports.default = UIHomePage;
  1295. cc._RF.pop();