08ec80cb-3bc6-4a43-a02b-9a6e1383f9a4.js 9.68 KB
"use strict";
cc._RF.push(module, '08ec8DLO8ZKQ6Armm4Tg/mk', 'VerbView');
// script/game/ui/VerbView.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 Typewriter_1 = require("../../common/components/Typewriter");
const simba_cc_audio_manager_1 = require("simba-cc-audio-manager");
const simba_eventkit_1 = require("simba-eventkit");
const GameModelManager_1 = require("../model/GameModelManager");
const UIManager_1 = require("../../common/gameplay/managers/UIManager");
const { ccclass, property } = cc._decorator;
let VerbView = /** @class */ (() => {
    let VerbView = class VerbView extends cc.Component {
        constructor() {
            super(...arguments);
            this.title = CCDummyObjects_1.DummyRichText;
            this.desc = CCDummyObjects_1.DummyRichText;
            this.loadingWidget = CCDummyObjects_1.DummyWidget;
            this.loadingNode = CCDummyObjects_1.DummyNode;
            this.typewriter = undefined;
            this.guideNode = CCDummyObjects_1.DummyNode;
            this.shopNode = CCDummyObjects_1.DummyNode;
            this._intervalPixel = 0;
            /**是否正在执行渐显动画 */
            this._isShowAction = false;
            this._disposable = new simba_eventkit_1.CompositeDisposable();
            /**标志数据是否已经准备就绪 */
            this._forceClickDataReady = false;
            this._itemSpriteFrame = CCDummyObjects_1.DummySpriteFrame;
            this._showItemCfg = undefined;
            /**
             * 点击回调
             */
            this.touchEndCallback = () => {
                //如果有物品掉落信息就清空
                if (this._itemSpriteFrame || this._showItemCfg) {
                    this._itemSpriteFrame = CCDummyObjects_1.DummySpriteFrame;
                    this._showItemCfg = undefined;
                }
                /**没有显示动画并且数据没有准备完毕 */
                if (!this._isShowAction && this._forceClickDataReady) {
                    let sequence = cc.sequence(cc.delayTime(0.5), cc.spawn(cc.fadeOut(1), cc.callFunc(() => {
                        this.title.node.active = false;
                        this.desc.node.active = false;
                        this.guideNode.active = false;
                        //加载提示退出
                        this.loadingNode.runAction(cc.moveTo(0.3, cc.v2(this._loadingNodeX + this.loadingNode.getContentSize().width + this._intervalPixel, this._loadingNodeY)));
                    })), cc.callFunc(() => {
                        this.node.active = false;
                        // AudioManager.resumeMusic();
                    }));
                    this.node.runAction(sequence);
                }
            };
            this.forceClickDataReady = () => {
                this._forceClickDataReady = true;
                console.log('this._forceClickDataReady', this._forceClickDataReady);
            };
        }
        onLoad() {
            this.loadingNode.x = this.node.getContentSize().width / 2 + 10;
            this._loadingNodeX = this.node.getContentSize().width / 2 + 10;
            this.loadingNode.y = this.node.getContentSize().height / 2 - 36 - this.loadingNode.height / 2;
            this._loadingNodeY = this.node.getContentSize().height / 2 - 36 - this.loadingNode.height / 2;
            this.guideNode.active = false;
            if (CC_DEV) {
                globalThis['VerbView'] = this;
            }
        }
        onEnable() {
            this._disposable.add(GameModelManager_1.GameModelManager.ForceClickDataReady.on(this.forceClickDataReady));
        }
        onDisable() {
            this.node.off(cc.Node.EventType.TOUCH_END, this.touchEndCallback, this);
        }
        testCallback() {
            this.toDating(() => { }, { title: '', desc: '来电了!!!' });
        }
        /**到聊天 */
        toChat(info) {
            console.log('=====报幕到聊天====');
            simba_cc_audio_manager_1.AudioManager.stopMusic();
            this.restartNode();
            this._title = info.title;
            this._desc = info.desc;
            this.verbAction();
        }
        /**到约会 */
        toDating(callback, info) {
            console.log('=====报幕到约会====');
            simba_cc_audio_manager_1.AudioManager.stopMusic();
            this.restartNode();
            this._title = info.title;
            this._desc = info.desc;
            this._callback = callback;
            this.verbAction();
        }
        /**报幕执行动画 */
        verbAction() {
            this._isShowAction = true;
            let sequence = cc.sequence(cc.fadeIn(1), cc.callFunc(() => {
                if (this._title) {
                    //打字机效果
                    this.title.node.active = true;
                    this.typewriter.showRichTextTyper(this.title, this._title, () => {
                        if (this._desc) {
                            this.desc.node.active = true;
                            this.typewriter.showRichTextTyper(this.desc, this._desc);
                        }
                    });
                }
                else {
                    this.title.node.active = false;
                    if (this._desc) {
                        this.desc.node.active = true;
                        this.typewriter.showRichTextTyper(this.desc, this._desc);
                    }
                }
                //加载提示进入
                this.loadingNode.runAction(cc.moveTo(0.3, cc.v2(this._loadingNodeX - this.loadingNode.getContentSize().width - this._intervalPixel, this._loadingNodeY)));
            }), cc.delayTime(1), cc.callFunc(() => {
                this.node.on(cc.Node.EventType.TOUCH_END, this.touchEndCallback, this);
                this._isShowAction = false;
                this.guideNode.active = true;
                if (this._callback) {
                    this._callback();
                }
            }));
            this.node.runAction(sequence);
        }
        /**重置node */
        restartNode() {
            this.node.stopAllActions();
            this.node.active = true;
            let wid = this.node.getComponent(cc.Widget);
            wid.updateAlignment();
            this.node.opacity = 0;
            this._callback = undefined;
            this.guideNode.active = false;
            this.loadingNode.x = this.node.getContentSize().width / 2 + 10;
            this.loadingNode.y = this._loadingNodeY;
            this._forceClickDataReady = false;
            this._isShowAction = false;
        }
        setItemDropData(spriteFrame, cfg) {
            this.itemDropSprFrame = spriteFrame;
            this.cfg = cfg;
            this.showItemDrop(spriteFrame, cfg.scaletime, cfg.scale, cfg.delaytime, cfg.collecttime);
        }
        showItemDrop(itemSpr, dropTime, startScale, delayTime, collectTime) {
            this.shopNode.active = true;
            let itemNode = this.shopNode.getChildByName("item");
            let shopSprNode = this.shopNode.getChildByName("shopSpr");
            let itemSprNode = this.shopNode.getChildByName("item").getChildByName("itemSpr");
            let itemBaiSpineNode = this.shopNode.getChildByName("item").getChildByName("itemSpine");
            itemNode.rotation = -90;
            itemSprNode.getComponent(cc.Sprite).spriteFrame = itemSpr;
            cc.tween(itemNode)
                .to(0, { scale: startScale })
                .to(dropTime, { scale: 1, angle: 0 })
                .call(() => {
                itemBaiSpineNode.active = true;
                cc.tween(itemNode)
                    .to(delayTime, {})
                    .call(() => {
                    itemBaiSpineNode.active = false;
                    shopSprNode.active = true;
                    cc.tween(itemNode)
                        .to(collectTime, { scale: 0, angle: -360, x: shopSprNode.x, y: shopSprNode.y })
                        .call(() => {
                        itemNode.x = 0;
                        itemNode.y = 0;
                        this.shopNode.active = false;
                        shopSprNode.active = false;
                        UIManager_1.UIManager.showSceneToast("记得去卧室查看它的故事呦~~");
                    }).start();
                }).start();
            }).start();
        }
    };
    __decorate([
        property(cc.RichText)
    ], VerbView.prototype, "title", void 0);
    __decorate([
        property(cc.RichText)
    ], VerbView.prototype, "desc", void 0);
    __decorate([
        property(cc.Widget)
    ], VerbView.prototype, "loadingWidget", void 0);
    __decorate([
        property(cc.Node)
    ], VerbView.prototype, "loadingNode", void 0);
    __decorate([
        property(Typewriter_1.default)
    ], VerbView.prototype, "typewriter", void 0);
    __decorate([
        property(cc.Node)
    ], VerbView.prototype, "guideNode", void 0);
    __decorate([
        property({ type: cc.Node, displayName: "物品掉落节点" })
    ], VerbView.prototype, "shopNode", void 0);
    VerbView = __decorate([
        ccclass
    ], VerbView);
    return VerbView;
})();
exports.default = VerbView;

cc._RF.pop();