c2dfdd08-ee66-4a46-8bd8-b1e6e3d2a190.js 12.9 KB
"use strict";
cc._RF.push(module, 'c2dfd0I7mZKRovYsebj0qGQ', 'WardrobeViewPresenter');
// script/game/ui/presenter/bedroom/WardrobeViewPresenter.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 simba_cc_resutils_1 = require("simba-cc-resutils");
const PresenterBase_1 = require("../../../../common/classbase/PresenterBase");
const GameConstData_1 = require("../../../../common/gameplay/gamedata/GameConstData");
const UIManager_1 = require("../../../../common/gameplay/managers/UIManager");
const GameConfig_1 = require("../../../../GameConfig");
const BedRoomCatModelManager_1 = require("../../../model/BedRoomCatModelManager");
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const SuitItem_1 = require("../../SuitItem");
const WardrobeView_1 = require("../../view/type/WardrobeView");
const AlertDialogViewPresenter_1 = require("../AlertDialogViewPresenter");
let WardrobeViewPresenter = /** @class */ (() => {
    let WardrobeViewPresenter = class WardrobeViewPresenter extends PresenterBase_1.Presenter {
        constructor() {
            super();
            this._suitId = 0;
            this._nextStep = -1;
            this._wardrobeIntroductionString = "通过完成任务,收集碎片,收集完所有碎片就可以解锁梵优的新衣服啦!";
            this.onWearBtnClickCallBack = () => {
                BedRoomCatModelManager_1.BedRoomCatModelManager.changeUsingSuitId(this._suitId);
                this.checkWearBtnStatus(this._suitId);
                UIManager_1.UIManager.showSceneToast("已穿戴当前套装,约会人物立绘将替换为当前套装!", 0.5);
                let isShow = BedRoomCatModelManager_1.BedRoomCatModelManager.checkIsShowSuitShareBtnBySuitId(this._suitId);
                if (isShow) {
                    this.onShareBtnClickCallBack();
                }
            };
            this.onShareBtnClickCallBack = () => {
                let temp = {
                    dataptr: { bgPath: GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "wardrobeBg", rolePath: GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + this._suitId },
                    titlecontent: "提示",
                    content: "小主穿戴了服装,快去分享给小伙伴吧,分享可得4个猫粮哦~",
                    ishasad: false,
                    istwobtn: true,
                    adconfig: "default",
                    hasBanner: false,
                    callback: (type, ret) => {
                        if (ret || GameConfig_1.channel === "dummy") {
                            //保存分享存档
                            BedRoomCatModelManager_1.BedRoomCatModelManager.saveSuitShareStatusBySuitId(this._suitId);
                            this.checkShareBtnStatus(this._suitId);
                            //分享奖励
                            BedRoomCatModelManager_1.BedRoomCatModelManager.addCatFoodNumberByFoodId(1, 4);
                            UIManager_1.UIManager.showSceneToast("猫粮数量+4");
                        }
                    },
                    isShareScreen: true
                };
                UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
            };
            this.onTabBtnClickCallBack = async (suitId) => {
                this._suitId = suitId;
                this.view.getStayTunedNode().active = false;
                this.view.getScrollViewContentNode().removeAllChildren();
                let suitButtons = this.view.getSuitButtons();
                for (let i = 0; i < suitButtons.length; i++) {
                    if (i == suitId - 1) {
                        suitButtons[i].normalSprite = this.view.getSuitButtonSprites()[1];
                    }
                    else {
                        suitButtons[i].normalSprite = this.view.getSuitButtonSprites()[0];
                    }
                }
                for (let i = 0; i < suitButtons.length; i++) {
                    if (i == suitId - 1) {
                        suitButtons[i].getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "tabBtn", cc.SpriteFrame);
                    }
                    else {
                        suitButtons[i].getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "tabBtnGray", cc.SpriteFrame);
                    }
                }
                //套装3为未开发套装,暂时特殊处理
                if (suitId == 3) {
                    this.view.getStayTunedNode().active = true;
                    this.view.getWearBtn().node.active = false;
                    this.view.getShareBtn().node.active = false;
                    this.view.getRolePortrait().node.active = false;
                    this.view.getRolePortraitLock().node.active = true;
                    this.view.getRolePortraitLockLabel().string = "敬请期待";
                    this.view.getRolePortrait().spriteFrame = undefined;
                    this.view.getRolePortraitLock().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + "3lock", cc.SpriteFrame);
                    return;
                }
                //套装1居中适配,在前后各加一个空的预制体
                if (suitId == 1) {
                    let item = cc.instantiate(this.view.getSuitItemNull());
                    item.parent = this.view.getScrollViewContentNode();
                }
                let suitConfigs = BedRoomCatModelManager_1.BedRoomCatModelManager.getSuitConfigBySuitId(suitId);
                for (let i = 0; i < suitConfigs.length; i++) {
                    let item = cc.instantiate(this.view.getSuitItem());
                    if (suitConfigs[i].isUnlock) {
                        BedRoomCatModelManager_1.BedRoomCatModelManager.saveUnlockClothingBySuitId(suitConfigs[i].suitId, suitConfigs[i].clothingId);
                    }
                    let unlockClothing = BedRoomCatModelManager_1.BedRoomCatModelManager.getUnlockClothingBySuitId(suitId);
                    let showLockRootNode = unlockClothing.indexOf(suitConfigs[i].clothingId) == -1;
                    item.getComponent(SuitItem_1.default).setData(suitConfigs[i], showLockRootNode);
                    item.parent = this.view.getScrollViewContentNode();
                }
                //套装1居中适配,在前后各加一个空的预制体
                if (suitId == 1) {
                    let item = cc.instantiate(this.view.getSuitItemNull());
                    item.parent = this.view.getScrollViewContentNode();
                }
                this.checkWearBtnStatus(suitId);
                this.checkShareBtnStatus(suitId);
                this.updateRedDot();
            };
            this.onBackBtnClickCallBack = () => {
                this.view.close();
            };
        }
        onOpen(props) {
            super.onOpen(props);
            this._viewProps = props;
            this._viewProps.onWearBtnClickCallBack = this.onWearBtnClickCallBack;
            this._viewProps.onShareBtnClickCallBack = this.onShareBtnClickCallBack;
            this._viewProps.onTabBtnClickCallBack = this.onTabBtnClickCallBack;
            this._viewProps.onBackBtnClickCallBack = this.onBackBtnClickCallBack;
            this.view.setProps(this._viewProps);
            this.onShow();
        }
        onShow() {
            super.onShow();
            this.setIntroductionIconTouchEvent();
            this.onTabBtnClickCallBack(1);
        }
        onClose() {
            super.onClose();
        }
        onEnterBackground() {
            super.onEnterBackground();
        }
        onEnterForeground() {
            super.onEnterForeground();
        }
        setIntroductionIconTouchEvent() {
            let introductionIconNode = this.view.getIntroductionIconNode();
            let introductionNode = this.view.getIntroductionNode();
            introductionIconNode.on(cc.Node.EventType.TOUCH_START, function (event) {
                introductionNode.active = true;
            }, this);
            introductionIconNode.on(cc.Node.EventType.TOUCH_END, function (event) {
                introductionNode.active = false;
            }, this);
            introductionIconNode.on(cc.Node.EventType.TOUCH_CANCEL, function (event) {
                introductionNode.active = false;
            }, this);
        }
        updateRedDot() {
            for (let i = 1; i < 4; i++) {
                let suitStatus = BedRoomCatModelManager_1.BedRoomCatModelManager.checkSuitStatus(i);
                let suitIsClicked = BedRoomCatModelManager_1.BedRoomCatModelManager.getSuitIsClicked(i);
                if (suitStatus !== BedRoomCatModelManager_1.SuitStatus.Lock && !suitIsClicked) {
                    this.view.getRedDotNodes()[i - 1].active = true;
                }
                else {
                    this.view.getRedDotNodes()[i - 1].active = false;
                }
            }
        }
        async checkWearBtnStatus(suitId) {
            let suitStatus = BedRoomCatModelManager_1.BedRoomCatModelManager.checkSuitStatus(suitId);
            if (suitStatus !== BedRoomCatModelManager_1.SuitStatus.Lock) {
                BedRoomCatModelManager_1.BedRoomCatModelManager.saveSuitIsClicked(suitId);
            }
            switch (suitStatus) {
                case BedRoomCatModelManager_1.SuitStatus.Lock:
                    this.view.getWearBtn().node.active = false;
                    this.view.getRolePortrait().node.active = false;
                    this.view.getRolePortraitLock().node.active = true;
                    this.view.getRolePortraitLockLabel().string = "收集完所有碎片才可解锁哦";
                    this.view.getRolePortrait().spriteFrame = undefined;
                    this.view.getRolePortraitLock().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + suitId + "lock", cc.SpriteFrame);
                    break;
                case BedRoomCatModelManager_1.SuitStatus.Unlock:
                    this.view.getWearBtn().node.active = true;
                    this.view.getWearBtn().interactable = true;
                    this.view.getRolePortrait().node.active = true;
                    this.view.getRolePortraitLock().node.active = false;
                    this.view.getRolePortrait().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + suitId, cc.SpriteFrame);
                    this.view.getRolePortraitLock().spriteFrame = undefined;
                    this.view.getWearBtn().getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "wearBtn", cc.SpriteFrame);
                    break;
                case BedRoomCatModelManager_1.SuitStatus.Wear:
                    this.view.getWearBtn().node.active = true;
                    this.view.getWearBtn().interactable = false;
                    this.view.getRolePortrait().node.active = true;
                    this.view.getRolePortraitLock().node.active = false;
                    this.view.getRolePortrait().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + suitId, cc.SpriteFrame);
                    this.view.getRolePortraitLock().spriteFrame = undefined;
                    this.view.getWearBtn().getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "wearedBtn", cc.SpriteFrame);
                    break;
                default:
                    break;
            }
        }
        checkShareBtnStatus(suitId) {
            let isShow = BedRoomCatModelManager_1.BedRoomCatModelManager.checkIsShowSuitShareBtnBySuitId(suitId);
            this.view.getShareBtn().node.active = isShow;
        }
    };
    WardrobeViewPresenter.uuid = "WardrobeViewPresenter";
    WardrobeViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(WardrobeView_1.WardrobeViewType)
    ], WardrobeViewPresenter);
    return WardrobeViewPresenter;
})();
exports.default = WardrobeViewPresenter;

cc._RF.pop();