@cc-component/cc-guide 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cc-ex-component.md +12 -0
- package/assets/guide/common/GuideTool.ts +33 -0
- package/assets/guide/common/GuideTool.ts.meta +9 -0
- package/assets/guide/common/Log.ts +82 -0
- package/assets/guide/common/Log.ts.meta +9 -0
- package/assets/guide/common/ViewUtil.ts +163 -0
- package/assets/guide/common/ViewUtil.ts.meta +9 -0
- package/assets/guide/common.meta +9 -0
- package/assets/guide/guide/Guide.ts +42 -0
- package/assets/guide/guide/Guide.ts.meta +9 -0
- package/assets/guide/guide/GuideCenter.ts +364 -0
- package/assets/guide/guide/GuideCenter.ts.meta +9 -0
- package/assets/guide/guide/GuideSDK.ts +71 -0
- package/assets/guide/guide/GuideSDK.ts.meta +9 -0
- package/assets/guide/guide/model/GuideCommon.ts +27 -0
- package/assets/guide/guide/model/GuideCommon.ts.meta +9 -0
- package/assets/guide/guide/model/GuideModelComp.ts +161 -0
- package/assets/guide/guide/model/GuideModelComp.ts.meta +9 -0
- package/assets/guide/guide/model/ITableGuide.ts +32 -0
- package/assets/guide/guide/model/ITableGuide.ts.meta +9 -0
- package/assets/guide/guide/model/ITableNPC.ts +10 -0
- package/assets/guide/guide/model/ITableNPC.ts.meta +9 -0
- package/assets/guide/guide/model.meta +12 -0
- package/assets/guide/guide/view/GuideTest.ts +150 -0
- package/assets/guide/guide/view/GuideTest.ts.meta +9 -0
- package/assets/guide/guide/view/GuideViewComp.ts +299 -0
- package/assets/guide/guide/view/GuideViewComp.ts.meta +9 -0
- package/assets/guide/guide/view/GuideViewItem.ts +104 -0
- package/assets/guide/guide/view/GuideViewItem.ts.meta +9 -0
- package/assets/guide/guide/view/GuideViewMask.ts +342 -0
- package/assets/guide/guide/view/GuideViewMask.ts.meta +9 -0
- package/assets/guide/guide/view/GuideViewPrompt.ts +178 -0
- package/assets/guide/guide/view/GuideViewPrompt.ts.meta +9 -0
- package/assets/guide/guide/view/PolygonMask.ts +161 -0
- package/assets/guide/guide/view/PolygonMask.ts.meta +9 -0
- package/assets/guide/guide/view/touch.ts.meta +9 -0
- package/assets/guide/guide/view.meta +12 -0
- package/assets/guide/guide.meta +9 -0
- package/assets/guide/interface/GuideModule.ts +54 -0
- package/assets/guide/interface/GuideModule.ts.meta +1 -0
- package/assets/guide/interface/Interface.ts +44 -0
- package/assets/guide/interface/Interface.ts.meta +9 -0
- package/assets/guide/interface/guide/mask.prefab +716 -0
- package/assets/guide/interface/guide/mask.prefab.meta +13 -0
- package/assets/guide/interface/guide/prompt.prefab +1524 -0
- package/assets/guide/interface/guide/prompt.prefab.meta +13 -0
- package/assets/guide/interface/guide/skeleton.atlas +20 -0
- package/assets/guide/interface/guide/skeleton.atlas.meta +12 -0
- package/assets/guide/interface/guide/skeleton.json +1 -0
- package/assets/guide/interface/guide/skeleton.json.meta +13 -0
- package/assets/guide/interface/guide/skeleton.png +0 -0
- package/assets/guide/interface/guide/skeleton.png.meta +134 -0
- package/assets/guide/interface/guide.meta +9 -0
- package/assets/guide/interface.meta +1 -0
- package/assets/guide.meta +11 -0
- package/assets.meta +9 -0
- package/index.ts +5 -0
- package/index.ts.meta +9 -0
- package/package.json +19 -0
- package/package.json.meta +11 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { assetManager } from 'cc';
|
|
2
|
+
import { AssetManager } from 'cc';
|
|
3
|
+
import { _decorator, Component, Node } from 'cc';
|
|
4
|
+
//import { Guide } from './Guide';
|
|
5
|
+
import { Guide } from './Guide';
|
|
6
|
+
import { JsonAsset } from 'cc';
|
|
7
|
+
import { IGuideData } from './model/GuideCommon';
|
|
8
|
+
import { ITableGuide } from './model/ITableGuide';
|
|
9
|
+
import { Sprite } from 'cc';
|
|
10
|
+
import { isValid } from 'cc';
|
|
11
|
+
import { SpriteFrame } from 'cc';
|
|
12
|
+
import { Log } from '../common/Log';
|
|
13
|
+
import { CreateNode, IsJson } from '../common/GuideTool';
|
|
14
|
+
|
|
15
|
+
const { ccclass, property } = _decorator;
|
|
16
|
+
|
|
17
|
+
@ccclass('GuideCenter')
|
|
18
|
+
export class GuideCenter {
|
|
19
|
+
static _instance: GuideCenter = null!;
|
|
20
|
+
static get instance() {
|
|
21
|
+
if (!this._instance) {
|
|
22
|
+
this._instance = new GuideCenter()
|
|
23
|
+
}
|
|
24
|
+
return this._instance
|
|
25
|
+
}
|
|
26
|
+
static get guideCenter() {
|
|
27
|
+
return GuideCenter.instance;
|
|
28
|
+
}
|
|
29
|
+
callMessage: (param: ITableGuide) => void;
|
|
30
|
+
callMessageNet: (param: number, finish: Function) => void;
|
|
31
|
+
|
|
32
|
+
callClick: (step: number) => void;
|
|
33
|
+
callJumpWindow: (urls: string[]) => void;
|
|
34
|
+
callFinishGroup: () => void;
|
|
35
|
+
/** 游戏初始化模块 */
|
|
36
|
+
guide: Guide = null!;
|
|
37
|
+
node: Node;
|
|
38
|
+
/** 资源路径 */
|
|
39
|
+
path: string = "guide/tableJS/";
|
|
40
|
+
bundleName: string = "guide";
|
|
41
|
+
|
|
42
|
+
/** 数据缓存 */
|
|
43
|
+
data: Map<string, any> = new Map();
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
is_guide_week = false;
|
|
47
|
+
step_week = -1
|
|
48
|
+
_step = 1
|
|
49
|
+
param: IGuideData
|
|
50
|
+
/**设置步数 */
|
|
51
|
+
set step(step: number) {
|
|
52
|
+
this.guide.GuideModel.step = step;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get step() {
|
|
56
|
+
return this.guide.GuideModel.step;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** 加载完成事件 */
|
|
60
|
+
public init(node: Node, step: number, param: IGuideData) {
|
|
61
|
+
this.param = param;
|
|
62
|
+
return new Promise<void>(async (resolve, reject) => {
|
|
63
|
+
const guide_window = CreateNode("GuideWindow")
|
|
64
|
+
node.addChild(guide_window)
|
|
65
|
+
// 动态导入 Guide
|
|
66
|
+
this.node = guide_window;
|
|
67
|
+
// 创建引导模块
|
|
68
|
+
this.guide = new Guide();
|
|
69
|
+
this.guide.init(param)
|
|
70
|
+
// 引导当前位置
|
|
71
|
+
this.step = step;
|
|
72
|
+
// 引导最大步数(最后步骤引导完后自动释放引导相关资源)
|
|
73
|
+
//this.guide.GuideModel.last = 2;
|
|
74
|
+
this.load(this.bundleName, [this.guide.GuideModel.res_dir], (pro) => {
|
|
75
|
+
// Log.log("加载进度:", pro);
|
|
76
|
+
}).then(async () => {
|
|
77
|
+
//await this.loadDirJsonAsync()
|
|
78
|
+
Log.log("加载完成");
|
|
79
|
+
this.guide.load(this.node);
|
|
80
|
+
|
|
81
|
+
this.guide.GuideView.nextCall = () => {
|
|
82
|
+
this.is_guide_week = false//this.step >= this.step_week
|
|
83
|
+
this.hideUI()
|
|
84
|
+
}
|
|
85
|
+
resolve()
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
getAsset<T>(name: string) {
|
|
92
|
+
return assetManager.getBundle(this.bundleName).get(name) as T;
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
/**加载视频 */
|
|
96
|
+
load(bundleName: string, dirs: string[], pro: (pro: number) => void) {
|
|
97
|
+
return new Promise<void>(async (resolve, reject) => {
|
|
98
|
+
let bundle = assetManager.getBundle(bundleName);
|
|
99
|
+
if (!bundle) {
|
|
100
|
+
bundle = await new Promise<AssetManager.Bundle>(resolve => {
|
|
101
|
+
assetManager.loadBundle(bundleName, (err, bundle) => {
|
|
102
|
+
if (err) {
|
|
103
|
+
reject(err);
|
|
104
|
+
} else {
|
|
105
|
+
resolve(bundle)
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
let pro_num = 0
|
|
111
|
+
for (let index = 0; index < dirs.length; index++) {
|
|
112
|
+
const dir = dirs[index];
|
|
113
|
+
await new Promise<void>(resolve => {
|
|
114
|
+
bundle.loadDir(dir, (fin, total) => {
|
|
115
|
+
// const value = fin / total * 100;
|
|
116
|
+
// pro?.(value);
|
|
117
|
+
}, (err, assets) => {
|
|
118
|
+
resolve()
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
let pro_add = (index + 1) / dirs.length
|
|
122
|
+
pro_num = pro_add * 100
|
|
123
|
+
pro?.(index);
|
|
124
|
+
}
|
|
125
|
+
resolve()
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** 加载所有配置表数据到缓存中 */
|
|
130
|
+
loadDirJsonAsync(): Promise<boolean> {
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
assetManager.getBundle(this.param.bundleName).loadDir(this.path, (err: Error | null, assets: JsonAsset[]) => {
|
|
133
|
+
if (err) {
|
|
134
|
+
//Log.warn(err.message);
|
|
135
|
+
resolve(false);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
assets.forEach(asset => {
|
|
139
|
+
this.data.set(asset.name, asset.json);
|
|
140
|
+
});
|
|
141
|
+
//resLoader.releaseDir(this.path);
|
|
142
|
+
resolve(true);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get(name: string): any {
|
|
149
|
+
return this.data.get(name);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** 检查指定引导是否触发 */
|
|
153
|
+
check(step: number) {
|
|
154
|
+
if (this.guide.GuideModel) {
|
|
155
|
+
this.guide.GuideModel.refeshStepLast()
|
|
156
|
+
}
|
|
157
|
+
this.guide.check(step);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
hideUI() {
|
|
161
|
+
this.guide.GuideView.hideUI()
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
/** 开始指定功能引导组-注意此方法需要更新服务器的步骤 */
|
|
166
|
+
startGuideGroup(group_id: number) {
|
|
167
|
+
if (group_id === undefined || group_id < 0 || !this.guide.GuideModel.guide_group.has(group_id)) {
|
|
168
|
+
Log.error("请检查表格,没有引导组:", group_id)
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//功能引导
|
|
173
|
+
const data = this.guide.GuideModel.guide_group.get(group_id)
|
|
174
|
+
const step = data[0].data.id;
|
|
175
|
+
this.callMessageNet?.(step, () => {
|
|
176
|
+
this.step = step;
|
|
177
|
+
this.check(step)
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
onClick() {
|
|
181
|
+
this.callClick?.(this.step)
|
|
182
|
+
//Log.warn("2点击了")
|
|
183
|
+
const curren = this.guide.GuideModel.prompts[this.step];
|
|
184
|
+
//Log.warn("3点击了", curren.data.id);
|
|
185
|
+
if (curren.data.saveID === curren.data.step) {
|
|
186
|
+
//Log.warn("4点击了", curren.data.id);
|
|
187
|
+
//const map = JsonUtil.getMap<number, ITableGuide>(ITableGuide.TableName)
|
|
188
|
+
const step_new = this.step + 1;
|
|
189
|
+
const next = this.guide.GuideModel.prompts[step_new];
|
|
190
|
+
//Log.warn("5点击了", curren.data.id);
|
|
191
|
+
const group_list = this.guide.GuideModel.guide_group.get(curren.data.groupID)
|
|
192
|
+
const last = group_list[group_list.length - 1]
|
|
193
|
+
const is_last = last.data.saveID === curren.data.saveID;
|
|
194
|
+
//const data = map.get(step_new)
|
|
195
|
+
if (curren.data.groupID === 1 && next && next.data.groupID === 1) {
|
|
196
|
+
this.callMessageNet?.(step_new, () => { }) // 新手强引导
|
|
197
|
+
}
|
|
198
|
+
else if (curren.data.groupID === 1 && next && next.data.groupID !== 1 || is_last) {
|
|
199
|
+
let step_net = this.step
|
|
200
|
+
//GuideModule.StartGuideGroup(this.guide.GuideModel.currentPrompt.data.enableGroup)
|
|
201
|
+
// Log.error("开始引导", this.guide.GuideModel.currentPrompt.data.groupID, this.guide.GuideModel.currentPrompt.data.enableGroup)
|
|
202
|
+
const enableGroup = this.guide.GuideModel.currentPrompt.data.enableGroup
|
|
203
|
+
if (enableGroup > 0) {
|
|
204
|
+
const step = this.guide.GuideModel.guide_group.get(enableGroup)[0].data.id
|
|
205
|
+
this.step = step - 1
|
|
206
|
+
step_net = step
|
|
207
|
+
} else {
|
|
208
|
+
this.step = 100000
|
|
209
|
+
step_net = this.step;
|
|
210
|
+
GuideModule.GuideCenter.callFinishGroup?.()
|
|
211
|
+
}
|
|
212
|
+
this.callMessageNet?.(step_net, () => { }) //功能引导
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this.callMessageNet?.(step_new, () => { }) //功能引导
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
refresh() {
|
|
221
|
+
const curren = this.guide.GuideModel.prompts[this.step];
|
|
222
|
+
if (!curren || !curren.data) {
|
|
223
|
+
Log.log("当前无引导");
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
if (curren.data.groupID !== 1) {
|
|
227
|
+
|
|
228
|
+
} else {
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const ui_com_map = this.guide.GuideModel.ui_com_map;
|
|
233
|
+
const guides = this.guide.GuideModel.guides;
|
|
234
|
+
const save_map = this.guide.GuideModel.save_map;
|
|
235
|
+
const guide_group_list = this.guide.GuideModel.guide_group.get(curren.data.groupID);
|
|
236
|
+
let step_first = 0;
|
|
237
|
+
let prompts = [...this.guide.GuideModel.prompts].splice(1, this.step - 1);
|
|
238
|
+
prompts.sort((a, b) => b.data.id - a.data.id)
|
|
239
|
+
prompts.forEach(element => {
|
|
240
|
+
const saveID = element.data.saveID;
|
|
241
|
+
if (saveID === element.data.step) {
|
|
242
|
+
save_map.get(saveID).forEach(element => { element.is_finish = true });//引导完成
|
|
243
|
+
// Log.error('引导完成', element.data.GuideGroupID, saveID)
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
//找到下一个没有执行的存储点
|
|
247
|
+
const _guide_group_list = [...guide_group_list].sort((a, b) => b.data.id - a.data.id)
|
|
248
|
+
_guide_group_list.forEach(element => {
|
|
249
|
+
const saveID = element.data.saveID;
|
|
250
|
+
if (saveID > curren.data.saveID) {
|
|
251
|
+
step_first = saveID
|
|
252
|
+
}
|
|
253
|
+
const save_data = save_map.get(saveID)?.[0]
|
|
254
|
+
if (save_data && !save_data.is_finish) {
|
|
255
|
+
step_first = save_data.data.saveID
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// prompts.forEach(element => {
|
|
260
|
+
// const saveID = element.data.saveID;
|
|
261
|
+
// if (saveID > curren.data.saveID) {
|
|
262
|
+
// step_first = saveID
|
|
263
|
+
// }
|
|
264
|
+
// const save_data = save_map.get(saveID)?.[0]
|
|
265
|
+
// if (save_data && !save_data.is_finish) {
|
|
266
|
+
// step_first = save_data.data.saveID
|
|
267
|
+
// }
|
|
268
|
+
// });
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
Log.log("引导当前步数:", this.step, step_first);
|
|
272
|
+
if (step_first > 0) {
|
|
273
|
+
this.step = save_map.get(step_first)[0].data.id
|
|
274
|
+
} else {
|
|
275
|
+
//有引导组,并且引导组没有完成
|
|
276
|
+
const group = save_map.get(curren.data.saveID);
|
|
277
|
+
if (group) {
|
|
278
|
+
if (group[0].is_finish) {
|
|
279
|
+
for (let index = 0; index < guide_group_list.length; index++) {
|
|
280
|
+
const element = guide_group_list[index];
|
|
281
|
+
if (!element.is_finish) {
|
|
282
|
+
this.step = element.data.id
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
this.step = group[0].data.id
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
Log.log("引导当前步数-刷新后:", this.step);
|
|
293
|
+
Log.log("引导数据", this.guide.GuideModel.prompts);
|
|
294
|
+
|
|
295
|
+
// ui_com_map.forEach((value, key) => {
|
|
296
|
+
// value.forEach(element => {
|
|
297
|
+
// const com = this.node.getComponentInChildren(key)
|
|
298
|
+
// if (com) {
|
|
299
|
+
// com.interactable = true
|
|
300
|
+
// }
|
|
301
|
+
// });
|
|
302
|
+
// });
|
|
303
|
+
//跳转指定页面
|
|
304
|
+
if (IsJson(curren.data.jumpWindow)) {
|
|
305
|
+
const urls: string[] = JSON.parse(curren.data.jumpWindow)//curren.data.jumpWindow?.toArray<string>() ?? []
|
|
306
|
+
this.callJumpWindow?.(urls)
|
|
307
|
+
} else {
|
|
308
|
+
Log.error("jumpWindow 参数格式错误")
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
OnMessageStep(call: (param: ITableGuide) => void) {
|
|
313
|
+
this.callMessage = call
|
|
314
|
+
}
|
|
315
|
+
OnMessageStepNet(call: (step: number, finish: Function) => void) {
|
|
316
|
+
this.callMessageNet = call
|
|
317
|
+
}
|
|
318
|
+
OnMessageClick(call: (step: number) => void) {
|
|
319
|
+
this.callClick = call
|
|
320
|
+
}
|
|
321
|
+
OnMessageJumpWindow(call: (urls: string[]) => void) {
|
|
322
|
+
this.callJumpWindow = call
|
|
323
|
+
}
|
|
324
|
+
OnMessageFinishGroup(call: () => void) {
|
|
325
|
+
this.callFinishGroup = call
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
LoadSprite(sp: Sprite, param: string, callback?: () => void) {
|
|
329
|
+
const path = param + '/spriteFrame'
|
|
330
|
+
const bundleName = this.param.bundleName
|
|
331
|
+
const bundle = assetManager.getBundle(bundleName)
|
|
332
|
+
const sprite = bundle.get(path, SpriteFrame)
|
|
333
|
+
if (sprite) {
|
|
334
|
+
if (isValid(sp, true)) {
|
|
335
|
+
sp.spriteFrame = sprite;
|
|
336
|
+
callback?.()
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
Log.log("图片已销毁")
|
|
340
|
+
}
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
bundle.load(path, SpriteFrame, (err, res) => {
|
|
344
|
+
if (err) {
|
|
345
|
+
Log.error('包:' + bundleName, " 图片路径不对:", path)
|
|
346
|
+
}
|
|
347
|
+
else if (sp) {
|
|
348
|
+
if (isValid(sp, true)) {
|
|
349
|
+
sp.spriteFrame = res;
|
|
350
|
+
callback?.()
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
Log.log("图片已销毁")
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
})
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
spriteRootPath(name: string) { return `${this.param.spriteRootPath}/${name}` }
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { GuideCenter } from "./GuideCenter";
|
|
2
|
+
import { Node } from "cc";
|
|
3
|
+
import { IGuideData } from "./model/GuideCommon";
|
|
4
|
+
import { ITableGuide } from "./model/ITableGuide";
|
|
5
|
+
import { IsJson } from "../common/GuideTool";
|
|
6
|
+
import { Log } from "../common/Log";
|
|
7
|
+
|
|
8
|
+
export class GuideSDK {
|
|
9
|
+
|
|
10
|
+
current_setp = 0;
|
|
11
|
+
|
|
12
|
+
static async init(node: Node, step: number, param: IGuideData): Promise<void> {
|
|
13
|
+
return GuideCenter.instance.init(node, step, param);
|
|
14
|
+
}
|
|
15
|
+
static step(value: number) {
|
|
16
|
+
GuideCenter.instance.step = value === 0 ? 0 : value;
|
|
17
|
+
GuideCenter.instance.refresh();
|
|
18
|
+
}
|
|
19
|
+
static getSetp() {
|
|
20
|
+
return GuideCenter.instance.step;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 检查指定引导是否触发 */
|
|
24
|
+
static check(step: number) {
|
|
25
|
+
GuideCenter.instance.check(step === 0 ? 0 : step);
|
|
26
|
+
GuideCenter.instance.refresh();
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static save(value) {
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static async startGuideGroup(group_id: number) {
|
|
35
|
+
return GuideCenter.instance.startGuideGroup(group_id);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
GuideModel() {
|
|
39
|
+
return GuideCenter.instance.guide.GuideModel;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static MoveTo(param: any, window_name: string): { window: string, value: any } {
|
|
43
|
+
const guide: ITableGuide = param;
|
|
44
|
+
if (guide?.move) {
|
|
45
|
+
if (IsJson(guide.move)) {
|
|
46
|
+
const data: Record<string, any> = JSON.parse(guide.move)// guide.move.toMap<string, any>()
|
|
47
|
+
const key = Array.from(Object.keys(data))[0]
|
|
48
|
+
if (key === window_name) {
|
|
49
|
+
const value = data[key]
|
|
50
|
+
return { window: key, value: value }
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
Log.error("move参数格式错误,请检查")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static GuideShow() {
|
|
60
|
+
return GuideCenter.instance.guide.GuideView.isGuideShow()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// static loadData() {
|
|
65
|
+
|
|
66
|
+
// GuideSDK.step(1);
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ITableGuide } from "./ITableGuide";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export enum GuideCommon {
|
|
5
|
+
Full = 0, // 有对话框 有手
|
|
6
|
+
Hard = 1,// 仅小手
|
|
7
|
+
Box = 2,// 仅对话框
|
|
8
|
+
None = 3 // 都无
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export interface IGuideData {
|
|
14
|
+
/**资源bundle-引导 */
|
|
15
|
+
bundleName: string;
|
|
16
|
+
/**图片资源根路径 */
|
|
17
|
+
spriteRootPath: string;
|
|
18
|
+
/**资源表json */
|
|
19
|
+
tableGuide: Map<number, ITableGuide>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum GuideStep {
|
|
23
|
+
/**客户端:更新了引导步骤 */
|
|
24
|
+
GuideEventStep = "GuideEventStep",
|
|
25
|
+
/**服务器:需要你更新服务器的步骤 */
|
|
26
|
+
GuideEventStepNet = "GuideEventStepNet",
|
|
27
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: dgflash
|
|
3
|
+
* @Date: 2022-03-21 11:12:03
|
|
4
|
+
* @LastEditors: dgflash
|
|
5
|
+
* @LastEditTime: 2022-09-06 10:12:03
|
|
6
|
+
*/
|
|
7
|
+
import { Node } from "cc";
|
|
8
|
+
import { GuideViewItem } from "../view/GuideViewItem";
|
|
9
|
+
import { ITableGuide } from "./ITableGuide";
|
|
10
|
+
import { IGuideData } from "./GuideCommon";
|
|
11
|
+
import { Log } from "../../common/Log";
|
|
12
|
+
|
|
13
|
+
/** 引导数据 */
|
|
14
|
+
export class GuideModelComp {
|
|
15
|
+
/** 当前引导步骤 */
|
|
16
|
+
_step: number = 1;
|
|
17
|
+
/** 当前引导步骤 */
|
|
18
|
+
set step(value: number) {
|
|
19
|
+
this._step = value;
|
|
20
|
+
// if (this.currentPrompt)
|
|
21
|
+
// GuideModule.GuideCenter.callMessage?.(this.currentPrompt.data)
|
|
22
|
+
};
|
|
23
|
+
get step(): number {
|
|
24
|
+
return this._step;
|
|
25
|
+
};
|
|
26
|
+
/** 最后一步索引 */
|
|
27
|
+
last: number = Number.MAX_VALUE;
|
|
28
|
+
/** 引导的节点 */
|
|
29
|
+
guides: Map<number, Node> = new Map();
|
|
30
|
+
|
|
31
|
+
/** 资源文件夹 */
|
|
32
|
+
res_dir = "interface/guide";
|
|
33
|
+
/** 遮罩预制资源 */
|
|
34
|
+
res_mask = "interface/guide/mask";
|
|
35
|
+
/** 提示预制资源 */
|
|
36
|
+
res_prompt = "interface/guide/prompt";
|
|
37
|
+
|
|
38
|
+
current_bg = ''
|
|
39
|
+
/** 当前准备引导的节点 */
|
|
40
|
+
get current(): Node | undefined {
|
|
41
|
+
return this.guides.get(this.step);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
get currentPrompt() {
|
|
46
|
+
return this.prompts[this.step]
|
|
47
|
+
}
|
|
48
|
+
get npc_icon(): string {
|
|
49
|
+
return this.currentPrompt.data.npcAvator
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get npc_name(): string {
|
|
53
|
+
return this.currentPrompt.data.npcName
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
reset(): void {
|
|
57
|
+
this.step = 1;
|
|
58
|
+
this.last = Number.MAX_VALUE;
|
|
59
|
+
|
|
60
|
+
this.guides.forEach(node => {
|
|
61
|
+
if (node.isValid) node.getComponent(GuideViewItem)!.destroy();
|
|
62
|
+
});
|
|
63
|
+
this.guides.clear();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 提示词数据 */
|
|
67
|
+
// prompts: any = {
|
|
68
|
+
// 1: "提示词1",
|
|
69
|
+
// 2: "提示词2",
|
|
70
|
+
// 4: "提示词3",
|
|
71
|
+
// 5: "提示词5",
|
|
72
|
+
// 6: "提示词6",
|
|
73
|
+
// 8: "提示词8",
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
prompts: { is_week: boolean, is_finish: boolean, data: ITableGuide }[] = []
|
|
78
|
+
ui_com_map = new Map<string, number[]>();
|
|
79
|
+
ui_com_choose_map = new Map<string, { index: number, step: number }[]>();
|
|
80
|
+
|
|
81
|
+
save_map = new Map<number, { is_week: boolean, is_finish: boolean, data: ITableGuide }[]>();
|
|
82
|
+
guide_group = new Map<number, { is_week: boolean, is_finish: boolean, data: ITableGuide }[]>();
|
|
83
|
+
table: Map<number, ITableGuide> = new Map();
|
|
84
|
+
get is_week(): boolean {
|
|
85
|
+
return false//this.prompts[this.step].is_week;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
loadData(param: IGuideData) {
|
|
89
|
+
this.table = param.tableGuide
|
|
90
|
+
this.prompts.push({ is_week: false, is_finish: false, data: null })
|
|
91
|
+
this.table.forEach((element, key) => {
|
|
92
|
+
const data = { is_week: false, is_finish: key === 2 ? false : false, data: element }
|
|
93
|
+
this.prompts.push(data)
|
|
94
|
+
const map_key = element.clickArea
|
|
95
|
+
if (map_key) {
|
|
96
|
+
//ui
|
|
97
|
+
if (!this.ui_com_map.has(map_key)) {
|
|
98
|
+
this.ui_com_map.set(map_key, [])
|
|
99
|
+
}
|
|
100
|
+
this.ui_com_map.get(map_key).push(key)
|
|
101
|
+
|
|
102
|
+
//存档
|
|
103
|
+
if (!this.save_map.has(element.saveID)) {
|
|
104
|
+
this.save_map.set(element.saveID, [])
|
|
105
|
+
}
|
|
106
|
+
this.save_map.get(element.saveID).push(data)
|
|
107
|
+
//选项
|
|
108
|
+
if (!this.guide_group.has(element.groupID)) {
|
|
109
|
+
this.guide_group.set(element.groupID, [])
|
|
110
|
+
}
|
|
111
|
+
this.guide_group.get(element.groupID).push(data)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Log.warn("引导数据加载完成", this.ui_com_map)
|
|
117
|
+
// Log.warn("引导数据加载完成", this.prompts)
|
|
118
|
+
|
|
119
|
+
this.refeshStepLast()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//模块独立
|
|
123
|
+
// prompts: ITableGuide[] = []
|
|
124
|
+
// loadData2() {
|
|
125
|
+
// var table = GuideModule.get(TableGuideTest.TableName);
|
|
126
|
+
// const keys = Object.keys(table)
|
|
127
|
+
// for (const index in keys) {
|
|
128
|
+
// const key = Number(keys[index]);
|
|
129
|
+
// var guide = new TableGuideTest();
|
|
130
|
+
// guide.init(key);
|
|
131
|
+
// this.prompts.push(guide)
|
|
132
|
+
// }
|
|
133
|
+
// for (var i = 0; i < table.length; i++) {
|
|
134
|
+
|
|
135
|
+
// }
|
|
136
|
+
|
|
137
|
+
// Log.error("引导数据加载完成", this.prompts)
|
|
138
|
+
|
|
139
|
+
// }
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
refesh() {
|
|
143
|
+
Log.log("引导数据刷新", this._step)
|
|
144
|
+
while (this._step < this.prompts.length) {
|
|
145
|
+
const prompt = this.prompts[this._step]
|
|
146
|
+
if (prompt.is_finish) {
|
|
147
|
+
this._step++
|
|
148
|
+
} else {
|
|
149
|
+
Log.log("引导数据刷新2", this._step)
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
refeshStepLast() {
|
|
157
|
+
this.last = this.prompts[this.prompts.length - 1].data.id;
|
|
158
|
+
Log.log("引导最大步数", this.last)
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ITableGuide {
|
|
2
|
+
/** 编号【KEY】-引导步骤 */
|
|
3
|
+
id: number;
|
|
4
|
+
/** 点击位置 */
|
|
5
|
+
clickArea: string;
|
|
6
|
+
/** 框选位置备注 */
|
|
7
|
+
Des: string;
|
|
8
|
+
/** 步数 */
|
|
9
|
+
step: number;
|
|
10
|
+
/** 存档节点 */
|
|
11
|
+
saveID: number;
|
|
12
|
+
/** 引导组ID */
|
|
13
|
+
groupID: number;
|
|
14
|
+
/** 展示类型 */
|
|
15
|
+
showType: number;
|
|
16
|
+
/**npc名 */
|
|
17
|
+
npcName: string;
|
|
18
|
+
/**npc头像 */
|
|
19
|
+
npcAvator: string;
|
|
20
|
+
/** 对话内容 */
|
|
21
|
+
contentKey: string;
|
|
22
|
+
/** 界面移动 */
|
|
23
|
+
move: string;
|
|
24
|
+
/** 背景图 */
|
|
25
|
+
backgroundImage: string;
|
|
26
|
+
/** 引导跳界面 */
|
|
27
|
+
jumpWindow: string;
|
|
28
|
+
/** 对话框Y轴坐标 */
|
|
29
|
+
dialogY: number;
|
|
30
|
+
/** 节点显示触发引导组 */
|
|
31
|
+
enableGroup: number;
|
|
32
|
+
}
|