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

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