08ec80cb-3bc6-4a43-a02b-9a6e1383f9a4.js
9.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
"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();