@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,150 @@
|
|
|
1
|
+
import { GraphicsComponent } from 'cc';
|
|
2
|
+
import { Graphics } from 'cc';
|
|
3
|
+
import { Color } from 'cc';
|
|
4
|
+
import { Mask } from 'cc';
|
|
5
|
+
import { _decorator, Component, Node } from 'cc';
|
|
6
|
+
|
|
7
|
+
const { ccclass, property } = _decorator;
|
|
8
|
+
|
|
9
|
+
@ccclass('GuideTest')
|
|
10
|
+
export class GuideTest extends Component {
|
|
11
|
+
@property(Mask)
|
|
12
|
+
mask: Mask = null!;
|
|
13
|
+
|
|
14
|
+
@property(Graphics)
|
|
15
|
+
graphics: Graphics = null!;
|
|
16
|
+
|
|
17
|
+
protected onLoad(): void {
|
|
18
|
+
this.drawCircleWithInnerBlur(0, 0, 500);
|
|
19
|
+
|
|
20
|
+
// this.drawRectWithGradient()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 绘制带有透明度渐变的圆形遮罩 */
|
|
24
|
+
drawCircleWithGradient(centerX: number, centerY: number, radius: number, gradientWidth: number = 20): void {
|
|
25
|
+
// if (this.mask.type !== Mask.Type.GRAPHICS_STENCIL) {
|
|
26
|
+
// return;
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
var g: Graphics = this.graphics;
|
|
30
|
+
g.clear();
|
|
31
|
+
|
|
32
|
+
// 绘制中心不透明圆形
|
|
33
|
+
g.fillColor = new Color(0, 0, 0, 255);
|
|
34
|
+
g.circle(centerX, centerY, radius);
|
|
35
|
+
g.fill();
|
|
36
|
+
|
|
37
|
+
// 创建渐变边缘(通过多个半透明圆环实现)
|
|
38
|
+
const steps = 15;
|
|
39
|
+
for (let i = 1; i <= steps; i++) {
|
|
40
|
+
const progress = i / steps;
|
|
41
|
+
const currentRadius = radius + gradientWidth * progress;
|
|
42
|
+
const alpha = Math.floor(255 * (1 - progress));
|
|
43
|
+
|
|
44
|
+
g.fillColor = new Color(0, 0, 0, alpha);
|
|
45
|
+
g.circle(centerX, centerY, currentRadius);
|
|
46
|
+
g.fill();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** 绘制带有从中心向边缘渐变的圆形遮罩 */
|
|
51
|
+
drawCircleWithInnerBlur2(centerX: number, centerY: number, radius: number, blurWidth: number = 20): void {
|
|
52
|
+
var g: Graphics = this.graphics;
|
|
53
|
+
g.clear();
|
|
54
|
+
|
|
55
|
+
// 从内向外绘制多个半透明圆环,实现向外渐变效果
|
|
56
|
+
const steps = 20;
|
|
57
|
+
for (let i = steps; i >= 1; i--) {
|
|
58
|
+
const progress = i / steps;
|
|
59
|
+
const currentRadius = radius * progress;
|
|
60
|
+
// 从中心到边缘,透明度逐渐增加
|
|
61
|
+
const alpha = Math.floor(255 * (1 - progress));
|
|
62
|
+
|
|
63
|
+
g.fillColor = new Color(0, 0, 0, alpha);
|
|
64
|
+
g.circle(centerX, centerY, currentRadius);
|
|
65
|
+
g.fill();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
drawCircleWithInnerBlur(centerX: number, centerY: number, radius: number): void {
|
|
69
|
+
const g: Graphics = this.graphics;
|
|
70
|
+
g.clear(); // 清空之前的绘制
|
|
71
|
+
|
|
72
|
+
const steps = 3; // 渐变的步数,越高越平滑
|
|
73
|
+
const maxAlpha = 255; // 最大透明度
|
|
74
|
+
const minAlpha = 0; // 最小透明度
|
|
75
|
+
|
|
76
|
+
// 从内到外逐步绘制多个圆形,透明度逐渐增加
|
|
77
|
+
for (let i = 0; i < steps; i++) {
|
|
78
|
+
const progress = i / (steps - 1); // 计算每一步的进度(从 0 到 1)
|
|
79
|
+
const currentRadius = radius * progress; // 当前圆的半径
|
|
80
|
+
const alpha = Math.floor(maxAlpha * progress); // 计算透明度,越远离中心越不透明
|
|
81
|
+
|
|
82
|
+
// 设置每个圆的填充颜色,透明度逐渐增加
|
|
83
|
+
g.fillColor = new Color(0, 0, 0, 20); // 黑色,透明度渐变
|
|
84
|
+
g.circle(centerX, centerY, currentRadius); // 绘制圆形
|
|
85
|
+
g.fill(); // 填充当前圆形
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
/** 绘制带边缘渐变的矩形遮罩 */
|
|
95
|
+
drawRectWithGradient(x: number, y: number, width: number, height: number, gradientWidth: number = 20): void {
|
|
96
|
+
if (this.mask.type !== Mask.Type.GRAPHICS_STENCIL) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var g: GraphicsComponent = this.graphics;
|
|
101
|
+
g.clear();
|
|
102
|
+
|
|
103
|
+
// 绘制中心不透明矩形
|
|
104
|
+
g.fillColor = new Color(0, 0, 0, 255);
|
|
105
|
+
g.rect(x, y, width, height);
|
|
106
|
+
g.fill();
|
|
107
|
+
|
|
108
|
+
// 绘制渐变边缘
|
|
109
|
+
const steps = 10;
|
|
110
|
+
for (let i = 1; i <= steps; i++) {
|
|
111
|
+
const progress = i / steps;
|
|
112
|
+
const alpha = Math.floor(255 * (1 - progress));
|
|
113
|
+
const currentColor = new Color(0, 0, 0, alpha);
|
|
114
|
+
|
|
115
|
+
// 上边缘
|
|
116
|
+
g.fillColor = currentColor;
|
|
117
|
+
g.rect(x - gradientWidth * progress, y + height, gradientWidth * progress * 2 + width, gradientWidth * progress);
|
|
118
|
+
g.fill();
|
|
119
|
+
|
|
120
|
+
// 下边缘
|
|
121
|
+
g.fillColor = currentColor;
|
|
122
|
+
g.rect(x - gradientWidth * progress, y - gradientWidth * progress, gradientWidth * progress * 2 + width, gradientWidth * progress);
|
|
123
|
+
g.fill();
|
|
124
|
+
|
|
125
|
+
// 左边缘
|
|
126
|
+
g.fillColor = currentColor;
|
|
127
|
+
g.rect(x - gradientWidth * progress, y, gradientWidth * progress, height);
|
|
128
|
+
g.fill();
|
|
129
|
+
|
|
130
|
+
// 右边缘
|
|
131
|
+
g.fillColor = currentColor;
|
|
132
|
+
g.rect(x + width, y, gradientWidth * progress, height);
|
|
133
|
+
g.fill();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
yang() {
|
|
138
|
+
const g = this.graphics
|
|
139
|
+
g.lineWidth = 10;
|
|
140
|
+
g.fillColor.fromHEX('#00ccffff');
|
|
141
|
+
g.strokeColor = Color.GREEN
|
|
142
|
+
g.moveTo(-40, 0);
|
|
143
|
+
g.lineTo(0, -80);
|
|
144
|
+
g.lineTo(40, 0);
|
|
145
|
+
g.lineTo(0, 80);
|
|
146
|
+
g.close();
|
|
147
|
+
g.stroke();
|
|
148
|
+
g.fill();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: dgflash
|
|
3
|
+
* @Date: 2021-07-03 16:13:17
|
|
4
|
+
* @LastEditors: dgflash
|
|
5
|
+
* @LastEditTime: 2022-09-06 10:16:57
|
|
6
|
+
*/
|
|
7
|
+
import { Button, EventTouch, Node, _decorator } from "cc";
|
|
8
|
+
|
|
9
|
+
import { GuideModelComp } from "../model/GuideModelComp";
|
|
10
|
+
import { GuideViewMask } from "./GuideViewMask";
|
|
11
|
+
import { GuideViewPrompt } from "./GuideViewPrompt";
|
|
12
|
+
|
|
13
|
+
import { isValid } from "cc";
|
|
14
|
+
import { sp } from "cc";
|
|
15
|
+
import { GuideViewItem } from "./GuideViewItem";
|
|
16
|
+
import { Component } from "cc";
|
|
17
|
+
import { Log } from "../../common/Log";
|
|
18
|
+
|
|
19
|
+
const { ccclass, property } = _decorator;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 新手引导界面管理
|
|
23
|
+
*/
|
|
24
|
+
@ccclass('GuideViewComp')
|
|
25
|
+
export class GuideViewComp extends Component {
|
|
26
|
+
@property({ type: sp.Skeleton })
|
|
27
|
+
skel: sp.Skeleton;
|
|
28
|
+
/** 引导数据 */
|
|
29
|
+
private model: GuideModelComp = null!;
|
|
30
|
+
/** 引导遮罩 */
|
|
31
|
+
private mask: GuideViewMask = null!;
|
|
32
|
+
/** 引导提示动画 */
|
|
33
|
+
private prompt: GuideViewPrompt = null!;
|
|
34
|
+
step_week = -1
|
|
35
|
+
|
|
36
|
+
nextCall: Function;
|
|
37
|
+
|
|
38
|
+
protected onLoad(): void {
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
start() {
|
|
42
|
+
this.model = GuideModule.GuideCenter.guide.GuideModel//this.ent.get(GuideModelComp);
|
|
43
|
+
|
|
44
|
+
this.prompt = this.node.addComponent(GuideViewPrompt);
|
|
45
|
+
this.prompt.model = this.model;
|
|
46
|
+
this.mask = this.node.addComponent(GuideViewMask);
|
|
47
|
+
this.mask.model = this.model;
|
|
48
|
+
|
|
49
|
+
this.mask.clickMask = () => {
|
|
50
|
+
const data = this.model.prompts[this.model.step]
|
|
51
|
+
GuideModule.GuideCenter.is_guide_week = data.is_week
|
|
52
|
+
if (data.is_week) {
|
|
53
|
+
this.mask.hideUI(false);
|
|
54
|
+
this.prompt.hideUI(false);
|
|
55
|
+
this.prompt.hideHard(false);
|
|
56
|
+
|
|
57
|
+
this.mask.hide();
|
|
58
|
+
this.prompt.hide();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 注册引导项 */
|
|
64
|
+
register(step: number, Node: Node) {
|
|
65
|
+
|
|
66
|
+
// if (step === 53) {
|
|
67
|
+
|
|
68
|
+
// Log.error('注册引导项', step, Node.parent.name, Node.name)
|
|
69
|
+
// Log.error('注册引导项', this.model.guides.get(53)?.name)
|
|
70
|
+
|
|
71
|
+
// return
|
|
72
|
+
// }
|
|
73
|
+
this.model.guides.set(step, Node);
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** 下一个引导 */
|
|
78
|
+
next() {
|
|
79
|
+
this.model.step++;
|
|
80
|
+
this.model.refesh();
|
|
81
|
+
this.nextCall?.()
|
|
82
|
+
Log.log(`验证下一个引擎【${this.model.step}】-${this.model.last}`);
|
|
83
|
+
if (this.model.step === 100001) {
|
|
84
|
+
this.mask.hide();
|
|
85
|
+
this.prompt.hide();
|
|
86
|
+
}
|
|
87
|
+
else if (this.model.step > this.model.last && this.model.step < 100000) {
|
|
88
|
+
this.mask.hide();
|
|
89
|
+
this.prompt.hide();
|
|
90
|
+
Log.log(`全部结束`);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.check();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** 验证引导 */
|
|
98
|
+
check(comName?: string) {
|
|
99
|
+
|
|
100
|
+
// if(this.model.step === 4){
|
|
101
|
+
// Log.error('引导打印',4)
|
|
102
|
+
// return
|
|
103
|
+
// }
|
|
104
|
+
// 延时处理是为了避免与cc.Widget组件冲突,引导遮罩出现后,组件位置变了
|
|
105
|
+
this.scheduleOnce(() => {
|
|
106
|
+
let btn = this.getTargetNode()
|
|
107
|
+
if ((btn == null || !isValid(btn, true))) {
|
|
108
|
+
this.mask.hide();
|
|
109
|
+
this.prompt.hide();
|
|
110
|
+
|
|
111
|
+
Log.log(`暂无引导`)
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
Log.log(`当前步骤:${this.model.step} 引导事件节点:${btn.name}--父节点:${btn.parent.name}`)
|
|
115
|
+
GuideModule.GuideCenter.callMessage?.(this.model.currentPrompt.data)
|
|
116
|
+
|
|
117
|
+
GuideModule.GuideCenter.is_guide_week = false;
|
|
118
|
+
// const is_choose = this.model.step === 5 || this.model.step === 6
|
|
119
|
+
// if (is_choose) {
|
|
120
|
+
// this.mask.node.active = true;
|
|
121
|
+
// this.mask.hideUI(false)
|
|
122
|
+
// } else {
|
|
123
|
+
this.mask.draw(btn);
|
|
124
|
+
//Log.warn('2引导打印', this.model.step)
|
|
125
|
+
if (this.model.step !== 4) {
|
|
126
|
+
|
|
127
|
+
// }
|
|
128
|
+
}
|
|
129
|
+
//Log.warn('1引导打印', this.model.step)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
this.prompt.show(btn);
|
|
133
|
+
//Log.warn('3引导打印', this.model.step)
|
|
134
|
+
|
|
135
|
+
this.prompt.showPrompt();
|
|
136
|
+
//Log.warn('4引导打印', this.model.step)
|
|
137
|
+
|
|
138
|
+
// 引导节点加触摸事件,跳到下一步
|
|
139
|
+
btn.on(Node.EventType.TOUCH_END, this.onTouchEnd, this, false);
|
|
140
|
+
btn.on(Node.EventType.TRANSFORM_CHANGED, this.onTransformChanged, this);
|
|
141
|
+
this.mask.dispatchEvent = (event, target) => {
|
|
142
|
+
this.onTouchEnd(event, target)
|
|
143
|
+
}
|
|
144
|
+
//Log.warn('5引导打印', this.model.step)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private onTransformChanged() {
|
|
152
|
+
this.refresh();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private onTouchEnd(event: EventTouch, target?: Node) {
|
|
156
|
+
try {
|
|
157
|
+
//Log.error('引导3', this.model.step)
|
|
158
|
+
let target_btn = this.getTargetNode()
|
|
159
|
+
if ((target_btn == null || !isValid(target_btn, true) || !target_btn.activeInHierarchy) && !this.isHavePathNode(target_btn)) {
|
|
160
|
+
|
|
161
|
+
this.mask.hide();
|
|
162
|
+
this.prompt.hide();
|
|
163
|
+
Log.log(`暂无引导-目前节点隐藏了`, target_btn?.name)
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
//event.preventSwallow = true;
|
|
168
|
+
// var btn = event.target as Node;
|
|
169
|
+
let btn = target;
|
|
170
|
+
if (!isValid(btn, true)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
btn.off(Node.EventType.TOUCH_END, this.onTouchEnd, this, false);
|
|
174
|
+
btn.off(Node.EventType.TRANSFORM_CHANGED, this.onTransformChanged, this);
|
|
175
|
+
|
|
176
|
+
// 触发按钮组件
|
|
177
|
+
var button = btn.getComponent(Button);
|
|
178
|
+
if (button) {
|
|
179
|
+
if (event["_other_button"]) {
|
|
180
|
+
event["_other_button"] = null;
|
|
181
|
+
const view = btn.getComponent(GuideViewItem)
|
|
182
|
+
const other_button = view.findNodeButton()
|
|
183
|
+
const is_ok = other_button && other_button.isValid && other_button.node.activeInHierarchy && other_button.interactable
|
|
184
|
+
other_button.clickEvents.forEach((e, index) => {
|
|
185
|
+
if (is_ok)
|
|
186
|
+
e.emit([event]);
|
|
187
|
+
if (index === 0) {
|
|
188
|
+
this.onClick()
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
} else {
|
|
193
|
+
button.clickEvents.forEach((e, index) => {
|
|
194
|
+
if (button.interactable)
|
|
195
|
+
e.emit([event]);
|
|
196
|
+
if (index === 0) {
|
|
197
|
+
this.onClick()
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
const item = this.model.current
|
|
203
|
+
if (item && isValid(item, true)) {
|
|
204
|
+
const view = item.getComponent(GuideViewItem)
|
|
205
|
+
//按钮
|
|
206
|
+
let target_button = view.findButton()
|
|
207
|
+
const clickEvents = target_button?.clickEvents ?? [];
|
|
208
|
+
if (target_button?.interactable) {
|
|
209
|
+
clickEvents.forEach((e, index) => { e.emit([event]); });
|
|
210
|
+
}
|
|
211
|
+
//解决用node.on("click") 监听的事件
|
|
212
|
+
if (target_button && clickEvents.length <= 0) {
|
|
213
|
+
if (target_button.interactable) {
|
|
214
|
+
target_button.node.emit("click");
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
//toggle组件
|
|
219
|
+
const target_toggle = view.findToggle()
|
|
220
|
+
const target_toggle_container = view.findToggleContainer()
|
|
221
|
+
if (target_toggle_container && target_toggle) {
|
|
222
|
+
target_toggle_container?.checkEvents.forEach(event => {
|
|
223
|
+
if (target_toggle.interactable)
|
|
224
|
+
event.emit([target_toggle]);
|
|
225
|
+
})
|
|
226
|
+
} else {
|
|
227
|
+
btn.dispatchEvent(event)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
this.onClick()
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
this.next();
|
|
236
|
+
} catch (error) {
|
|
237
|
+
|
|
238
|
+
Log.error('报错了:', error)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** 刷新引导位置 */
|
|
244
|
+
refresh() {
|
|
245
|
+
let btn = this.model.guides.has(this.model.step) ? this.model.guides.get(this.model.step) : null;
|
|
246
|
+
if (btn && isValid(btn, true)) {
|
|
247
|
+
this.mask.draw(btn);
|
|
248
|
+
this.prompt.show(btn);
|
|
249
|
+
this.prompt.showPrompt();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
reset(): void {
|
|
254
|
+
this.model = null!;
|
|
255
|
+
this.mask.destroy();
|
|
256
|
+
this.prompt.destroy();
|
|
257
|
+
this.destroy();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
logout() {
|
|
261
|
+
this.mask.hide()
|
|
262
|
+
}
|
|
263
|
+
hideUI() {
|
|
264
|
+
return
|
|
265
|
+
const data = this.model.prompts[this.model.step]
|
|
266
|
+
const isShow: boolean = !data.is_week
|
|
267
|
+
this.mask.hideUI(isShow);
|
|
268
|
+
this.prompt.hideUI(isShow);
|
|
269
|
+
// this.prompt.hideHard(isShow)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
onClick() {
|
|
273
|
+
GuideModule.GuideCenter.onClick()
|
|
274
|
+
}
|
|
275
|
+
isGuideShow() {
|
|
276
|
+
|
|
277
|
+
//引导
|
|
278
|
+
return this.mask.isGuideShow()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
isHavePathNode(target_btn) {
|
|
282
|
+
if (target_btn && target_btn.isValid) {
|
|
283
|
+
const item = this.model.current
|
|
284
|
+
const view = item.getComponent(GuideViewItem)
|
|
285
|
+
const node = view.findNode()
|
|
286
|
+
|
|
287
|
+
return node && node.activeInHierarchy ? true : false
|
|
288
|
+
}
|
|
289
|
+
return false
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
getTargetNode() {
|
|
293
|
+
|
|
294
|
+
return this.model.guides.has(this.model.step) ? this.model.guides.get(this.model.step) : null;
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: dgflash
|
|
3
|
+
* @Date: 2022-03-14 11:18:54
|
|
4
|
+
* @LastEditors: dgflash
|
|
5
|
+
* @LastEditTime: 2022-04-13 10:34:33
|
|
6
|
+
*/
|
|
7
|
+
import { Button } from "cc";
|
|
8
|
+
import { ToggleContainer } from "cc";
|
|
9
|
+
import { Toggle } from "cc";
|
|
10
|
+
import { CCInteger, Component, _decorator } from "cc";
|
|
11
|
+
import { Log } from "../../common/Log";
|
|
12
|
+
|
|
13
|
+
const { ccclass, property } = _decorator;
|
|
14
|
+
|
|
15
|
+
/** 新手引导数据(绑定到引导节点上) */
|
|
16
|
+
@ccclass('GuideViewItem')
|
|
17
|
+
export class GuideViewItem extends Component {
|
|
18
|
+
@property({
|
|
19
|
+
type: [CCInteger],
|
|
20
|
+
visible: false,
|
|
21
|
+
})
|
|
22
|
+
step: Array<number> = [];
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@property({ displayName: "组件名称", tooltip: "引导节点绑定的组件名称" })
|
|
26
|
+
comName: string = "";
|
|
27
|
+
@property({ displayName: "选中行路径", tooltip: "引导节点绑定的组件名称" })
|
|
28
|
+
path: string = '';
|
|
29
|
+
|
|
30
|
+
is_open = true;
|
|
31
|
+
is_enable = false;
|
|
32
|
+
start() {
|
|
33
|
+
var gm = GuideModule.GuideCenter.guide?.GuideModel;
|
|
34
|
+
if (gm) {
|
|
35
|
+
this.step = gm.ui_com_map.get(this.comName)
|
|
36
|
+
if (!this.step) {
|
|
37
|
+
Log.warn("引导数据未找到--请检查表格:", this.comName)
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.step.forEach((step: number) => {
|
|
41
|
+
var gv = GuideModule.GuideCenter.guide.GuideView;
|
|
42
|
+
// 注册引导数据
|
|
43
|
+
gv.register(step, this.node);
|
|
44
|
+
|
|
45
|
+
// 验证当前是否触发这个引导
|
|
46
|
+
// if (is_choose) {
|
|
47
|
+
// gv.check(this.comName);
|
|
48
|
+
// } else {
|
|
49
|
+
if (gm.step == step) {
|
|
50
|
+
gv.check();
|
|
51
|
+
}
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
update(dt: number) {
|
|
60
|
+
|
|
61
|
+
var gm = GuideModule.GuideCenter.guide?.GuideModel;
|
|
62
|
+
if (gm && !GuideModule.GuideCenter.is_guide_week) {
|
|
63
|
+
if (this.step) {
|
|
64
|
+
this.step.forEach((step: number) => {
|
|
65
|
+
|
|
66
|
+
var gv = GuideModule.GuideCenter.guide.GuideView;
|
|
67
|
+
// 验证当前是否触发这个引导
|
|
68
|
+
if (gm.step == step) {
|
|
69
|
+
gv?.refresh();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// guideSelect(index: number) {
|
|
78
|
+
// if (index === this.row) {
|
|
79
|
+
// this.row = index
|
|
80
|
+
// } else {
|
|
81
|
+
// this.row = -1
|
|
82
|
+
// }
|
|
83
|
+
// }
|
|
84
|
+
|
|
85
|
+
findButton() {
|
|
86
|
+
return this.node.parent.getChildByPath(this.path)?.getComponent(Button)
|
|
87
|
+
}
|
|
88
|
+
findToggle() {
|
|
89
|
+
return this.node.parent.getChildByPath(this.path)?.getComponent(Toggle)
|
|
90
|
+
}
|
|
91
|
+
findToggleContainer() {
|
|
92
|
+
return this.node.parent.getChildByPath(this.path)?.parent?.getComponent(ToggleContainer)
|
|
93
|
+
}
|
|
94
|
+
findNode() {
|
|
95
|
+
if (this.path == "") {
|
|
96
|
+
return null
|
|
97
|
+
}
|
|
98
|
+
return this.node.parent.getChildByPath(this.path)
|
|
99
|
+
}
|
|
100
|
+
findNodeButton() {
|
|
101
|
+
const node = this.findNode()
|
|
102
|
+
return node?.getComponent(Button)
|
|
103
|
+
}
|
|
104
|
+
}
|