fb97d446-ef23-4786-b06d-925fb0029ba1.js 2.79 KB
"use strict";
cc._RF.push(module, 'fb97dRG7yNHhrBtkl+wApuh', 'LikeLevelSubpresenter');
// script/game/ui/presenter/LikeLevelSubpresenter.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 });
exports.LikeLevelSubpresenter = void 0;
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const LikeLevelSubview_1 = require("../view/type/LikeLevelSubview");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const GameModelManager_1 = require("../../model/GameModelManager");
const EditorEnums_1 = require("../../../avg/EditorEnums");
const GameRecord_1 = require("../../../avg/game-data/GameRecord");
let LikeLevelSubpresenter = /** @class */ (() => {
    let LikeLevelSubpresenter = class LikeLevelSubpresenter extends PresenterBase_1.Subpresenter {
        onOpen() {
            super.onOpen();
            if (!this.owner["getRoleId"]) {
                console.error("owner need provide roleId by getRoleId");
                return;
            }
            let roleId = this.owner["getRoleId"]();
            let roleData = GameModelManager_1.GameModelManager.getRoleData(roleId);
            if (roleData.getConfig().RoleType === EditorEnums_1.RoleType.Role_Major) {
                this.updateView(roleData);
                this._disposable.add(GameRecord_1.GameRecord.onRecordVariableChange("like" + roleId, () => {
                    this.updateView(roleData);
                }));
                this._disposable.add(GameRecord_1.GameRecord.onGlobalVariableChange("like" + roleId, () => {
                    this.updateView(roleData);
                }));
            }
            else {
                this.view.setProps({ visible: false, level: 0, percent: 0 });
            }
        }
        updateView(role) {
            let data = role.getRoleLikeLevel();
            this.view.setProps({ visible: true, level: data.level, percent: data.level === data.maxLevel ? 1 : (data.currLike / data.nextLevelLike) });
        }
    };
    LikeLevelSubpresenter = __decorate([
        PresenterCCViewFactory_1.RegSubpresenter(LikeLevelSubview_1.LikeLevelViewType)
    ], LikeLevelSubpresenter);
    return LikeLevelSubpresenter;
})();
exports.LikeLevelSubpresenter = LikeLevelSubpresenter;

cc._RF.pop();