daa1964f-7ef4-4b2d-8164-e23b96a54fcf.js 2.66 KB
"use strict";
cc._RF.push(module, 'daa19ZPfvRLLYFk4juWpU/P', 'ChapterBtn');
// script/game/ui/ChapterBtn.ts

"use strict";
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 });
const CCDummyObjects_1 = require("../../common/CCDummyObjects");
const GameModelManager_1 = require("../model/GameModelManager");
const { ccclass, property } = cc._decorator;
let ChapterBtn = /** @class */ (() => {
    let ChapterBtn = class ChapterBtn extends cc.Component {
        constructor() {
            super(...arguments);
            this.label = CCDummyObjects_1.DummyLabel;
            this.pointSpr = CCDummyObjects_1.DummyNode;
            this._pid = -1;
        }
        setData(chapterId, chapterName, pid) {
            this._pid = pid;
            this.label.string = chapterId.toString() + "." + GameModelManager_1.GameModelManager.getI18LanguageTxt(chapterName);
        }
        onItemClick() {
            console.log("onItemClick pid = ", this._pid);
            GameModelManager_1.GameModelManager.RollBackToPlot.emit(this._pid);
            let sprites = this.node.parent.getComponentsInChildren(cc.Sprite);
            for (let i = 0; i < sprites.length; i++) {
                sprites[i].node.active = false;
            }
            this.pointSpr.active = true;
            cc.tween(this.pointSpr)
                .repeatForever(cc.tween()
                .to(0.5, { scale: 1.15, x: -25 }, { easing: 'sineInOut' })
                .to(0.5, { scale: 1, x: -30 }, { easing: 'sineInOut' }))
                .start();
            let labels = this.node.parent.getComponentsInChildren(cc.Label);
            for (let i = 0; i < labels.length; i++) {
                labels[i].node.color = cc.color(255, 255, 255, 255);
            }
            this.label.node.color = cc.color(255, 238, 149, 255);
        }
    };
    __decorate([
        property(cc.Label)
    ], ChapterBtn.prototype, "label", void 0);
    __decorate([
        property(cc.Node)
    ], ChapterBtn.prototype, "pointSpr", void 0);
    ChapterBtn = __decorate([
        ccclass
    ], ChapterBtn);
    return ChapterBtn;
})();
exports.default = ChapterBtn;

cc._RF.pop();