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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  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 'xxxxxxx': //复活
  300. adKeyTemp = 'sendBtnEventForAdEventFuHuo_monthParams';
  301. var mpStr2 = cc.sys.localStorage.getItem(adKeyTemp);
  302. console.log('zh:#############复活 奖励', mpStr2);
  303. GlobalManager_1.default.getInstance().callMethod('sendBtnEventForAdEventFuHuo', mpStr2);
  304. break;
  305. default:
  306. console.log('zh:未知的道具类型AD==' + idx);
  307. }
  308. cc.sys.localStorage.setItem(this.adKey, '');
  309. cc.sys.localStorage.setItem(adKeyTemp, '');
  310. console.log('zh:清理adKey ');
  311. };
  312. UIHomePage.prototype.initAd = function () {
  313. if (cc.sys.os != cc.sys.OS_ANDROID) {
  314. return;
  315. }
  316. //let adKey = "zh_ad_type"
  317. cc.sys.localStorage.setItem(this.adKey, "");
  318. var placementId = ATAndroidJS2_1.default.getPlacementId();
  319. var deviceId = ATAndroidJS2_1.default.getDeviceUserId();
  320. var setting = {};
  321. setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId;
  322. ATRewardedVideoJSSDK_1.default.loadRewardedVideo(placementId, setting);
  323. //console.log('zh:bbb222')
  324. var customPlacementId = "";
  325. if (cc.sys.os === cc.sys.OS_IOS) {
  326. customPlacementId = placementId;
  327. }
  328. else if (cc.sys.os === cc.sys.OS_ANDROID) {
  329. customPlacementId = placementId;
  330. }
  331. // 初始化SDK
  332. // ATSDK.initSDK("h6752c78a49dc1", "aad31bcaf7f7ff45ba21a8bc87bd9318a");//正式的,发布提交go0gle play
  333. ATJSSDK_1.default.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83"); //测试专用,可以显示广告
  334. // ATSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是打砖块的已经上架的
  335. // ATSDK.initSDK("h6752c78a49dc1", "aad31bcaf7f7ff45ba21a8bc87bd9318a");//货柜1 正式的,发布提交go0gle play
  336. ATJSSDK_1.default.setLogDebug(true); //zh:diy
  337. var GDPRLevel = ATJSSDK_1.default.getGDPRLevel();
  338. // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。
  339. ATJSSDK_1.default.getUserLocation(function (userLocation) {
  340. //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗
  341. if (userLocation === ATJSSDK_1.default.kATUserLocationInEU) {
  342. if (ATJSSDK_1.default.getGDPRLevel() === ATJSSDK_1.default.UNKNOWN) {
  343. ATJSSDK_1.default.showGDPRAuth();
  344. }
  345. }
  346. });
  347. ATRewardedVideoJSSDK_1.default.setAdListener(this);
  348. if (cc.sys.os === cc.sys.OS_ANDROID) {
  349. setTimeout(function () {
  350. var allInfo = ATAndroidJS2_1.default.allInfo();
  351. ATJSSDK_1.default.printLog("zh:allInfo=" + allInfo);
  352. var key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
  353. var iv = "Jn0.aWsOu$y-Dbqb";
  354. var data = { data: AESUtil_1.default.AESencrypt(allInfo, key, iv) };
  355. ATJSSDK_1.default.printLog("zh:allInfo-jm=" + JSON.stringify(data));
  356. console.log('zh:ad_allInfo', data);
  357. ATAndroidJS2_1.default.makePostRequestWithXhr(JSON.stringify(data));
  358. }, 200);
  359. }
  360. };
  361. UIHomePage.prototype.initAdForPage = function () {
  362. if (cc.sys.os === cc.sys.OS_ANDROID) {
  363. var deviceId = ATAndroidJS2_1.default.getDeviceUserId();
  364. console.log("zh:checkstatus:", ATRewardedVideoJSSDK_1.default.checkAdStatus(ATAndroidJS2_1.default.getPlacementId()));
  365. var setting = {};
  366. setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId;
  367. ATRewardedVideoJSSDK_1.default.loadRewardedVideo(ATAndroidJS2_1.default.getPlacementId(), setting);
  368. }
  369. };
  370. UIHomePage.prototype._canGetBonus = function () {
  371. return (new Date().toDateString() != CocosZ_1.cocosz.dataMgr.LastDailyBonusTime);
  372. };
  373. UIHomePage.prototype._aniEffect = function (type) {
  374. switch (type) {
  375. case 1: {
  376. if (this._aniUpgrade) {
  377. this._aniUpgrade.node.active = true;
  378. this._aniUpgrade.setAnimation(0, "animation", false);
  379. CocosZ_1.cocosz.audioMgr.playEffect("ui_upgrade");
  380. }
  381. break;
  382. }
  383. case 2: {
  384. if (this._aniCaidai) {
  385. this._aniCaidai.node.active = true;
  386. this._aniCaidai.setAnimation(0, "animation", false);
  387. CocosZ_1.cocosz.audioMgr.playEffect("ui_caidai");
  388. }
  389. break;
  390. }
  391. }
  392. };
  393. UIHomePage.prototype.onOpen = function () {
  394. var _this = this;
  395. cc.log("home open !");
  396. // 上报游戏首页
  397. Utils_1.utils.umaEvent("gamehome");
  398. Utils_1.utils.SendEvent("页面-首页");
  399. this._updatePlayer();
  400. this._updateWeapon();
  401. this._updateWeaponFrame();
  402. // 广告
  403. Utils_1.utils.showYzRealNameAuthPanel();
  404. Utils_1.utils.showPrivacyPanel({ group: "default", parent: this._page });
  405. Utils_1.utils.registerServerInitEvent(function () {
  406. // 验证服务器配置为自动弹签到,并且当前可以签到
  407. if (Utils_1.utils.checkAutoSign() && _this._canGetBonus()) {
  408. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UISignPanel);
  409. }
  410. _this.showAd();
  411. }, this);
  412. cc.game.on(Constant_1.default.E_GAME_LOGIC, this._onGameMessageHandler, this);
  413. };
  414. UIHomePage.prototype.onClose = function () {
  415. cc.game.targetOff(this);
  416. Utils_1.utils.hideVivoGamePortalWidget();
  417. Utils_1.utils.hideOppoGameDrawerAdWidget();
  418. Utils_1.utils.adManager.hideBlockAd();
  419. Utils_1.utils.adManager.hideNativeTryGameWidget();
  420. Utils_1.utils.adManager.HideSingleNativeAd();
  421. if (PlatUtils_1.default.IsWechat) {
  422. Utils_1.utils.adManager.hideCustomAd({ location: 1 });
  423. Utils_1.utils.adManager.hideCustomAd({ location: 2 });
  424. }
  425. else if (PlatUtils_1.default.IsVIVO) {
  426. Utils_1.utils.adManager.hideCustomAd({ location: YZ_Constant_1.BannerLocation.Home });
  427. }
  428. };
  429. UIHomePage.prototype.showAd = function () {
  430. if (CocosZ_1.cocosz.isShowAd) {
  431. if (PlatUtils_1.default.IsWechat) {
  432. Utils_1.utils.adManager.HideBanner(YZ_Constant_1.BannerLocation.Home);
  433. }
  434. else {
  435. Utils_1.utils.adManager.ShowBanner(YZ_Constant_1.BannerLocation.Home, { width: 0.1, bottom: 1 });
  436. }
  437. // 原生广告
  438. if (PlatUtils_1.default.IsWechat) {
  439. Utils_1.utils.adManager.showCustomAd({ location: 1 });
  440. Utils_1.utils.adManager.showCustomAd({ location: 2 });
  441. }
  442. else if (PlatUtils_1.default.IsVIVO) {
  443. Utils_1.utils.adManager.showCustomAd({ location: YZ_Constant_1.BannerLocation.Home });
  444. }
  445. Utils_1.utils.adManager.showNativeTryGameWidget({ right: 50, top: 800, scale: 1, parent: this._page });
  446. Utils_1.utils.adManager.ShowSingleNativeAd({});
  447. Utils_1.utils.adManager.showBlockAd({ right: 50, top: 500, showNum: 1 });
  448. Utils_1.utils.showMoreGamesWidget({ group: 'default', scale: 1, bottom: 300, left: 50, parent: this._page, location: YZ_Constant_1.BannerLocation.Home });
  449. Utils_1.utils.showTryGamesWidget({ group: 'default', scale: 1, bottom: 350, right: 50, parent: this._page, location: YZ_Constant_1.BannerLocation.Home });
  450. Utils_1.utils.showVivoGamePortalWidget({ top: 500, location: YZ_Constant_1.BannerLocation.Home });
  451. Utils_1.utils.showOppoGameDrawerAdWidget({ top: 500, location: YZ_Constant_1.BannerLocation.Home });
  452. Utils_1.utils.showCreateShortcutWidget(null, { group: 'default', scale: 1, left: 0, top: 500, parent: this._page });
  453. Utils_1.utils.showPrivacyWidget({ group: "default", top: 0, left: 0, parent: this._page.getChildByName("PrivacyWidget"), color: cc.Color.BLACK });
  454. }
  455. };
  456. UIHomePage.prototype._onGameMessageHandler = function (event) {
  457. switch (event.type) {
  458. case Constant_1.default.E_Fly_Coin: {
  459. this._flyCoins(event.iconName, event.frameNodeName);
  460. break;
  461. }
  462. case Constant_1.default.E_CJ_SKIN: {
  463. this._showSkinId = CocosZ_1.cocosz.dataMgr.CurSkinId;
  464. this._updatePlayer();
  465. break;
  466. }
  467. case Constant_1.default.E_CJ_Weapon: {
  468. this._showWeaponId = CocosZ_1.cocosz.dataMgr.curWeapon;
  469. this._updateWeapon();
  470. this._updateWeaponFrame();
  471. break;
  472. }
  473. }
  474. };
  475. UIHomePage.prototype._onBtnClickHandler = function (event) {
  476. return __awaiter(this, void 0, void 0, function () {
  477. var skinInfo, skinInfo, showSkinInfo, showSKinKey, showWeaponInfo, showWeaponKey, t;
  478. var _this = this;
  479. return __generator(this, function (_a) {
  480. switch (_a.label) {
  481. case 0: return [4 /*yield*/, CocosZ_1.cocosz.audioMgr.playBtnEffect().catch()];
  482. case 1:
  483. _a.sent();
  484. switch (event.target.name) {
  485. case "BtnGameStart": {
  486. console.log('zh:BtnGameStart');
  487. CocosZ_1.cocosz.gameMode = 6;
  488. CocosZ_1.cocosz.gameMgr.gameStart(CocosZ_1.cocosz.getLevelId());
  489. break;
  490. }
  491. case "BtnLeft": {
  492. console.log('zh:BtnLeft');
  493. this._showSkinId--;
  494. if (this._showSkinId < 0)
  495. this._showSkinId = 11;
  496. this._updatePlayer();
  497. skinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  498. if (skinInfo && skinInfo.State == 1) {
  499. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  500. }
  501. break;
  502. }
  503. case "BtnRight": {
  504. console.log('zh:BtnRight');
  505. this._showSkinId++;
  506. if (this._showSkinId > 11)
  507. this._showSkinId = 0;
  508. this._updatePlayer();
  509. skinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  510. if (skinInfo && skinInfo.State == 1) {
  511. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  512. }
  513. break;
  514. }
  515. case "BtnSkin": {
  516. console.log('zh:BtnSkin');
  517. showSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  518. showSKinKey = "" + (this._showSkinId + 1);
  519. if (showSkinInfo.State == 0) {
  520. // 金币
  521. if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Gold) {
  522. if (CocosZ_1.cocosz.dataMgr.CoinCount >= gameDate_1.default.SkinMess[showSKinKey].price) {
  523. CocosZ_1.cocosz.dataMgr.CoinCount -= gameDate_1.default.SkinMess[showSKinKey].price;
  524. Msg_1.default.Show(i18n.t("msg.gxhdxjs")); //恭喜获得新角色
  525. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  526. this._updatePlayer();
  527. this._aniEffect(2);
  528. }
  529. else {
  530. this.showCoinPanel(false);
  531. }
  532. }
  533. // 钻石
  534. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Diamond) {
  535. if (CocosZ_1.cocosz.dataMgr.DiamondCount >= gameDate_1.default.SkinMess[showSKinKey].price) {
  536. CocosZ_1.cocosz.dataMgr.DiamondCount -= gameDate_1.default.SkinMess[showSKinKey].price;
  537. Msg_1.default.Show(i18n.t("msg.gxhdxjs")); //恭喜获得新角色
  538. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  539. this._updatePlayer();
  540. this._aniEffect(2);
  541. }
  542. else {
  543. this.showCoinPanel(true);
  544. }
  545. }
  546. // 转盘奖励
  547. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  548. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UITurntablePanel);
  549. }
  550. }
  551. // 升级
  552. else if (showSkinInfo.Level < 6) {
  553. if (CocosZ_1.cocosz.dataMgr.CoinCount >= Constant_1.default.skinLevelPriceArr[showSkinInfo.Level]) {
  554. CocosZ_1.cocosz.dataMgr.CoinCount -= Constant_1.default.skinLevelPriceArr[showSkinInfo.Level];
  555. showSkinInfo.Level++;
  556. CocosZ_1.cocosz.dataMgr.setSkinInfo(showSkinInfo.Id, showSkinInfo);
  557. this._updatePlayer();
  558. this._aniEffect(1);
  559. }
  560. else {
  561. this.showCoinPanel(false);
  562. }
  563. }
  564. break;
  565. }
  566. case "BtnWeapon": {
  567. console.log('zh:BtnWeapon');
  568. showWeaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(this._showWeaponId);
  569. showWeaponKey = weapon_1.default.WeaponName[this._showWeaponId];
  570. if (showWeaponInfo.State == 0) {
  571. // 金币
  572. if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Gold) {
  573. if (CocosZ_1.cocosz.dataMgr.CoinCount >= gameDate_1.default.Weapon[showWeaponKey].price) {
  574. CocosZ_1.cocosz.dataMgr.CoinCount -= gameDate_1.default.Weapon[showWeaponKey].price;
  575. Msg_1.default.Show(i18n.t("msg.gxhdxwq"));
  576. CocosZ_1.cocosz.dataMgr.curWeapon = this._showWeaponId;
  577. this._updateWeapon();
  578. this._updateWeaponFrame();
  579. this._aniEffect(2);
  580. }
  581. else {
  582. this.showCoinPanel(false);
  583. }
  584. }
  585. // 钻石
  586. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Diamond) {
  587. if (CocosZ_1.cocosz.dataMgr.DiamondCount >= gameDate_1.default.Weapon[showWeaponKey].price) {
  588. CocosZ_1.cocosz.dataMgr.DiamondCount -= gameDate_1.default.Weapon[showWeaponKey].price;
  589. Msg_1.default.Show(i18n.t("msg.gxhdxwq"));
  590. CocosZ_1.cocosz.dataMgr.curWeapon = this._showWeaponId;
  591. this._updateWeapon();
  592. this._updateWeaponFrame();
  593. this._aniEffect(2);
  594. }
  595. else {
  596. this.showCoinPanel(true);
  597. }
  598. }
  599. // 转盘奖励
  600. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  601. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UITurntablePanel);
  602. }
  603. }
  604. // 升级
  605. else if (showWeaponInfo.Level < 3) {
  606. if (CocosZ_1.cocosz.dataMgr.CoinCount >= Constant_1.default.weaponLevelPriceArr[showWeaponInfo.Level]) {
  607. CocosZ_1.cocosz.dataMgr.CoinCount -= Constant_1.default.weaponLevelPriceArr[showWeaponInfo.Level];
  608. showWeaponInfo.Level++;
  609. CocosZ_1.cocosz.dataMgr.setGunInfo(showWeaponInfo.Id, showWeaponInfo);
  610. this._updateWeapon();
  611. this._updateWeaponFrame();
  612. this._aniEffect(1);
  613. }
  614. else {
  615. this.showCoinPanel(false);
  616. }
  617. }
  618. break;
  619. }
  620. case "BtnSkinAd": {
  621. console.log('zh:BtnSkinAd');
  622. Utils_1.utils.SendEvent("视频-皮肤解锁-播放");
  623. // 注册方法 , this.ClickClose.bind(this));
  624. //GlobalManager.getInstance().registerMethod('event_wuqi_unlook', this.event_wuqi_unlook.bind(this));
  625. cc.sys.localStorage.setItem(this.adKey, 'event_pifu_unlook'); //
  626. if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
  627. console.log('zh:AD ready for idx2');
  628. ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
  629. }
  630. else {
  631. console.log('zh:AD not ready for idx2');
  632. this.event_pifu_unlook();
  633. }
  634. if (2 > 1) {
  635. return [2 /*return*/]; //下面是原始的代码
  636. }
  637. CocosZ_1.cocosz.watchAD(function () {
  638. // 视频成功
  639. Utils_1.utils.SendEvent("视频-皮肤解锁-成功");
  640. var showSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(_this._showSkinId);
  641. var showSkinKey = "" + (_this._showSkinId + 1);
  642. if (!!showSkinInfo && !!gameDate_1.default.SkinMess[showSkinKey] && !!gameDate_1.default.SkinMess[showSkinKey].videoCount) {
  643. showSkinInfo.VideoCount++;
  644. CocosZ_1.cocosz.dataMgr.setSkinInfo(_this._showSkinId, showSkinInfo);
  645. if (showSkinInfo.VideoCount >= gameDate_1.default.SkinMess[showSkinKey].videoCount) {
  646. Msg_1.default.Show(i18n.t("msg.gxhdxjs")); //恭喜获得新角色
  647. CocosZ_1.cocosz.dataMgr.CurSkinId = _this._showSkinId;
  648. _this._aniEffect(2);
  649. }
  650. else {
  651. Msg_1.default.Show(i18n.t("msg.jswc") + showSkinInfo.VideoCount + "/" + gameDate_1.default.SkinMess[showSkinKey].videoCount);
  652. }
  653. // 更新玩家信息
  654. _this._updatePlayer();
  655. }
  656. }, function () {
  657. // 视频失败
  658. Utils_1.utils.SendEvent("视频-皮肤解锁-失败");
  659. });
  660. break;
  661. }
  662. case "BtnWeaponAd": {
  663. console.log('zh:BtnWeaponAd');
  664. Utils_1.utils.SendEvent("视频-武器解锁-播放");
  665. // 注册方法 , this.ClickClose.bind(this));
  666. //GlobalManager.getInstance().registerMethod('event_wuqi_unlook', this.event_wuqi_unlook.bind(this));
  667. cc.sys.localStorage.setItem(this.adKey, 'event_wuqi_unlook'); //
  668. if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
  669. console.log('zh:AD ready for idx2');
  670. ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
  671. }
  672. else {
  673. console.log('zh:AD not ready for idx2');
  674. this.event_wuqi_unlook();
  675. }
  676. if (2 > 1) {
  677. return [2 /*return*/]; //下面是原始的代码
  678. }
  679. CocosZ_1.cocosz.watchAD(function () {
  680. // 视频成功
  681. Utils_1.utils.SendEvent("视频-武器解锁-成功");
  682. _this.event_wuqi_unlook();
  683. }, function () {
  684. // 视频失败
  685. Utils_1.utils.SendEvent("视频-武器解锁-失败");
  686. });
  687. break;
  688. }
  689. case "BtnCJ": {
  690. console.log('zh:BtnCJ');
  691. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UITurntablePanel);
  692. break;
  693. }
  694. case "BtnSign": {
  695. console.log('zh:BtnSign');
  696. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UISignPanel);
  697. break;
  698. }
  699. case "BtnTime": {
  700. console.log('zh:BtnTime');
  701. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UITimePanel);
  702. break;
  703. }
  704. case "BtnSet": {
  705. console.log('zh:BtnSet');
  706. this._icon_set.stopAllActions();
  707. this._frame_set.stopAllActions();
  708. t = (this._frame_set.scaleY ? this._frame_set.scaleY : 1) / 2;
  709. cc.tween(this._icon_set)
  710. .to(t, { angle: (this._frame_set.scaleY ? 90 : -90) }, { easing: "sineInOut" })
  711. .start();
  712. cc.tween(this._frame_set)
  713. .to(t, { scaleY: this._frame_set.scaleY ? 0 : 1 }, { easing: "sineInOut" })
  714. .start();
  715. break;
  716. }
  717. case "BtnAudio": {
  718. console.log('zh:BtnAudio');
  719. CocosZ_1.cocosz.dataMgr.AudioOn = !CocosZ_1.cocosz.dataMgr.AudioOn;
  720. this._updateAudioBtn();
  721. break;
  722. }
  723. case "BtnShake": {
  724. console.log('zh:BtnShake');
  725. CocosZ_1.cocosz.dataMgr.ShakeOn = !CocosZ_1.cocosz.dataMgr.ShakeOn;
  726. this._updatShakeBtn();
  727. break;
  728. }
  729. }
  730. return [2 /*return*/];
  731. }
  732. });
  733. });
  734. };
  735. //武器结算
  736. UIHomePage.prototype.event_wuqi_unlook = function () {
  737. console.log('zh:event_wuqi_unlook 被触发');
  738. var showWeaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(this._showWeaponId);
  739. var showWeaponKey = weapon_1.default.WeaponName[this._showWeaponId];
  740. if (!!showWeaponInfo && !!gameDate_1.default.Weapon[showWeaponKey] && !!gameDate_1.default.Weapon[showWeaponKey].videoCount) {
  741. showWeaponInfo.VideoCount++;
  742. CocosZ_1.cocosz.dataMgr.setGunInfo(this._showWeaponId, showWeaponInfo);
  743. if (showWeaponInfo.VideoCount >= gameDate_1.default.Weapon[showWeaponKey].videoCount) {
  744. Msg_1.default.Show(i18n.t("msg.gxhdxwq"));
  745. CocosZ_1.cocosz.dataMgr.curWeapon = this._showWeaponId;
  746. this._aniEffect(2);
  747. }
  748. else {
  749. Msg_1.default.Show(i18n.t("msg.jswc") + showWeaponInfo.VideoCount + "/" + gameDate_1.default.Weapon[showWeaponKey].videoCount);
  750. }
  751. // 更新武器信息
  752. this._updateWeapon();
  753. this._updateWeaponFrame();
  754. }
  755. };
  756. //皮肤解锁
  757. UIHomePage.prototype.event_pifu_unlook = function () {
  758. console.log('zh:event_pifu_unlook 被触发');
  759. // 视频成功
  760. Utils_1.utils.SendEvent("视频-皮肤解锁-成功");
  761. var showSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  762. var showSkinKey = "" + (this._showSkinId + 1);
  763. if (!!showSkinInfo && !!gameDate_1.default.SkinMess[showSkinKey] && !!gameDate_1.default.SkinMess[showSkinKey].videoCount) {
  764. showSkinInfo.VideoCount++;
  765. CocosZ_1.cocosz.dataMgr.setSkinInfo(this._showSkinId, showSkinInfo);
  766. if (showSkinInfo.VideoCount >= gameDate_1.default.SkinMess[showSkinKey].videoCount) {
  767. Msg_1.default.Show(i18n.t("msg.gxhdxjs")); //恭喜获得新角色
  768. CocosZ_1.cocosz.dataMgr.CurSkinId = this._showSkinId;
  769. this._aniEffect(2);
  770. }
  771. else {
  772. Msg_1.default.Show(i18n.t("msg.jswc") + showSkinInfo.VideoCount + "/" + gameDate_1.default.SkinMess[showSkinKey].videoCount);
  773. }
  774. // 更新玩家信息
  775. this._updatePlayer();
  776. }
  777. };
  778. UIHomePage.prototype._updatePlayer = function () {
  779. var _this = this;
  780. cc.log("showSkinID: ", this._showSkinId);
  781. this._playerAni.setSkinById(this._showSkinId);
  782. // 属性
  783. // 角色名字
  784. this._skinInfo_name.spriteFrame = CocosZ_1.cocosz.resMgr.getRes("p_" + (this._showSkinId + 1), cc.SpriteFrame);
  785. // 角色属性
  786. var curSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(CocosZ_1.cocosz.dataMgr.CurSkinId);
  787. var showSkinInfo = CocosZ_1.cocosz.dataMgr.getSkinInfo(this._showSkinId);
  788. var curLevel = curSkinInfo.Level;
  789. var showLevel = showSkinInfo.Level;
  790. var curSkinKey = "" + (CocosZ_1.cocosz.dataMgr.CurSkinId + 1);
  791. var showSKinKey = "" + (this._showSkinId + 1);
  792. // 血滴
  793. this._skinInfo_xuedi.children.forEach(function (v, i) {
  794. if (i < gameDate_1.default.SkinMess[showSKinKey].xuedi) {
  795. _this._skinInfo_xuedi.children[i].opacity = 255;
  796. }
  797. else {
  798. _this._skinInfo_xuedi.children[i].opacity = 0;
  799. }
  800. });
  801. // 攻击力
  802. this._skinInfo_value1.string = "" + gameDate_1.default.SkinMess[showSKinKey].atk[showLevel];
  803. // 移动
  804. this._skinInfo_value2.string = "" + gameDate_1.default.SkinMess[showSKinKey].speed[showLevel];
  805. // 攻击变化
  806. var num1 = gameDate_1.default.SkinMess[showSKinKey].atk[showLevel] - gameDate_1.default.SkinMess[curSkinKey].atk[curLevel];
  807. if (num1 < 0) {
  808. this._skinInfo_change1.string = "" + num1;
  809. this._skinInfo_change1.node.children[0].active = false;
  810. this._skinInfo_change1.node.children[1].active = true;
  811. this._skinInfo_change1.node.color = cc.Color.RED;
  812. this._skinInfo_change1.node.opacity = 255;
  813. }
  814. else if (num1 == 0) {
  815. this._skinInfo_change1.node.opacity = 0;
  816. }
  817. else {
  818. this._skinInfo_change1.string = "+" + num1;
  819. this._skinInfo_change1.node.children[0].active = true;
  820. this._skinInfo_change1.node.children[1].active = false;
  821. this._skinInfo_change1.node.color = cc.Color.GREEN;
  822. this._skinInfo_change1.node.opacity = 255;
  823. }
  824. // 移动变化
  825. var num2 = gameDate_1.default.SkinMess[showSKinKey].speed[showLevel] - gameDate_1.default.SkinMess[curSkinKey].speed[curLevel];
  826. if (num2 < 0) {
  827. this._skinInfo_change2.string = "" + num2;
  828. this._skinInfo_change2.node.children[0].active = false;
  829. this._skinInfo_change2.node.children[1].active = true;
  830. this._skinInfo_change2.node.color = cc.Color.RED;
  831. this._skinInfo_change2.node.opacity = 255;
  832. }
  833. else if (num2 == 0) {
  834. this._skinInfo_change2.node.opacity = 0;
  835. }
  836. else {
  837. this._skinInfo_change2.string = "+" + num2;
  838. this._skinInfo_change2.node.children[0].active = true;
  839. this._skinInfo_change2.node.children[1].active = false;
  840. this._skinInfo_change2.node.color = cc.Color.GREEN;
  841. this._skinInfo_change2.node.opacity = 255;
  842. }
  843. // 等级
  844. this._skinInfo_level_pro.progress = showLevel / 6;
  845. // 按钮变化
  846. if (showSkinInfo) {
  847. this._btnSkin.children.forEach(function (v) { return v.active = false; });
  848. var btn_huang = this._btnSkin.getChildByName("btn_huang");
  849. var btn_huang_small = this._btnSkin.getChildByName("btn_huang_small");
  850. var btn_hong = this._btnSkin.getChildByName("btn_hong");
  851. var txt_buy = this._btnSkin.getChildByName("txt_buy");
  852. var txt_sjwc = this._btnSkin.getChildByName("txt_sjwc");
  853. var txt_upgrade = this._btnSkin.getChildByName("txt_upgrade");
  854. var txt_zpjl = this._btnSkin.getChildByName("txt_zpjl");
  855. var icon_jinbi = this._btnSkin.getChildByName("icon_jinbi");
  856. var icon_zuanshi = this._btnSkin.getChildByName("icon_zuanshi");
  857. var price = this._btnSkin.getChildByName("price");
  858. // 购买
  859. if (showSkinInfo.State == 0) {
  860. if (gameDate_1.default.SkinMess[showSKinKey] && gameDate_1.default.SkinMess[showSKinKey].videoCount) {
  861. this._btnSkin.x = -350;
  862. this._btnSkin.width = 169;
  863. if (btn_huang_small)
  864. btn_huang_small.active = true;
  865. // 金币
  866. if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Gold) {
  867. if (icon_jinbi) {
  868. icon_jinbi.active = true;
  869. icon_jinbi.x = -50;
  870. }
  871. if (price) {
  872. price.active = true;
  873. price.x = -10;
  874. price.getComponent(cc.Label).string = '' + gameDate_1.default.SkinMess[showSKinKey].price;
  875. }
  876. }
  877. // 钻石
  878. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Diamond) {
  879. if (icon_zuanshi) {
  880. icon_zuanshi.active = true;
  881. icon_zuanshi.x = -50;
  882. }
  883. if (price) {
  884. price.active = true;
  885. price.x = -10;
  886. price.getComponent(cc.Label).string = '' + gameDate_1.default.SkinMess[showSKinKey].price;
  887. }
  888. }
  889. // 转盘奖励
  890. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  891. if (txt_zpjl)
  892. txt_zpjl.active = true;
  893. }
  894. // 视频解锁
  895. this._btnSkinAd.active = true;
  896. var videoCount = this._btnSkinAd.getChildByName("videoCount");
  897. if (videoCount)
  898. videoCount.getComponent(cc.Label).string = showSkinInfo.VideoCount + "/" + gameDate_1.default.SkinMess[showSKinKey].videoCount;
  899. }
  900. else {
  901. this._btnSkinAd.active = false;
  902. this._btnSkin.x = -250;
  903. this._btnSkin.width = 252;
  904. if (btn_huang)
  905. btn_huang.active = true;
  906. // 金币
  907. if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Gold) {
  908. if (txt_buy)
  909. txt_buy.active = true;
  910. if (icon_jinbi) {
  911. icon_jinbi.active = true;
  912. icon_jinbi.x = 0;
  913. }
  914. if (price) {
  915. price.active = true;
  916. price.x = 30;
  917. price.getComponent(cc.Label).string = '' + gameDate_1.default.SkinMess[showSKinKey].price;
  918. }
  919. }
  920. // 钻石
  921. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.Diamond) {
  922. if (txt_buy)
  923. txt_buy.active = true;
  924. if (icon_zuanshi) {
  925. icon_zuanshi.active = true;
  926. icon_zuanshi.x = 0;
  927. }
  928. if (price) {
  929. price.active = true;
  930. price.x = 30;
  931. price.getComponent(cc.Label).string = '' + gameDate_1.default.SkinMess[showSKinKey].price;
  932. }
  933. }
  934. // 转盘奖励
  935. else if (gameDate_1.default.SkinMess[showSKinKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  936. if (txt_zpjl)
  937. txt_zpjl.active = true;
  938. }
  939. }
  940. }
  941. // 升级
  942. else if (showSkinInfo.Level < 6) {
  943. this._btnSkinAd.active = false;
  944. this._btnSkin.x = -250;
  945. this._btnSkin.width = 252;
  946. if (btn_hong)
  947. btn_hong.active = true;
  948. if (txt_upgrade)
  949. txt_upgrade.active = true;
  950. if (icon_jinbi) {
  951. icon_jinbi.active = true;
  952. icon_jinbi.x = 0;
  953. }
  954. if (price) {
  955. price.active = true;
  956. price.x = 30;
  957. price.getComponent(cc.Label).string = '' + Constant_1.default.skinLevelPriceArr[showSkinInfo.Level];
  958. }
  959. }
  960. // 最大等级
  961. else {
  962. this._btnSkinAd.active = false;
  963. this._btnSkin.x = -250;
  964. this._btnSkin.width = 252;
  965. if (txt_sjwc)
  966. txt_sjwc.active = true;
  967. }
  968. }
  969. };
  970. UIHomePage.prototype._updateWeapon = function () {
  971. cc.log("showWeaponID: ", this._showWeaponId);
  972. this._playerAni.setWeaponById(this._showWeaponId);
  973. // 武器名字
  974. this._weaponInfo_name.spriteFrame = CocosZ_1.cocosz.resMgr.getRes("w_" + (this._showWeaponId + 1), cc.SpriteFrame);
  975. // 武器属性
  976. var curWeaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(CocosZ_1.cocosz.dataMgr.CurRange);
  977. var showWeaponInfo = CocosZ_1.cocosz.dataMgr.getGunInfo(this._showWeaponId);
  978. var curLevel = curWeaponInfo.Level;
  979. var showLevel = showWeaponInfo.Level;
  980. var curWeaponKey = weapon_1.default.WeaponName[CocosZ_1.cocosz.dataMgr.CurRange];
  981. var showWeaponKey = weapon_1.default.WeaponName[this._showWeaponId];
  982. // 攻击力
  983. this._weaponInfo_value0.string = "" + gameDate_1.default.Weapon[showWeaponKey].atk[showLevel];
  984. // 攻击频率
  985. this._weaponInfo_value1.string = (1 / gameDate_1.default.Weapon[showWeaponKey].atkSpeed[showLevel]).toFixed(1);
  986. // 攻击范围
  987. this._weaponInfo_value2.string = "" + gameDate_1.default.Weapon[showWeaponKey].atkRange;
  988. // 弹药量
  989. this._weaponInfo_value3.string = "" + gameDate_1.default.Weapon[showWeaponKey].bulletTotal[showLevel];
  990. // 变化
  991. var num0 = gameDate_1.default.Weapon[showWeaponKey].atk[showLevel] - gameDate_1.default.Weapon[curWeaponKey].atk[curLevel];
  992. var num1 = 1 / gameDate_1.default.Weapon[showWeaponKey].atkSpeed[showLevel] - 1 / gameDate_1.default.Weapon[curWeaponKey].atkSpeed[curLevel];
  993. var num2 = gameDate_1.default.Weapon[showWeaponKey].atkRange - gameDate_1.default.Weapon[curWeaponKey].atkRange;
  994. var num3 = gameDate_1.default.Weapon[showWeaponKey].bulletTotal[showLevel] - gameDate_1.default.Weapon[curWeaponKey].bulletTotal[curLevel];
  995. // 攻击力变化
  996. if (num0 < 0) {
  997. this._weaponInfo_change0.string = "" + num0;
  998. this._weaponInfo_change0.node.children[0].active = false;
  999. this._weaponInfo_change0.node.children[1].active = true;
  1000. this._weaponInfo_change0.node.color = cc.Color.RED;
  1001. this._weaponInfo_change0.node.opacity = 255;
  1002. }
  1003. else if (num0 == 0) {
  1004. this._weaponInfo_change0.node.opacity = 0;
  1005. }
  1006. else {
  1007. this._weaponInfo_change0.string = "+" + num0;
  1008. this._weaponInfo_change0.node.children[0].active = true;
  1009. this._weaponInfo_change0.node.children[1].active = false;
  1010. this._weaponInfo_change0.node.color = cc.Color.GREEN;
  1011. this._weaponInfo_change0.node.opacity = 255;
  1012. }
  1013. // 攻击频率变化
  1014. if (num1 < 0) {
  1015. this._weaponInfo_change1.string = "" + num1;
  1016. this._weaponInfo_change1.node.children[0].active = false;
  1017. this._weaponInfo_change1.node.children[1].active = true;
  1018. this._weaponInfo_change1.node.color = cc.Color.RED;
  1019. this._weaponInfo_change1.node.opacity = 255;
  1020. }
  1021. else if (num1 == 0) {
  1022. this._weaponInfo_change1.node.opacity = 0;
  1023. }
  1024. else {
  1025. this._weaponInfo_change1.string = "+" + num1;
  1026. this._weaponInfo_change1.node.children[0].active = true;
  1027. this._weaponInfo_change1.node.children[1].active = false;
  1028. this._weaponInfo_change1.node.color = cc.Color.GREEN;
  1029. this._weaponInfo_change1.node.opacity = 255;
  1030. }
  1031. // 攻击范围变化
  1032. if (num2 < 0) {
  1033. this._weaponInfo_change2.string = "" + num2;
  1034. this._weaponInfo_change2.node.children[0].active = false;
  1035. this._weaponInfo_change2.node.children[1].active = true;
  1036. this._weaponInfo_change2.node.color = cc.Color.RED;
  1037. this._weaponInfo_change2.node.opacity = 255;
  1038. }
  1039. else if (num2 == 0) {
  1040. this._weaponInfo_change2.node.opacity = 0;
  1041. }
  1042. else {
  1043. this._weaponInfo_change2.string = "+" + num2;
  1044. this._weaponInfo_change2.node.children[0].active = true;
  1045. this._weaponInfo_change2.node.children[1].active = false;
  1046. this._weaponInfo_change2.node.color = cc.Color.GREEN;
  1047. this._weaponInfo_change2.node.opacity = 255;
  1048. }
  1049. // 弹药量变化
  1050. if (num3 < 0) {
  1051. this._weaponInfo_change3.string = "" + num3;
  1052. this._weaponInfo_change3.node.children[0].active = false;
  1053. this._weaponInfo_change3.node.children[1].active = true;
  1054. this._weaponInfo_change3.node.color = cc.Color.RED;
  1055. this._weaponInfo_change3.node.opacity = 255;
  1056. }
  1057. else if (num3 == 0) {
  1058. this._weaponInfo_change3.node.opacity = 0;
  1059. }
  1060. else {
  1061. this._weaponInfo_change3.string = "+" + num3;
  1062. this._weaponInfo_change3.node.children[0].active = true;
  1063. this._weaponInfo_change3.node.children[1].active = false;
  1064. this._weaponInfo_change3.node.color = cc.Color.GREEN;
  1065. this._weaponInfo_change3.node.opacity = 255;
  1066. }
  1067. // 等级
  1068. this._weaponInfo_level_pro.progress = showLevel / 3;
  1069. // 按钮变化
  1070. if (showWeaponInfo) {
  1071. this._btnWeapon.children.forEach(function (v) { return v.active = false; });
  1072. var btn_huang = this._btnWeapon.getChildByName("btn_huang");
  1073. var btn_huang_small = this._btnWeapon.getChildByName("btn_huang_small");
  1074. var btn_hong = this._btnWeapon.getChildByName("btn_hong");
  1075. var txt_buy = this._btnWeapon.getChildByName("txt_buy");
  1076. var txt_sjwc = this._btnWeapon.getChildByName("txt_sjwc");
  1077. var txt_upgrade = this._btnWeapon.getChildByName("txt_upgrade");
  1078. var txt_zpjl = this._btnWeapon.getChildByName("txt_zpjl");
  1079. var icon_jinbi = this._btnWeapon.getChildByName("icon_jinbi");
  1080. var icon_zuanshi = this._btnWeapon.getChildByName("icon_zuanshi");
  1081. var price = this._btnWeapon.getChildByName("price");
  1082. if (showWeaponInfo.State == 0) {
  1083. // 视频解锁
  1084. if (gameDate_1.default.Weapon[showWeaponKey] && gameDate_1.default.Weapon[showWeaponKey].videoCount) {
  1085. this._btnWeapon.x = 150;
  1086. this._btnWeapon.width = 169;
  1087. if (btn_huang_small)
  1088. btn_huang_small.active = true;
  1089. // 金币
  1090. if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Gold) {
  1091. if (icon_jinbi) {
  1092. icon_jinbi.active = true;
  1093. icon_jinbi.x = -50;
  1094. }
  1095. if (price) {
  1096. price.active = true;
  1097. price.x = -10;
  1098. price.getComponent(cc.Label).string = '' + gameDate_1.default.Weapon[showWeaponKey].price;
  1099. }
  1100. }
  1101. // 钻石
  1102. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Diamond) {
  1103. if (icon_zuanshi) {
  1104. icon_zuanshi.active = true;
  1105. icon_zuanshi.x = -50;
  1106. }
  1107. if (price) {
  1108. price.active = true;
  1109. price.x = -10;
  1110. price.getComponent(cc.Label).string = '' + gameDate_1.default.Weapon[showWeaponKey].price;
  1111. }
  1112. }
  1113. // 转盘奖励
  1114. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  1115. if (txt_zpjl)
  1116. txt_zpjl.active = true;
  1117. }
  1118. // 视频解锁
  1119. this._btnWeaponAd.active = true;
  1120. var videoCount = this._btnWeaponAd.getChildByName("videoCount");
  1121. if (videoCount)
  1122. videoCount.getComponent(cc.Label).string = showWeaponInfo.VideoCount + "/" + gameDate_1.default.Weapon[showWeaponKey].videoCount;
  1123. }
  1124. // 购买
  1125. else {
  1126. this._btnWeaponAd.active = false;
  1127. this._btnWeapon.x = 250;
  1128. this._btnWeapon.width = 252;
  1129. if (btn_huang)
  1130. btn_huang.active = true;
  1131. // 金币
  1132. if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Gold) {
  1133. if (txt_buy)
  1134. txt_buy.active = true;
  1135. if (icon_jinbi) {
  1136. icon_jinbi.active = true;
  1137. icon_jinbi.x = 0;
  1138. }
  1139. if (price) {
  1140. price.active = true;
  1141. price.x = 30;
  1142. price.getComponent(cc.Label).string = '' + gameDate_1.default.Weapon[showWeaponKey].price;
  1143. }
  1144. }
  1145. // 钻石
  1146. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.Diamond) {
  1147. if (txt_buy)
  1148. txt_buy.active = true;
  1149. if (icon_zuanshi) {
  1150. icon_zuanshi.active = true;
  1151. icon_zuanshi.x = 0;
  1152. }
  1153. if (price) {
  1154. price.active = true;
  1155. price.x = 30;
  1156. price.getComponent(cc.Label).string = '' + gameDate_1.default.Weapon[showWeaponKey].price;
  1157. }
  1158. }
  1159. // 转盘奖励
  1160. else if (gameDate_1.default.Weapon[showWeaponKey].priceType == gameDate_1.PriceType.ZhuanPanReward) {
  1161. if (txt_zpjl)
  1162. txt_zpjl.active = true;
  1163. }
  1164. }
  1165. }
  1166. // 升级
  1167. else if (showWeaponInfo.Level < 3) {
  1168. this._btnWeaponAd.active = false;
  1169. this._btnWeapon.x = 250;
  1170. this._btnWeapon.width = 252;
  1171. if (btn_hong)
  1172. btn_hong.active = true;
  1173. if (txt_upgrade)
  1174. txt_upgrade.active = true;
  1175. if (icon_jinbi) {
  1176. icon_jinbi.active = true;
  1177. icon_jinbi.x = 0;
  1178. }
  1179. if (price) {
  1180. price.active = true;
  1181. price.x = 30;
  1182. price.getComponent(cc.Label).string = '' + Constant_1.default.weaponLevelPriceArr[showWeaponInfo.Level];
  1183. }
  1184. }
  1185. // 最大等级
  1186. else {
  1187. this._btnWeaponAd.active = false;
  1188. this._btnWeapon.x = 250;
  1189. this._btnWeapon.width = 252;
  1190. if (txt_sjwc)
  1191. txt_sjwc.active = true;
  1192. }
  1193. }
  1194. this._updateWeaponFrame();
  1195. };
  1196. UIHomePage.prototype._updateWeaponFrame = function () {
  1197. var gunInfos = CocosZ_1.cocosz.dataMgr.getItem(Constant_1.default.ST_GunInfo, "");
  1198. if (gunInfos) {
  1199. var gunInfoArr = JSON.parse(gunInfos);
  1200. if (gunInfoArr) {
  1201. for (var i = 0; i < this._weaponList.length; i++) {
  1202. var node = this._weaponList[i];
  1203. if (gameDate_1.default.Weapon[node.name] && gameDate_1.default.Weapon[node.name].id >= 0) {
  1204. var id = gameDate_1.default.Weapon[node.name].id;
  1205. if (gunInfoArr[id]) {
  1206. var state = gunInfoArr[id].State;
  1207. if (state >= 1) {
  1208. node.getChildByName("kuang_hui").active = false;
  1209. }
  1210. else {
  1211. node.getChildByName("kuang_hui").active = true;
  1212. }
  1213. // 选中
  1214. if (node.name == weapon_1.default.WeaponName[this._showWeaponId]) {
  1215. node.getChildByName("kuang_huang").active = true;
  1216. if (this._ani_arrow) {
  1217. if (gunInfoArr[id].State > 0 && gunInfoArr[id].Level < 3) {
  1218. this._ani_arrow.x = node.x + 30;
  1219. this._ani_arrow.active = true;
  1220. }
  1221. else {
  1222. this._ani_arrow.active = false;
  1223. }
  1224. }
  1225. }
  1226. else {
  1227. node.getChildByName("kuang_huang").active = false;
  1228. }
  1229. }
  1230. else {
  1231. node.getChildByName("kuang_hui").active = false;
  1232. node.getChildByName("kuang_huang").active = false;
  1233. }
  1234. }
  1235. else {
  1236. node.getChildByName("kuang_hui").active = false;
  1237. node.getChildByName("kuang_huang").active = false;
  1238. }
  1239. }
  1240. }
  1241. }
  1242. };
  1243. /** 金币/钻石弹窗 */
  1244. UIHomePage.prototype.showCoinPanel = function (isDiamond) {
  1245. var node = cc.instantiate(CocosZ_1.cocosz.resMgr.getRes("UIADPanel", cc.Prefab));
  1246. cc.find("Canvas").addChild(node);
  1247. if (isDiamond) {
  1248. node.getComponent("UIADPanel").setDiamond();
  1249. }
  1250. };
  1251. /** 飞金币/钻石 */
  1252. UIHomePage.prototype._flyCoins = function (iconName, frameNodeName) {
  1253. var posNode = cc.find(frameNodeName, this._page);
  1254. if (!posNode)
  1255. return;
  1256. var pos = posNode.parent.convertToWorldSpaceAR(posNode.position);
  1257. FlyCoin_1.default.Show(iconName, pos);
  1258. };
  1259. /** 更新音频开关 */
  1260. UIHomePage.prototype._updateAudioBtn = function (isPlay) {
  1261. if (isPlay === void 0) { isPlay = true; }
  1262. var offImg = cc.find("Background/off", this._btnAudio);
  1263. offImg.active = CocosZ_1.cocosz.dataMgr.AudioOn == false;
  1264. if (isPlay) {
  1265. //判断开关,重新播放背景音乐
  1266. if (CocosZ_1.cocosz.dataMgr.AudioOn) {
  1267. CocosZ_1.cocosz.audioMgr.playBgm();
  1268. }
  1269. else {
  1270. CocosZ_1.cocosz.audioMgr.stopAll();
  1271. }
  1272. }
  1273. };
  1274. /** 更新震动开关 */
  1275. UIHomePage.prototype._updatShakeBtn = function () {
  1276. var offImg = cc.find("Background/off", this._btnShake);
  1277. offImg.active = CocosZ_1.cocosz.dataMgr.ShakeOn == false;
  1278. };
  1279. UIHomePage = __decorate([
  1280. ccclass
  1281. ], UIHomePage);
  1282. return UIHomePage;
  1283. }(UIPage_1.default));
  1284. exports.default = UIHomePage;
  1285. cc._RF.pop();