66abed93-a266-4e5f-8288-6c0c3a4e2a0e.js 5.97 KB
"use strict";
cc._RF.push(module, '66abe2TomZOX4KIbAw6TioO', 'UIPrivacy');
// scripts/ui/uiView/UIPrivacy.ts

"use strict";
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 Global_1 = require("../../Global");
var UIBase_1 = require("../UIBase");
var UIManager_1 = require("../UIManager");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var UI_Privacy = /** @class */ (function (_super) {
    __extends(UI_Privacy, _super);
    function UI_Privacy() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.type = 1;
        _this.imgBg = null;
        _this.Privacy = null;
        _this.curTextNum = 0;
        _this.privacyTextList = null;
        return _this;
    }
    // start() {
    // }
    UI_Privacy.prototype.onEnable = function () {
        this.curTextNum = 0;
        this.privacyTextList = this.Privacy.getChildByName('content').children;
        this.showFirstText();
        var _param = this.enableParam;
        this.Action_FadeIn();
        this.type = _param;
        if (_param == 2) {
            this.onEvent_ShowPrivcayText();
        }
        else {
            this.onEvent_BTN_Back();
        }
        cc.log('privacy');
    };
    UI_Privacy.prototype.showPrivacyTextForNum = function (curNum) {
        for (var i = 0; i < this.privacyTextList.length; i++) {
            if (i == curNum) {
                this.privacyTextList[i].active = true;
            }
            else {
                this.privacyTextList[i].active = false;
            }
        }
    };
    UI_Privacy.prototype.showFirstText = function () {
        this.privacyTextList.forEach(function (element) {
            if (element.name == 'Label1') {
                element.active = true;
            }
            else {
                element.active = false;
            }
        });
    };
    UI_Privacy.prototype.CloseUI = function () {
        this.Action_FadeOut();
        // this.showFirstText();
    };
    UI_Privacy.prototype.onEvent_BTN_Agree = function () {
        this.CloseUI();
        localStorage.setItem("_PRIVACY", "true");
    };
    UI_Privacy.prototype.onEvent_BTN_Exit = function () {
    };
    UI_Privacy.prototype.onEvent_BTN_Next = function () {
        this.curTextNum++;
        if (this.curTextNum >= this.privacyTextList.length) {
            this.curTextNum = 0;
        }
        this.showPrivacyTextForNum(this.curTextNum);
        //test
        // this.privacyTextList.forEach(element => {
        //     console.log(element.active + ' <<<<<<<<< ' + element.name)
        // });
    };
    UI_Privacy.prototype.onEvent_ShowPrivcayText = function () {
        this.imgBg.active = false;
        this.Privacy.active = true;
    };
    UI_Privacy.prototype.onEvent_BTN_Back = function () {
        if (this.type == 2) {
            this.CloseUI();
        }
        else {
            this.imgBg.active = true;
            this.Privacy.active = false;
        }
    };
    UI_Privacy.prototype.Action_SetButton_Clickable = function (value) {
        this.node.getChildByName('touchBlocker').active = !value;
    };
    UI_Privacy.prototype.Action_FadeIn = function (_data, _fadeTime) {
        var _this = this;
        if (_fadeTime === void 0) { _fadeTime = 0.5; }
        // 动态进入的效果
        this.node.getChildByName('blackFrame').opacity = 0;
        cc.tween(this.node.getChildByName('blackFrame')).to(_fadeTime * 0.4, { opacity: 200 }).start();
        this.node.getChildByName('panel').scale = 0;
        this.Action_SetButton_Clickable(false);
        cc.tween(this.node.getChildByName('panel')).to(_fadeTime, { scale: 1 }, { easing: 'backOut' }).call(function () {
            _this.OnEvent_TweenFinished_FadeIn(_data);
        }).start();
    };
    UI_Privacy.prototype.OnEvent_TweenFinished_FadeIn = function (_data) {
        this.Action_SetButton_Clickable(true);
    };
    UI_Privacy.prototype.Action_FadeOut = function (_fadeTime) {
        var _this = this;
        if (_fadeTime === void 0) { _fadeTime = 0.3; }
        this.Action_SetButton_Clickable(false);
        cc.tween(this.node.getChildByName('blackFrame')).to(_fadeTime, { opacity: 0 }).start();
        cc.tween(this.node.getChildByName('panel')).to(_fadeTime, { scale: 0 }, { easing: 'backIn' }).call(function () {
            _this.OnEvent_TweenFinished_FadeOut();
        }).start();
    };
    UI_Privacy.prototype.OnEvent_TweenFinished_FadeOut = function () {
        // this.node.active = false;
        UIManager_1.UIManager.ins.closeWindow(Global_1.WindowName.PRIVACY);
    };
    __decorate([
        property(cc.Node)
    ], UI_Privacy.prototype, "imgBg", void 0);
    __decorate([
        property(cc.Node)
    ], UI_Privacy.prototype, "Privacy", void 0);
    UI_Privacy = __decorate([
        ccclass
    ], UI_Privacy);
    return UI_Privacy;
}(UIBase_1.UIBase));
exports.default = UI_Privacy;

cc._RF.pop();