"use strict"; cc._RF.push(module, '4371bBLSqlKYZHR5J2oSyq6', 'UITitle'); // scripts/ui/uiView/UITitle.ts "use strict"; // Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); var SaveDataManager_1 = require("../../component/SaveDataManager"); var SoundManager_1 = require("../../component/SoundManager"); var Global_1 = require("../../Global"); var TableDefine_1 = require("../../kernel/table/TableDefine"); var MainScene_1 = require("../../scenes/MainScene"); var UIBase_1 = require("../UIBase"); var UIManager_1 = require("../UIManager"); var UIBallSkin_1 = require("./UIBallSkin"); var UIShop_1 = require("./UIShop"); var UITitleData_1 = require("./UITitleData"); var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; var UITitle = /** @class */ (function (_super) { __extends(UITitle, _super); function UITitle() { var _this = _super !== null && _super.apply(this, arguments) || this; _this._ballSkinView = null; _this._shopView = null; _this.ballSkinIsShowing = false; _this.shopIsShowing = false; return _this; //#endregion } // LIFE-CYCLE CALLBACKS: UITitle.prototype.onLoad = function () { this.node.getChildByName('top').getChildByName('btnTemp').active = CC_DEBUG; this.node.getChildByName('bottom').getChildByName('btnTestFight').active = CC_DEBUG; this.node.getChildByName('bottom').getChildByName('txiLevel').active = CC_DEBUG; }; UITitle.prototype.start = function () { }; UITitle.prototype.onEnable = function () { this.schedule(this.lazyUpdate, 1 / 20); this.lazyUpdate(); }; UITitle.prototype.onDisable = function () { this.unschedule(this.lazyUpdate); }; // update (dt) {} UITitle.prototype.lazyUpdate = function () { var maxLevel = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 22).Value; var nextLevel = SaveDataManager_1.SaveDataManager.ins.runtimeData.curLevel + 1; if (nextLevel > maxLevel) { nextLevel = maxLevel; } this.node.getChildByName('bottom').getChildByName('naviBar').getChildByName('btnLayer').getChildByName('btn3').getComponentInChildren(cc.Label).string = nextLevel.toString(); }; //#region events UITitle.prototype.onBtnTempClick = function () { // UIManager.ins.openScene('Temp'); SaveDataManager_1.SaveDataManager.ins.resetData(); SaveDataManager_1.SaveDataManager.ins.saveData(); location.reload(); }; UITitle.prototype.onBtnFightClick = function () { var id = Number(this.node.getChildByName('bottom').getChildByName('txiLevel').getComponent(cc.EditBox).string); UITitleData_1.UITitleData.id = id; // id > 0 ? UIManager.ins.openWindow(WindowName.PREVIEW, UITitleData.id) : UIManager.ins.openScene('Battle'); UIManager_1.UIManager.ins.openWindow(Global_1.WindowName.PREVIEW, UITitleData_1.UITitleData.id); }; UITitle.prototype.onBtnNaviClick = function (e, indexStr) { var _this = this; var index = Number(indexStr); switch (index) { case 1: UIManager_1.UIManager.ins.loadWindow(Global_1.WindowName.SHOP, function (view) { if (_this.shopIsShowing == true) return; _this.onBallSkinCloseClick(); //自动关闭 _this.node.getChildByName('middleMask').active = true; if (!_this._shopView) { _this._shopView = view; } view.active = true; _this.shopIsShowing = true; if (!view.parent) { var container = _this.node.getChildByName('middle'); var targetY = (1030 / 2 - container.height / 2); //界面底端对齐 container var startY = targetY - 1030; view.setPosition(0, startY); container.addChild(view); cc.tween(view).to(0.3, { position: cc.v3(0, targetY, 0) }, { easing: 'backOut' }).start(); } else { var container = _this.node.getChildByName('middle'); var targetY = (1030 / 2 - container.height / 2); //界面底端对齐 container var startY = targetY - 1030; view.setPosition(0, startY); cc.tween(view).to(0.3, { position: cc.v3(0, targetY, 0) }, { easing: 'backOut' }).start(); } view.getComponent(UIShop_1.default).setAD(); }); break; case 2: // console.log('抽奖') UIManager_1.UIManager.ins.openWindow(Global_1.WindowName.WHEEL); break; case 99: e.target.destroy(); this.node.parent.getComponent(MainScene_1.default).onGuideClick(); case 3: var maxLevel = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 22).Value; var nextLevel = SaveDataManager_1.SaveDataManager.ins.runtimeData.curLevel + 1; if (nextLevel > maxLevel) { nextLevel = maxLevel; } UITitleData_1.UITitleData.id = nextLevel; UIManager_1.UIManager.ins.openWindow(Global_1.WindowName.PREVIEW, UITitleData_1.UITitleData.id); // UIManager.ins.openScene('Battle'); break; case 4: UIManager_1.UIManager.ins.openWindow(Global_1.WindowName.SIGN); break; case 5: UIManager_1.UIManager.ins.loadWindow(Global_1.WindowName.BALL_SKIN, function (view) { if (_this.ballSkinIsShowing == true) return; _this.onShopCloseClick(); //自动关闭 _this.node.getChildByName('middleMask').active = true; if (!_this._ballSkinView) { _this._ballSkinView = view; } view.active = true; _this.ballSkinIsShowing = true; if (!view.parent) { var container = _this.node.getChildByName('middle'); var targetY = (1030 / 2 - container.height / 2); //界面底端对齐 container var startY = targetY - 1030; view.setPosition(0, startY); container.addChild(view); cc.tween(view).to(0.3, { position: cc.v3(0, targetY, 0) }, { easing: 'backOut' }).start(); } else { var container = _this.node.getChildByName('middle'); var targetY = (1030 / 2 - container.height / 2); //界面底端对齐 container var startY = targetY - 1030; view.setPosition(0, startY); cc.tween(view).to(0.3, { position: cc.v3(0, targetY, 0) }, { easing: 'backOut' }).start(); } view.getComponent(UIBallSkin_1.default).setAD(); }); break; default: break; } }; UITitle.prototype.onBtnSettingClick = function () { UIManager_1.UIManager.ins.openWindow(Global_1.WindowName.SETTING); SoundManager_1.SoundManager.ins.playEffect('Click'); }; UITitle.prototype.onBallSkinCloseClick = function () { var _this = this; if (this._ballSkinView && this._ballSkinView.parent) { var container = this.node.getChildByName('middle'); var targetY = (1030 / 2 - container.height / 2) - 1030; cc.Tween.stopAllByTarget(this._ballSkinView); cc.tween(this._ballSkinView).to(0.2, { position: cc.v3(0, targetY, 0) }).call(function () { UIManager_1.UIManager.ins.closeWindow(Global_1.WindowName.BALL_SKIN); _this.ballSkinIsShowing = false; }).start(); this.node.getChildByName('middleMask').active = false; } }; UITitle.prototype.onShopCloseClick = function () { var _this = this; if (this._shopView && this._shopView.parent) { var container = this.node.getChildByName('middle'); var targetY = (1030 / 2 - container.height / 2) - 1030; cc.Tween.stopAllByTarget(this._shopView); cc.tween(this._shopView).to(0.2, { position: cc.v3(0, targetY, 0) }).call(function () { UIManager_1.UIManager.ins.closeWindow(Global_1.WindowName.SHOP); _this.shopIsShowing = false; }).start(); this.node.getChildByName('middleMask').active = false; } }; UITitle.prototype.onLevelRankClick = function () { var _this = this; // UIManager.ins.openWindow(WindowName.LEVEL_RANK); UIManager_1.UIManager.ins.loadWindow(Global_1.WindowName.LEVEL_RANK, function (view) { _this._levelRankView = view; view.active = true; _this.node.getChildByName('topWindow').addChild(view); }); }; UITitle = __decorate([ ccclass ], UITitle); return UITitle; }(UIBase_1.UIBase)); exports.default = UITitle; cc._RF.pop();