123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239 |
- import UIPage from "../Framework/UIPage";
- import Constant, { GunInfo, PageName, PanelName, SkillInfo } from "../Framework/Constant";
- import { cocosz } from "../Framework/CocosZ";
- import { utils } from "../../common-plugin/Scripts/Utils";
- import { BannerLocation } from "../../common-plugin/Scripts/YZ_Constant";
- import Ani from "../Game/ani";
- import PlatUtils from "../../common-plugin/Scripts/PlatUtils";
- import FlyCoin from "../Framework/FlyCoin";
- import GameDate, { PriceType } from "../Game/gameDate";
- import Weapon from "../Game/weapon";
- import Msg from "../Framework/Msg";
- import AESUtil from "../AESUtil"
- import ATSDK from "../AnyThinkAds/ATJSSDK";
- import ATRewardedVideoSDK from "../AnyThinkAds/ATRewardedVideoJSSDK";
- import AAJS2 from "../ATAndroidJS2";
- import GlobalManager from '../GlobalManager';
- // @ts-ignore
- const i18n = require('LanguageData');
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class UIHomePage extends UIPage implements AdDeveloperCallback {
- constructor() {
- super(PageName.UIHomePage);
- this.isValid() && this.onLoad();
- }
- adState: boolean = false;
- adKey: string = "zh_ad_type";
- onRewardedVideoAdLoaded(placementId: any): void {
- ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")");
- }
- onRewardedVideoAdFailed(placementId: any, errorInfo: any): void {
- ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdFailed(" + placementId + ", " + errorInfo + ")");
- }
- onRewardedVideoAdPlayStart(placementId: any, callbackInfo: any): void {
- ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayStart(" + placementId + ", " + callbackInfo + ")");
- let deviceId = AAJS2.getDeviceUserId();
- var setting = {};
- setting[ATRewardedVideoSDK.userIdKey] = deviceId;
- ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
-
- }
- onRewardedVideoAdPlayEnd(placementId: any, callbackInfo: any): void {
- ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")");
- console.log('zh: ad PlayEnd')
- //this.node.emit("handleCustomEvent");
- }
- onRewardedVideoAdPlayFailed(placementId: any, errorInfo: any, callbackInfo: any): void {
- ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")");
- }
- onRewardedVideoAdClosed(placementId: any, callbackInfo: any): void {
- ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::AdClosed(" + placementId + ", " + callbackInfo + ")");
- if (this.adState == true) {
- this.adState = false;
- console.log('zh: ad奖励OK,开始处理奖励')
- this.handleCustomEvent()
- } else {
- console.log('zh: ad奖励标识 NO OK ')
- }
- }
- onRewardedVideoAdPlayClicked(placementId: any, callbackInfo: any): void {
- ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
- }
- onReward(placementId: any, callbackInfo: any): void {
- ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onReward(" + placementId + ", " + callbackInfo + ")");
- console.log('zh:onReward AD奖励标志OK')
- this.adState = true;
- }
- private _icon_set: cc.Node = null;
- private _frame_set: cc.Node = null;
- private _btnAudio: cc.Node = null;
- private _btnShake: cc.Node = null;
- private _btnSkin: cc.Node = null;
- private _btnSkinAd: cc.Node = null;
- private _btnWeapon: cc.Node = null;
- private _btnWeaponAd: cc.Node = null;
- private _playerAni: Ani = null;
- private _aniUpgrade: sp.Skeleton = null;
- private _aniCaidai: sp.Skeleton = null;
- private _weaponScroll: cc.Node = null;
- private _weaponList: cc.Node[] = [];
- private _ani_arrow: cc.Node = null;
- private _skinInfo_name: cc.Sprite = null;
- private _skinInfo_xuedi: cc.Node = null;
- private _skinInfo_value1: cc.Label = null;
- private _skinInfo_value2: cc.Label = null;
- private _skinInfo_change1: cc.Label = null;
- private _skinInfo_change2: cc.Label = null;
- private _skinInfo_level_pro: cc.ProgressBar = null;
- private _weaponInfo_name: cc.Sprite = null;
- private _weaponInfo_value0: cc.Label = null;
- private _weaponInfo_value1: cc.Label = null;
- private _weaponInfo_value2: cc.Label = null;
- private _weaponInfo_value3: cc.Label = null;
- private _weaponInfo_change0: cc.Label = null;
- private _weaponInfo_change1: cc.Label = null;
- private _weaponInfo_change2: cc.Label = null;
- private _weaponInfo_change3: cc.Label = null;
- private _weaponInfo_level_pro: cc.ProgressBar = null;
- protected onLoad() {
- console.log("zh: UIHOMEPAGE ONLOAD")
- // 按钮
- let btnNames: string[] = ["BtnSet", "BtnSet/frame_set/BtnAudio", "BtnSet/frame_set/BtnShake", "ditai/BtnLeft", "ditai/BtnRight", "BtnSkin", "BtnWeapon", "BtnSkinAd", "BtnWeaponAd", "BtnCJ", "BtnSign", "BtnTime", "BtnGameStart"];
- btnNames.forEach(name => {
- let btn: cc.Node = cc.find(name, this._page);
- if (btn) {
- btn.on(cc.Node.EventType.TOUCH_END, this._onBtnClickHandler, this);
- if (btn.name == "BtnSet") {
- this._icon_set = cc.find("Background/icon_set", btn);
- this._frame_set = cc.find("frame_set", btn);
- } else if (btn.name == "BtnAudio") {
- this._btnAudio = btn;
- this._updateAudioBtn(false);
- } else if (btn.name == "BtnShake") {
- this._btnShake = btn;
- this._updatShakeBtn();
- } else if (btn.name == "BtnSkin") {
- this._btnSkin = btn;
- } else if (btn.name == "BtnWeapon") {
- this._btnWeapon = btn;
- } else if (btn.name == "BtnSkinAd") {
- this._btnSkinAd = btn;
- btn.active = cocosz.isADON;
- } else if (btn.name == "BtnWeaponAd") {
- this._btnWeaponAd = btn;
- btn.active = cocosz.isADON;
- }
- }
- });
- // 角色动画
- this._playerAni = cc.find("ditai/skin_all/ani", this._page).getComponent(Ani);
- // 彩带动画
- this._aniCaidai = cc.find("ditai/aniCaidai", this._page).getComponent(sp.Skeleton);
- this._aniCaidai.setCompleteListener(() => { this._aniCaidai.node.active = false; })
- // 升级动画
- this._aniUpgrade = cc.find("ditai/aniUpgrade", this._page).getComponent(sp.Skeleton);
- this._aniUpgrade.setCompleteListener(() => { this._aniUpgrade.node.active = false; })
- // 武器
- this._weaponScroll = cc.find("weaponScroll", this._page);
- let content = cc.find("view/content", this._weaponScroll);
- for (let i = 0; i < content.children.length; i++) {
- this._weaponList.push(content.children[i]);
- this._weaponList[i].on(cc.Node.EventType.TOUCH_END, (e) => {
- cocosz.audioMgr.playBtnEffect();
- let id = GameDate.Weapon[e.target.name].id;
- this._showWeaponId = id;
- this._updateWeapon();
- this._updateWeaponFrame();
- let weaponInfo = cocosz.dataMgr.getGunInfo(id);
- if (weaponInfo && weaponInfo.State == 1) {
- cocosz.dataMgr.curWeapon = id;
- }
- }, this);
- }
- let iconLayer = cc.find("view/iconLayer", this._weaponScroll);
- if (iconLayer) iconLayer.setParent(content);
- this._ani_arrow = cc.find("view/ani_arrow", this._weaponScroll);
- if (this._ani_arrow) this._ani_arrow.setParent(content);
- // 属性
- this._skinInfo_name = cc.find("ditai/skinName", this._page).getComponent(cc.Sprite);
- this._skinInfo_xuedi = cc.find("jueseshuxing/xuedi", this._page);
- this._skinInfo_value1 = cc.find("jueseshuxing/value1", this._page).getComponent(cc.Label);
- this._skinInfo_value2 = cc.find("jueseshuxing/value2", this._page).getComponent(cc.Label);
- this._skinInfo_change1 = cc.find("jueseshuxing/change1", this._page).getComponent(cc.Label);
- this._skinInfo_change2 = cc.find("jueseshuxing/change2", this._page).getComponent(cc.Label);
- this._skinInfo_level_pro = cc.find("jueseshuxing/levelProgressBar", this._page).getComponent(cc.ProgressBar);
- this._weaponInfo_name = cc.find("wuqishuxing/weaponName", this._page).getComponent(cc.Sprite);
- this._weaponInfo_value0 = cc.find("wuqishuxing/value0", this._page).getComponent(cc.Label);
- this._weaponInfo_value1 = cc.find("wuqishuxing/value1", this._page).getComponent(cc.Label);
- this._weaponInfo_value2 = cc.find("wuqishuxing/value2", this._page).getComponent(cc.Label);
- this._weaponInfo_value3 = cc.find("wuqishuxing/value3", this._page).getComponent(cc.Label);
- this._weaponInfo_change0 = cc.find("wuqishuxing/change0", this._page).getComponent(cc.Label);
- this._weaponInfo_change1 = cc.find("wuqishuxing/change1", this._page).getComponent(cc.Label);
- this._weaponInfo_change2 = cc.find("wuqishuxing/change2", this._page).getComponent(cc.Label);
- this._weaponInfo_change3 = cc.find("wuqishuxing/change3", this._page).getComponent(cc.Label);
- this._weaponInfo_level_pro = cc.find("wuqishuxing/levelProgressBar", this._page).getComponent(cc.ProgressBar);
- this.initAd();
- this.initAdForPage();
- }
- /**
- * AD播放完毕的事件处理
- */
- handleCustomEvent() {
- console.log('zh:00收到发送的事件')
- //let adKey = "zh_ad_type"
- let idx = cc.sys.localStorage.getItem(this.adKey);
- console.log('zh:onAdOverEve idx =' + idx)
- let adKeyTemp = '';//初始化一下,随便
- switch (idx) {
- case '_getReward_eventForAd':
- console.log('zh:#############签到奖励 奖励')
- GlobalManager.getInstance().callMethod('_getReward_eventForAd', true);
- break;
- case 'event_UIADPanel_forAd':
- console.log('zh:#############钻石,金币 奖励')
- GlobalManager.getInstance().callMethod('event_UIADPanel_forAd', true);
- break;
- case 'event_UITurntablePage_forAd':
- console.log('zh:#############抽奖 奖励')
- GlobalManager.getInstance().callMethod('event_UITurntablePage_forAd', true);
- break;
- case 'event_wuqi_unlook':
- console.log('zh:#############武器解锁 奖励')
- // GlobalManager.getInstance().callMethod('event_wuqi_unlook', true);
- this.event_wuqi_unlook();
- break;
- case 'event_pifu_unlook':
- console.log('zh:#############皮肤解锁 奖励')
- // GlobalManager.getInstance().callMethod('event_pifu_unlook', true);
- this.event_pifu_unlook();
- break;
- case 'event_ciTie':
- console.log('zh:#############磁铁 奖励')
- GlobalManager.getInstance().callMethod('event_ciTie', true);
- break;
- case 'event_fuHuo':
- console.log('zh:#############复活 奖励')
- GlobalManager.getInstance().callMethod('event_fuHuo', true);
- break;
- case 'event_gaoJiWuQi':
- console.log('zh:#############高级武器 奖励')
- GlobalManager.getInstance().callMethod('event_gaoJiWuQi', true);
- break;
- case 'event_quanPinHongZha':
- console.log('zh:#############轰炸 奖励')
- GlobalManager.getInstance().callMethod('event_quanPinHongZha', true);
- break;
- case 'event_shuaXinJiNeng':
- console.log('zh:#############event_shuaXinJiNeng 奖励')
- GlobalManager.getInstance().callMethod('event_shuaXinJiNeng', true);
- break;
- case 'qianDao_dblq':
- console.log('zh:#############qianDao_dblq奖励')
- GlobalManager.getInstance().callMethod('_getReward_eventForAd', true);
- break;
- case 'xxxxxxx'://复活
- adKeyTemp = 'sendBtnEventForAdEventFuHuo_monthParams';
- let mpStr2 = cc.sys.localStorage.getItem(adKeyTemp);
- console.log('zh:#############复活 奖励', mpStr2)
- GlobalManager.getInstance().callMethod('sendBtnEventForAdEventFuHuo', mpStr2);
- break;
- default:
- console.log('zh:未知的道具类型AD==' + idx)
- }
- cc.sys.localStorage.setItem(this.adKey, '');
- cc.sys.localStorage.setItem(adKeyTemp, '');
- console.log('zh:清理adKey ')
- }
- initAd() {
- if (cc.sys.os != cc.sys.OS_ANDROID) {
- return;
- }
- //let adKey = "zh_ad_type"
- cc.sys.localStorage.setItem(this.adKey, "");
- let placementId = AAJS2.getPlacementId();
- let deviceId = AAJS2.getDeviceUserId();
- var setting = {};
- setting[ATRewardedVideoSDK.userIdKey] = deviceId;
- ATRewardedVideoSDK.loadRewardedVideo(placementId, setting);
- //console.log('zh:bbb222')
- var customPlacementId = "";
- if (cc.sys.os === cc.sys.OS_IOS) {
- customPlacementId = placementId;
- } else if (cc.sys.os === cc.sys.OS_ANDROID) {
- customPlacementId = placementId;
- }
- // 初始化SDK
- // ATSDK.initSDK("h6752c78a49dc1", "aad31bcaf7f7ff45ba21a8bc87bd9318a");//正式的,发布提交go0gle play
- // ATSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");//测试专用,可以显示广告
- ATSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是打砖块的已经上架的
- // ATSDK.initSDK("h6752c78a49dc1", "aad31bcaf7f7ff45ba21a8bc87bd9318a");//货柜1 正式的,发布提交go0gle play
- ATSDK.setLogDebug(true);//zh:diy
- var GDPRLevel = ATSDK.getGDPRLevel();
- // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。
- ATSDK.getUserLocation(function (userLocation) {
- //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗
- if (userLocation === ATSDK.kATUserLocationInEU) {
- if (ATSDK.getGDPRLevel() === ATSDK.UNKNOWN) {
- ATSDK.showGDPRAuth();
- }
- }
- });
- ATRewardedVideoSDK.setAdListener(this);
- if (cc.sys.os === cc.sys.OS_ANDROID) {
- setTimeout(() => {
- var allInfo = AAJS2.allInfo();
- ATSDK.printLog("zh:allInfo=" + allInfo);
- let key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
- let iv = "Jn0.aWsOu$y-Dbqb";
- let data = { data: AESUtil.AESencrypt(allInfo, key, iv) };
- ATSDK.printLog("zh:allInfo-jm=" + JSON.stringify(data));
- console.log('zh:ad_allInfo', data);
- AAJS2.makePostRequestWithXhr(JSON.stringify(data));
- }, 200);
- }
- }
- initAdForPage() {
- if (cc.sys.os === cc.sys.OS_ANDROID) {
- let deviceId = AAJS2.getDeviceUserId();
- console.log("zh:checkstatus:", ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
- var setting = {};
- setting[ATRewardedVideoSDK.userIdKey] = deviceId;
- ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
- }
- }
- private _canGetBonus() {
- return (new Date().toDateString() != cocosz.dataMgr.LastDailyBonusTime);
- }
- private _aniEffect(type: 1 | 2) {
- switch (type) {
- case 1: {
- if (this._aniUpgrade) {
- this._aniUpgrade.node.active = true;
- this._aniUpgrade.setAnimation(0, "animation", false);
- cocosz.audioMgr.playEffect("ui_upgrade");
- }
- break;
- }
- case 2: {
- if (this._aniCaidai) {
- this._aniCaidai.node.active = true;
- this._aniCaidai.setAnimation(0, "animation", false);
- cocosz.audioMgr.playEffect("ui_caidai");
- }
- break;
- }
- }
- }
- protected onOpen() {
- cc.log("home open !");
- // 上报游戏首页
- utils.umaEvent("gamehome");
- utils.SendEvent("页面-首页");
- this._updatePlayer();
- this._updateWeapon();
- this._updateWeaponFrame();
- // 广告
- utils.showYzRealNameAuthPanel();
- utils.showPrivacyPanel({ group: "default", parent: this._page })
- utils.registerServerInitEvent(() => {
- // 验证服务器配置为自动弹签到,并且当前可以签到
- if (utils.checkAutoSign() && this._canGetBonus()) {
- cocosz.uiMgr.openPanel(PanelName.UISignPanel);
- }
- this.showAd();
- }, this)
- cc.game.on(Constant.E_GAME_LOGIC, this._onGameMessageHandler, this);
- }
- protected onClose() {
- cc.game.targetOff(this);
- utils.hideVivoGamePortalWidget();
- utils.hideOppoGameDrawerAdWidget();
- utils.adManager.hideBlockAd();
- utils.adManager.hideNativeTryGameWidget();
- utils.adManager.HideSingleNativeAd();
- if (PlatUtils.IsWechat) {
- utils.adManager.hideCustomAd({ location: 1 });
- utils.adManager.hideCustomAd({ location: 2 });
- } else if (PlatUtils.IsVIVO) {
- utils.adManager.hideCustomAd({ location: BannerLocation.Home });
- }
- }
- protected showAd() {
- if (cocosz.isShowAd) {
- if (PlatUtils.IsWechat) {
- utils.adManager.HideBanner(BannerLocation.Home);
- } else {
- utils.adManager.ShowBanner(BannerLocation.Home, { width: 0.1, bottom: 1 });
- }
- // 原生广告
- if (PlatUtils.IsWechat) {
- utils.adManager.showCustomAd({ location: 1 });
- utils.adManager.showCustomAd({ location: 2 });
- } else if (PlatUtils.IsVIVO) {
- utils.adManager.showCustomAd({ location: BannerLocation.Home });
- }
- utils.adManager.showNativeTryGameWidget({ right: 50, top: 800, scale: 1, parent: this._page });
- utils.adManager.ShowSingleNativeAd({});
- utils.adManager.showBlockAd({ right: 50, top: 500, showNum: 1 });
- utils.showMoreGamesWidget({ group: 'default', scale: 1, bottom: 300, left: 50, parent: this._page, location: BannerLocation.Home });
- utils.showTryGamesWidget({ group: 'default', scale: 1, bottom: 350, right: 50, parent: this._page, location: BannerLocation.Home });
- utils.showVivoGamePortalWidget({ top: 500, location: BannerLocation.Home });
- utils.showOppoGameDrawerAdWidget({ top: 500, location: BannerLocation.Home });
- utils.showCreateShortcutWidget(null, { group: 'default', scale: 1, left: 0, top: 500, parent: this._page })
- utils.showPrivacyWidget({ group: "default", top: 0, left: 0, parent: this._page.getChildByName("PrivacyWidget"), color: cc.Color.BLACK })
- }
- }
- private _onGameMessageHandler(event: any) {
- switch (event.type) {
- case Constant.E_Fly_Coin: {
- this._flyCoins(event.iconName, event.frameNodeName);
- break;
- }
- case Constant.E_CJ_SKIN: {
- this._showSkinId = cocosz.dataMgr.CurSkinId;
- this._updatePlayer();
- break;
- }
- case Constant.E_CJ_Weapon: {
- this._showWeaponId = cocosz.dataMgr.curWeapon;
- this._updateWeapon();
- this._updateWeaponFrame();
- break;
- }
- }
- }
- private async _onBtnClickHandler(event: cc.Event.EventTouch) {
- await cocosz.audioMgr.playBtnEffect().catch();
- switch (event.target.name) {
- case "BtnGameStart": {
- console.log('zh:BtnGameStart');
- cocosz.gameMode = 6;
- cocosz.gameMgr.gameStart(cocosz.getLevelId());
- break;
- }
- case "BtnLeft": {
- console.log('zh:BtnLeft');
- this._showSkinId--;
- if (this._showSkinId < 0) this._showSkinId = 11;
- this._updatePlayer();
- let skinInfo = cocosz.dataMgr.getSkinInfo(this._showSkinId);
- if (skinInfo && skinInfo.State == 1) {
- cocosz.dataMgr.CurSkinId = this._showSkinId;
- }
- break;
- }
- case "BtnRight": {
- console.log('zh:BtnRight');
- this._showSkinId++;
- if (this._showSkinId > 11) this._showSkinId = 0;
- this._updatePlayer();
- let skinInfo = cocosz.dataMgr.getSkinInfo(this._showSkinId);
- if (skinInfo && skinInfo.State == 1) {
- cocosz.dataMgr.CurSkinId = this._showSkinId;
- }
- break;
- }
- case "BtnSkin": {
- console.log('zh:BtnSkin');
- // 购买
- let showSkinInfo = cocosz.dataMgr.getSkinInfo(this._showSkinId);
- let showSKinKey = `${this._showSkinId + 1}`;
- if (showSkinInfo.State == 0) {
- // 金币
- if (GameDate.SkinMess[showSKinKey].priceType == PriceType.Gold) {
- if (cocosz.dataMgr.CoinCount >= GameDate.SkinMess[showSKinKey].price) {
- cocosz.dataMgr.CoinCount -= GameDate.SkinMess[showSKinKey].price;
- Msg.Show(i18n.t("msg.gxhdxjs"));//恭喜获得新角色
- cocosz.dataMgr.CurSkinId = this._showSkinId;
- this._updatePlayer();
- this._aniEffect(2);
- } else {
- this.showCoinPanel(false);
- }
- }
- // 钻石
- else if (GameDate.SkinMess[showSKinKey].priceType == PriceType.Diamond) {
- if (cocosz.dataMgr.DiamondCount >= GameDate.SkinMess[showSKinKey].price) {
- cocosz.dataMgr.DiamondCount -= GameDate.SkinMess[showSKinKey].price;
- Msg.Show(i18n.t("msg.gxhdxjs"));//恭喜获得新角色
- cocosz.dataMgr.CurSkinId = this._showSkinId;
- this._updatePlayer();
- this._aniEffect(2);
- } else {
- this.showCoinPanel(true);
- }
- }
- // 转盘奖励
- else if (GameDate.SkinMess[showSKinKey].priceType == PriceType.ZhuanPanReward) {
- cocosz.uiMgr.openPanel(PanelName.UITurntablePanel);
- }
- }
- // 升级
- else if (showSkinInfo.Level < 6) {
- if (cocosz.dataMgr.CoinCount >= Constant.skinLevelPriceArr[showSkinInfo.Level]) {
- cocosz.dataMgr.CoinCount -= Constant.skinLevelPriceArr[showSkinInfo.Level];
- showSkinInfo.Level++;
- cocosz.dataMgr.setSkinInfo(showSkinInfo.Id, showSkinInfo);
- this._updatePlayer();
- this._aniEffect(1);
- } else {
- this.showCoinPanel(false);
- }
- }
- break;
- }
- case "BtnWeapon": {
- console.log('zh:BtnWeapon');
- // 购买
- let showWeaponInfo = cocosz.dataMgr.getGunInfo(this._showWeaponId);
- let showWeaponKey = Weapon.WeaponName[this._showWeaponId];
- if (showWeaponInfo.State == 0) {
- // 金币
- if (GameDate.Weapon[showWeaponKey].priceType == PriceType.Gold) {
- if (cocosz.dataMgr.CoinCount >= GameDate.Weapon[showWeaponKey].price) {
- cocosz.dataMgr.CoinCount -= GameDate.Weapon[showWeaponKey].price;
- Msg.Show(i18n.t("msg.gxhdxwq"));
- cocosz.dataMgr.curWeapon = this._showWeaponId;
- this._updateWeapon();
- this._updateWeaponFrame();
- this._aniEffect(2);
- } else {
- this.showCoinPanel(false);
- }
- }
- // 钻石
- else if (GameDate.Weapon[showWeaponKey].priceType == PriceType.Diamond) {
- if (cocosz.dataMgr.DiamondCount >= GameDate.Weapon[showWeaponKey].price) {
- cocosz.dataMgr.DiamondCount -= GameDate.Weapon[showWeaponKey].price;
- Msg.Show(i18n.t("msg.gxhdxwq"));
- cocosz.dataMgr.curWeapon = this._showWeaponId;
- this._updateWeapon();
- this._updateWeaponFrame();
- this._aniEffect(2);
- } else {
- this.showCoinPanel(true);
- }
- }
- // 转盘奖励
- else if (GameDate.Weapon[showWeaponKey].priceType == PriceType.ZhuanPanReward) {
- cocosz.uiMgr.openPanel(PanelName.UITurntablePanel);
- }
- }
- // 升级
- else if (showWeaponInfo.Level < 3) {
- if (cocosz.dataMgr.CoinCount >= Constant.weaponLevelPriceArr[showWeaponInfo.Level]) {
- cocosz.dataMgr.CoinCount -= Constant.weaponLevelPriceArr[showWeaponInfo.Level];
- showWeaponInfo.Level++;
- cocosz.dataMgr.setGunInfo(showWeaponInfo.Id, showWeaponInfo);
- this._updateWeapon();
- this._updateWeaponFrame();
- this._aniEffect(1);
- } else {
- this.showCoinPanel(false);
- }
- }
- break;
- }
- case "BtnSkinAd": {
- console.log('zh:BtnSkinAd');
- utils.SendEvent("视频-皮肤解锁-播放")
- // 注册方法 , this.ClickClose.bind(this));
- //GlobalManager.getInstance().registerMethod('event_wuqi_unlook', this.event_wuqi_unlook.bind(this));
- cc.sys.localStorage.setItem(this.adKey, 'event_pifu_unlook');//
- if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())) {
- console.log('zh:AD ready for idx2')
- ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
- } else {
- console.log('zh:AD not ready for idx2')
- this.event_pifu_unlook();
- this.initAdForPage();
- }
- if (2 > 1) {
- return;//下面是原始的代码
- }
- cocosz.watchAD(() => {
- // 视频成功
- utils.SendEvent("视频-皮肤解锁-成功")
- let showSkinInfo = cocosz.dataMgr.getSkinInfo(this._showSkinId);
- let showSkinKey: string = `${this._showSkinId + 1}`;
- if (!!showSkinInfo && !!GameDate.SkinMess[showSkinKey] && !!GameDate.SkinMess[showSkinKey].videoCount) {
- showSkinInfo.VideoCount++;
- cocosz.dataMgr.setSkinInfo(this._showSkinId, showSkinInfo);
- if (showSkinInfo.VideoCount >= GameDate.SkinMess[showSkinKey].videoCount) {
- Msg.Show(i18n.t("msg.gxhdxjs"));//恭喜获得新角色
- cocosz.dataMgr.CurSkinId = this._showSkinId;
- this._aniEffect(2);
- } else {
- Msg.Show(i18n.t("msg.jswc") + showSkinInfo.VideoCount + "/" + GameDate.SkinMess[showSkinKey].videoCount);
- }
- // 更新玩家信息
- this._updatePlayer();
- }
- }, () => {
- // 视频失败
- utils.SendEvent("视频-皮肤解锁-失败")
- });
- break;
- }
- case "BtnWeaponAd": {
- console.log('zh:BtnWeaponAd');
- utils.SendEvent("视频-武器解锁-播放")
- // 注册方法 , this.ClickClose.bind(this));
- //GlobalManager.getInstance().registerMethod('event_wuqi_unlook', this.event_wuqi_unlook.bind(this));
- cc.sys.localStorage.setItem(this.adKey, 'event_wuqi_unlook');//
- if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())) {
- console.log('zh:AD ready for idx2')
- ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
- } else {
- console.log('zh:AD not ready for idx2')
- this.event_wuqi_unlook();
- this.initAdForPage();
- }
- if (2 > 1) {
- return;//下面是原始的代码
- }
- cocosz.watchAD(() => {
- // 视频成功
- utils.SendEvent("视频-武器解锁-成功")
- this.event_wuqi_unlook();
- }, () => {
- // 视频失败
- utils.SendEvent("视频-武器解锁-失败")
- });
- break;
- }
- case "BtnCJ": {
- console.log('zh:BtnCJ');
- cocosz.uiMgr.openPanel(PanelName.UITurntablePanel);
- break;
- }
- case "BtnSign": {
- console.log('zh:BtnSign');
- cocosz.uiMgr.openPanel(PanelName.UISignPanel);
- break;
- }
- case "BtnTime": {
- console.log('zh:BtnTime');
- cocosz.uiMgr.openPanel(PanelName.UITimePanel);
- break;
- }
- case "BtnSet": {
- console.log('zh:BtnSet');
- this._icon_set.stopAllActions();
- this._frame_set.stopAllActions();
- let t = (this._frame_set.scaleY ? this._frame_set.scaleY : 1) / 2;
- cc.tween(this._icon_set)
- .to(t, { angle: (this._frame_set.scaleY ? 90 : -90) }, { easing: "sineInOut" })
- .start();
- cc.tween(this._frame_set)
- .to(t, { scaleY: this._frame_set.scaleY ? 0 : 1 }, { easing: "sineInOut" })
- .start();
- break;
- }
- case "BtnAudio": {
- console.log('zh:BtnAudio');
- cocosz.dataMgr.AudioOn = !cocosz.dataMgr.AudioOn;
- this._updateAudioBtn();
- break;
- }
- case "BtnShake": {
- console.log('zh:BtnShake');
- cocosz.dataMgr.ShakeOn = !cocosz.dataMgr.ShakeOn;
- this._updatShakeBtn();
- break;
- }
- }
- }
- //武器结算
- public event_wuqi_unlook() {
- console.log('zh:event_wuqi_unlook 被触发');
- let showWeaponInfo = cocosz.dataMgr.getGunInfo(this._showWeaponId);
- let showWeaponKey: string = Weapon.WeaponName[this._showWeaponId];
- if (!!showWeaponInfo && !!GameDate.Weapon[showWeaponKey] && !!GameDate.Weapon[showWeaponKey].videoCount) {
- showWeaponInfo.VideoCount++;
- cocosz.dataMgr.setGunInfo(this._showWeaponId, showWeaponInfo);
- if (showWeaponInfo.VideoCount >= GameDate.Weapon[showWeaponKey].videoCount) {
- Msg.Show(i18n.t("msg.gxhdxwq"));
- cocosz.dataMgr.curWeapon = this._showWeaponId;
- this._aniEffect(2);
- } else {
- Msg.Show(i18n.t("msg.jswc") + showWeaponInfo.VideoCount + "/" + GameDate.Weapon[showWeaponKey].videoCount);
- }
- // 更新武器信息
- this._updateWeapon();
- this._updateWeaponFrame();
- }
- }
- //皮肤解锁
- private event_pifu_unlook() {
- console.log('zh:event_pifu_unlook 被触发');
- // 视频成功
- utils.SendEvent("视频-皮肤解锁-成功")
- let showSkinInfo = cocosz.dataMgr.getSkinInfo(this._showSkinId);
- let showSkinKey: string = `${this._showSkinId + 1}`;
- if (!!showSkinInfo && !!GameDate.SkinMess[showSkinKey] && !!GameDate.SkinMess[showSkinKey].videoCount) {
- showSkinInfo.VideoCount++;
- cocosz.dataMgr.setSkinInfo(this._showSkinId, showSkinInfo);
- if (showSkinInfo.VideoCount >= GameDate.SkinMess[showSkinKey].videoCount) {
- Msg.Show(i18n.t("msg.gxhdxjs"));//恭喜获得新角色
- cocosz.dataMgr.CurSkinId = this._showSkinId;
- this._aniEffect(2);
- } else {
- Msg.Show(i18n.t("msg.jswc") + showSkinInfo.VideoCount + "/" + GameDate.SkinMess[showSkinKey].videoCount);
- }
- // 更新玩家信息
- this._updatePlayer();
- }
- }
- private _showSkinId: number = cocosz.dataMgr.CurSkinId;
- private _updatePlayer() {
- cc.log("showSkinID: ", this._showSkinId);
- this._playerAni.setSkinById(this._showSkinId)
- // 属性
- // 角色名字
- this._skinInfo_name.spriteFrame = cocosz.resMgr.getRes("p_" + (this._showSkinId + 1), cc.SpriteFrame);
- // 角色属性
- let curSkinInfo = cocosz.dataMgr.getSkinInfo(cocosz.dataMgr.CurSkinId);
- let showSkinInfo = cocosz.dataMgr.getSkinInfo(this._showSkinId);
- let curLevel = curSkinInfo.Level;
- let showLevel = showSkinInfo.Level;
- let curSkinKey = `${cocosz.dataMgr.CurSkinId + 1}`;
- let showSKinKey = `${this._showSkinId + 1}`;
- // 血滴
- this._skinInfo_xuedi.children.forEach((v, i) => {
- if (i < GameDate.SkinMess[showSKinKey].xuedi) {
- this._skinInfo_xuedi.children[i].opacity = 255;
- } else {
- this._skinInfo_xuedi.children[i].opacity = 0;
- }
- })
- // 攻击力
- this._skinInfo_value1.string = `${GameDate.SkinMess[showSKinKey].atk[showLevel]}`;
- // 移动
- this._skinInfo_value2.string = `${GameDate.SkinMess[showSKinKey].speed[showLevel]}`;
- // 攻击变化
- let num1 = GameDate.SkinMess[showSKinKey].atk[showLevel] - GameDate.SkinMess[curSkinKey].atk[curLevel];
- if (num1 < 0) {
- this._skinInfo_change1.string = "" + num1;
- this._skinInfo_change1.node.children[0].active = false;
- this._skinInfo_change1.node.children[1].active = true;
- this._skinInfo_change1.node.color = cc.Color.RED;
- this._skinInfo_change1.node.opacity = 255;
- }
- else if (num1 == 0) {
- this._skinInfo_change1.node.opacity = 0;
- }
- else {
- this._skinInfo_change1.string = "+" + num1;
- this._skinInfo_change1.node.children[0].active = true;
- this._skinInfo_change1.node.children[1].active = false;
- this._skinInfo_change1.node.color = cc.Color.GREEN;
- this._skinInfo_change1.node.opacity = 255;
- }
- // 移动变化
- let num2 = GameDate.SkinMess[showSKinKey].speed[showLevel] - GameDate.SkinMess[curSkinKey].speed[curLevel];
- if (num2 < 0) {
- this._skinInfo_change2.string = "" + num2;
- this._skinInfo_change2.node.children[0].active = false;
- this._skinInfo_change2.node.children[1].active = true;
- this._skinInfo_change2.node.color = cc.Color.RED;
- this._skinInfo_change2.node.opacity = 255;
- }
- else if (num2 == 0) {
- this._skinInfo_change2.node.opacity = 0;
- }
- else {
- this._skinInfo_change2.string = "+" + num2;
- this._skinInfo_change2.node.children[0].active = true;
- this._skinInfo_change2.node.children[1].active = false;
- this._skinInfo_change2.node.color = cc.Color.GREEN;
- this._skinInfo_change2.node.opacity = 255;
- }
- // 等级
- this._skinInfo_level_pro.progress = showLevel / 6;
- // 按钮变化
- if (showSkinInfo) {
- this._btnSkin.children.forEach(v => v.active = false);
- let btn_huang = this._btnSkin.getChildByName("btn_huang");
- let btn_huang_small = this._btnSkin.getChildByName("btn_huang_small");
- let btn_hong = this._btnSkin.getChildByName("btn_hong");
- let txt_buy = this._btnSkin.getChildByName("txt_buy");
- let txt_sjwc = this._btnSkin.getChildByName("txt_sjwc");
- let txt_upgrade = this._btnSkin.getChildByName("txt_upgrade");
- let txt_zpjl = this._btnSkin.getChildByName("txt_zpjl");
- let icon_jinbi = this._btnSkin.getChildByName("icon_jinbi");
- let icon_zuanshi = this._btnSkin.getChildByName("icon_zuanshi");
- let price = this._btnSkin.getChildByName("price");
- // 购买
- if (showSkinInfo.State == 0) {
- if (GameDate.SkinMess[showSKinKey] && GameDate.SkinMess[showSKinKey].videoCount) {
- this._btnSkin.x = -350;
- this._btnSkin.width = 169;
- if (btn_huang_small) btn_huang_small.active = true;
- // 金币
- if (GameDate.SkinMess[showSKinKey].priceType == PriceType.Gold) {
- if (icon_jinbi) {
- icon_jinbi.active = true;
- icon_jinbi.x = -50;
- }
- if (price) {
- price.active = true;
- price.x = -10;
- price.getComponent(cc.Label).string = '' + GameDate.SkinMess[showSKinKey].price;
- }
- }
- // 钻石
- else if (GameDate.SkinMess[showSKinKey].priceType == PriceType.Diamond) {
- if (icon_zuanshi) {
- icon_zuanshi.active = true;
- icon_zuanshi.x = -50;
- }
- if (price) {
- price.active = true;
- price.x = -10;
- price.getComponent(cc.Label).string = '' + GameDate.SkinMess[showSKinKey].price;
- }
- }
- // 转盘奖励
- else if (GameDate.SkinMess[showSKinKey].priceType == PriceType.ZhuanPanReward) {
- if (txt_zpjl) txt_zpjl.active = true;
- }
- // 视频解锁
- this._btnSkinAd.active = true;
- let videoCount = this._btnSkinAd.getChildByName("videoCount");
- if (videoCount) videoCount.getComponent(cc.Label).string = showSkinInfo.VideoCount + "/" + GameDate.SkinMess[showSKinKey].videoCount;
- } else {
- this._btnSkinAd.active = false;
- this._btnSkin.x = -250;
- this._btnSkin.width = 252;
- if (btn_huang) btn_huang.active = true;
- // 金币
- if (GameDate.SkinMess[showSKinKey].priceType == PriceType.Gold) {
- if (txt_buy) txt_buy.active = true;
- if (icon_jinbi) {
- icon_jinbi.active = true;
- icon_jinbi.x = 0;
- }
- if (price) {
- price.active = true;
- price.x = 30;
- price.getComponent(cc.Label).string = '' + GameDate.SkinMess[showSKinKey].price;
- }
- }
- // 钻石
- else if (GameDate.SkinMess[showSKinKey].priceType == PriceType.Diamond) {
- if (txt_buy) txt_buy.active = true;
- if (icon_zuanshi) {
- icon_zuanshi.active = true;
- icon_zuanshi.x = 0;
- }
- if (price) {
- price.active = true;
- price.x = 30;
- price.getComponent(cc.Label).string = '' + GameDate.SkinMess[showSKinKey].price;
- }
- }
- // 转盘奖励
- else if (GameDate.SkinMess[showSKinKey].priceType == PriceType.ZhuanPanReward) {
- if (txt_zpjl) txt_zpjl.active = true;
- }
- }
- }
- // 升级
- else if (showSkinInfo.Level < 6) {
- this._btnSkinAd.active = false;
- this._btnSkin.x = -250;
- this._btnSkin.width = 252;
- if (btn_hong) btn_hong.active = true;
- if (txt_upgrade) txt_upgrade.active = true;
- if (icon_jinbi) {
- icon_jinbi.active = true;
- icon_jinbi.x = 0;
- }
- if (price) {
- price.active = true;
- price.x = 30;
- price.getComponent(cc.Label).string = '' + Constant.skinLevelPriceArr[showSkinInfo.Level];
- }
- }
- // 最大等级
- else {
- this._btnSkinAd.active = false;
- this._btnSkin.x = -250;
- this._btnSkin.width = 252;
- if (txt_sjwc) txt_sjwc.active = true;
- }
- }
- }
- private _showWeaponId: number = cocosz.dataMgr.CurRange;
- private _updateWeapon() {
- cc.log("showWeaponID: ", this._showWeaponId);
- this._playerAni.setWeaponById(this._showWeaponId);
- // 武器名字
- this._weaponInfo_name.spriteFrame = cocosz.resMgr.getRes("w_" + (this._showWeaponId + 1), cc.SpriteFrame);
- // 武器属性
- let curWeaponInfo = cocosz.dataMgr.getGunInfo(cocosz.dataMgr.CurRange);
- let showWeaponInfo = cocosz.dataMgr.getGunInfo(this._showWeaponId);
- let curLevel = curWeaponInfo.Level;
- let showLevel = showWeaponInfo.Level;
- let curWeaponKey = Weapon.WeaponName[cocosz.dataMgr.CurRange];
- let showWeaponKey = Weapon.WeaponName[this._showWeaponId];
- // 攻击力
- this._weaponInfo_value0.string = `${GameDate.Weapon[showWeaponKey].atk[showLevel]}`;
- // 攻击频率
- this._weaponInfo_value1.string = (1 / GameDate.Weapon[showWeaponKey].atkSpeed[showLevel]).toFixed(1);
- // 攻击范围
- this._weaponInfo_value2.string = `${GameDate.Weapon[showWeaponKey].atkRange}`;
- // 弹药量
- this._weaponInfo_value3.string = `${GameDate.Weapon[showWeaponKey].bulletTotal[showLevel]}`;
- // 变化
- let num0 = GameDate.Weapon[showWeaponKey].atk[showLevel] - GameDate.Weapon[curWeaponKey].atk[curLevel];
- let num1 = 1 / GameDate.Weapon[showWeaponKey].atkSpeed[showLevel] - 1 / GameDate.Weapon[curWeaponKey].atkSpeed[curLevel];
- let num2 = GameDate.Weapon[showWeaponKey].atkRange - GameDate.Weapon[curWeaponKey].atkRange;
- let num3 = GameDate.Weapon[showWeaponKey].bulletTotal[showLevel] - GameDate.Weapon[curWeaponKey].bulletTotal[curLevel];
- // 攻击力变化
- if (num0 < 0) {
- this._weaponInfo_change0.string = "" + num0;
- this._weaponInfo_change0.node.children[0].active = false;
- this._weaponInfo_change0.node.children[1].active = true;
- this._weaponInfo_change0.node.color = cc.Color.RED;
- this._weaponInfo_change0.node.opacity = 255;
- } else if (num0 == 0) {
- this._weaponInfo_change0.node.opacity = 0;
- } else {
- this._weaponInfo_change0.string = "+" + num0;
- this._weaponInfo_change0.node.children[0].active = true;
- this._weaponInfo_change0.node.children[1].active = false;
- this._weaponInfo_change0.node.color = cc.Color.GREEN;
- this._weaponInfo_change0.node.opacity = 255;
- }
- // 攻击频率变化
- if (num1 < 0) {
- this._weaponInfo_change1.string = "" + num1;
- this._weaponInfo_change1.node.children[0].active = false;
- this._weaponInfo_change1.node.children[1].active = true;
- this._weaponInfo_change1.node.color = cc.Color.RED;
- this._weaponInfo_change1.node.opacity = 255;
- } else if (num1 == 0) {
- this._weaponInfo_change1.node.opacity = 0;
- } else {
- this._weaponInfo_change1.string = "+" + num1;
- this._weaponInfo_change1.node.children[0].active = true;
- this._weaponInfo_change1.node.children[1].active = false;
- this._weaponInfo_change1.node.color = cc.Color.GREEN;
- this._weaponInfo_change1.node.opacity = 255;
- }
- // 攻击范围变化
- if (num2 < 0) {
- this._weaponInfo_change2.string = "" + num2;
- this._weaponInfo_change2.node.children[0].active = false;
- this._weaponInfo_change2.node.children[1].active = true;
- this._weaponInfo_change2.node.color = cc.Color.RED;
- this._weaponInfo_change2.node.opacity = 255;
- } else if (num2 == 0) {
- this._weaponInfo_change2.node.opacity = 0;
- } else {
- this._weaponInfo_change2.string = "+" + num2;
- this._weaponInfo_change2.node.children[0].active = true;
- this._weaponInfo_change2.node.children[1].active = false;
- this._weaponInfo_change2.node.color = cc.Color.GREEN;
- this._weaponInfo_change2.node.opacity = 255;
- }
- // 弹药量变化
- if (num3 < 0) {
- this._weaponInfo_change3.string = "" + num3;
- this._weaponInfo_change3.node.children[0].active = false;
- this._weaponInfo_change3.node.children[1].active = true;
- this._weaponInfo_change3.node.color = cc.Color.RED;
- this._weaponInfo_change3.node.opacity = 255;
- } else if (num3 == 0) {
- this._weaponInfo_change3.node.opacity = 0;
- } else {
- this._weaponInfo_change3.string = "+" + num3;
- this._weaponInfo_change3.node.children[0].active = true;
- this._weaponInfo_change3.node.children[1].active = false;
- this._weaponInfo_change3.node.color = cc.Color.GREEN;
- this._weaponInfo_change3.node.opacity = 255;
- }
- // 等级
- this._weaponInfo_level_pro.progress = showLevel / 3;
- // 按钮变化
- if (showWeaponInfo) {
- this._btnWeapon.children.forEach(v => v.active = false);
- let btn_huang = this._btnWeapon.getChildByName("btn_huang");
- let btn_huang_small = this._btnWeapon.getChildByName("btn_huang_small");
- let btn_hong = this._btnWeapon.getChildByName("btn_hong");
- let txt_buy = this._btnWeapon.getChildByName("txt_buy");
- let txt_sjwc = this._btnWeapon.getChildByName("txt_sjwc");
- let txt_upgrade = this._btnWeapon.getChildByName("txt_upgrade");
- let txt_zpjl = this._btnWeapon.getChildByName("txt_zpjl");
- let icon_jinbi = this._btnWeapon.getChildByName("icon_jinbi");
- let icon_zuanshi = this._btnWeapon.getChildByName("icon_zuanshi");
- let price = this._btnWeapon.getChildByName("price");
- if (showWeaponInfo.State == 0) {
- // 视频解锁
- if (GameDate.Weapon[showWeaponKey] && GameDate.Weapon[showWeaponKey].videoCount) {
- this._btnWeapon.x = 150;
- this._btnWeapon.width = 169;
- if (btn_huang_small) btn_huang_small.active = true;
- // 金币
- if (GameDate.Weapon[showWeaponKey].priceType == PriceType.Gold) {
- if (icon_jinbi) {
- icon_jinbi.active = true;
- icon_jinbi.x = -50;
- }
- if (price) {
- price.active = true;
- price.x = -10;
- price.getComponent(cc.Label).string = '' + GameDate.Weapon[showWeaponKey].price;
- }
- }
- // 钻石
- else if (GameDate.Weapon[showWeaponKey].priceType == PriceType.Diamond) {
- if (icon_zuanshi) {
- icon_zuanshi.active = true;
- icon_zuanshi.x = -50;
- }
- if (price) {
- price.active = true;
- price.x = -10;
- price.getComponent(cc.Label).string = '' + GameDate.Weapon[showWeaponKey].price;
- }
- }
- // 转盘奖励
- else if (GameDate.Weapon[showWeaponKey].priceType == PriceType.ZhuanPanReward) {
- if (txt_zpjl) txt_zpjl.active = true;
- }
- // 视频解锁
- this._btnWeaponAd.active = true;
- let videoCount = this._btnWeaponAd.getChildByName("videoCount");
- if (videoCount) videoCount.getComponent(cc.Label).string = showWeaponInfo.VideoCount + "/" + GameDate.Weapon[showWeaponKey].videoCount;
- }
- // 购买
- else {
- this._btnWeaponAd.active = false;
- this._btnWeapon.x = 250;
- this._btnWeapon.width = 252;
- if (btn_huang) btn_huang.active = true;
- // 金币
- if (GameDate.Weapon[showWeaponKey].priceType == PriceType.Gold) {
- if (txt_buy) txt_buy.active = true;
- if (icon_jinbi) {
- icon_jinbi.active = true;
- icon_jinbi.x = 0;
- }
- if (price) {
- price.active = true;
- price.x = 30;
- price.getComponent(cc.Label).string = '' + GameDate.Weapon[showWeaponKey].price;
- }
- }
- // 钻石
- else if (GameDate.Weapon[showWeaponKey].priceType == PriceType.Diamond) {
- if (txt_buy) txt_buy.active = true;
- if (icon_zuanshi) {
- icon_zuanshi.active = true;
- icon_zuanshi.x = 0;
- }
- if (price) {
- price.active = true;
- price.x = 30;
- price.getComponent(cc.Label).string = '' + GameDate.Weapon[showWeaponKey].price;
- }
- }
- // 转盘奖励
- else if (GameDate.Weapon[showWeaponKey].priceType == PriceType.ZhuanPanReward) {
- if (txt_zpjl) txt_zpjl.active = true;
- }
- }
- }
- // 升级
- else if (showWeaponInfo.Level < 3) {
- this._btnWeaponAd.active = false;
- this._btnWeapon.x = 250;
- this._btnWeapon.width = 252;
- if (btn_hong) btn_hong.active = true;
- if (txt_upgrade) txt_upgrade.active = true;
- if (icon_jinbi) {
- icon_jinbi.active = true;
- icon_jinbi.x = 0;
- }
- if (price) {
- price.active = true;
- price.x = 30;
- price.getComponent(cc.Label).string = '' + Constant.weaponLevelPriceArr[showWeaponInfo.Level];
- }
- }
- // 最大等级
- else {
- this._btnWeaponAd.active = false;
- this._btnWeapon.x = 250;
- this._btnWeapon.width = 252;
- if (txt_sjwc) txt_sjwc.active = true;
- }
- }
- this._updateWeaponFrame();
- }
- _updateWeaponFrame() {
- let gunInfos: string = cocosz.dataMgr.getItem(Constant.ST_GunInfo, "");
- if (gunInfos) {
- let gunInfoArr: GunInfo[] = JSON.parse(gunInfos);
- if (gunInfoArr) {
- for (let i = 0; i < this._weaponList.length; i++) {
- let node = this._weaponList[i];
- if (GameDate.Weapon[node.name] && GameDate.Weapon[node.name].id >= 0) {
- let id = GameDate.Weapon[node.name].id;
- if (gunInfoArr[id]) {
- let state = gunInfoArr[id].State;
- if (state >= 1) {
- node.getChildByName("kuang_hui").active = false;
- } else {
- node.getChildByName("kuang_hui").active = true;
- }
- // 选中
- if (node.name == Weapon.WeaponName[this._showWeaponId]) {
- node.getChildByName("kuang_huang").active = true;
- if (this._ani_arrow) {
- if (gunInfoArr[id].State > 0 && gunInfoArr[id].Level < 3) {
- this._ani_arrow.x = node.x + 30;
- this._ani_arrow.active = true;
- } else {
- this._ani_arrow.active = false;
- }
- }
- } else {
- node.getChildByName("kuang_huang").active = false;
- }
- } else {
- node.getChildByName("kuang_hui").active = false;
- node.getChildByName("kuang_huang").active = false;
- }
- } else {
- node.getChildByName("kuang_hui").active = false;
- node.getChildByName("kuang_huang").active = false;
- }
- }
- }
- }
- }
- /** 金币/钻石弹窗 */
- showCoinPanel(isDiamond: boolean) {
- let node = cc.instantiate(cocosz.resMgr.getRes("UIADPanel", cc.Prefab));
- cc.find("Canvas").addChild(node);
- if (isDiamond) {
- node.getComponent("UIADPanel").setDiamond();
- }
- }
- /** 飞金币/钻石 */
- private _flyCoins(iconName: string, frameNodeName: string) {
- let posNode = cc.find(frameNodeName, this._page);
- if (!posNode) return;
- let pos = posNode.parent.convertToWorldSpaceAR(posNode.position);
- FlyCoin.Show(iconName, pos);
- }
- /** 更新音频开关 */
- private _updateAudioBtn(isPlay: boolean = true) {
- let offImg: cc.Node = cc.find("Background/off", this._btnAudio);
- offImg.active = cocosz.dataMgr.AudioOn == false;
- if (isPlay) {
- //判断开关,重新播放背景音乐
- if (cocosz.dataMgr.AudioOn) {
- cocosz.audioMgr.playBgm();
- } else {
- cocosz.audioMgr.stopAll();
- }
- }
- }
- /** 更新震动开关 */
- private _updatShakeBtn() {
- let offImg: cc.Node = cc.find("Background/off", this._btnShake);
- offImg.active = cocosz.dataMgr.ShakeOn == false;
- }
- }
|