UIHomePage.ts 52 KB

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