引导 基本完成

This commit is contained in:
panw
2025-08-25 17:28:02 +08:00
parent 6a29821a7b
commit 6c95b3acc3
17 changed files with 1085 additions and 508 deletions

View File

@@ -83,19 +83,24 @@ export class GuideConComp extends CCComp {
/** 点击引导 */
private showClickGuide(step: IGuideStep) {
console.log("[Tutorial] 显示点击引导", step);
if (!step.targetPath) {
console.error("[Tutorial] 点击引导缺少目标路径");
return;
}
// if (!step.targetPath) {
// console.error("[Tutorial] 点击引导缺少目标路径");
// return;
// }
const targetNode = this.findTargetNode(step.targetPath);
if (!targetNode) {
console.error(`[Tutorial] 找不到目标节点: ${step.targetPath}`);
return;
}
console.log("[Tutorial] 开始点击引导UI", step.targetPath);
this.showGuideStepUI(step, targetNode);
// const targetNode = this.findTargetNode(step.targetPath);
// if (!targetNode) {
// console.error(`[Tutorial] 找不到目标节点: ${step.targetPath}`);
// return;
// }
// let tipParent:Node|null=null;
// if(step.tipParent){
// tipParent = this.findTargetNode(step.tipParent);
// }else{
// tipParent=targetNode;
// }
// console.log("[Tutorial] 开始点击引导UI", step.targetPath);
this.showGuideStepUI(step);
}
/** 显示拖拽引导 */
@@ -107,6 +112,9 @@ export class GuideConComp extends CCComp {
private showWaitGuide(step: IGuideStep) {
console.log("[Tutorial] 显示等待引导:", step.id);
this.showGuideStepUI(step);
this.scheduleOnce(() => {
this.onStepCompleted(step);
}, step.waitTime ?? 2);
// 触摸监听器现在由 GuideSetpComp 管理
}
@@ -135,6 +143,7 @@ export class GuideConComp extends CCComp {
/** 完成指定引导 */
private completeGuide(key:any) {
smc.finishGuide(key);
this.closeGuideStepUI()
console.log(`[GuideCon] 引导 ${key} 已完成,进度数组: ${JSON.stringify(smc.guides)}`);
}
@@ -155,7 +164,7 @@ export class GuideConComp extends CCComp {
/** 打开引导UI */
private showGuideStepUI(step: IGuideStep, targetNode?: Node) {
private showGuideStepUI(step: IGuideStep) {
console.log(`[GuideCon] 开始打开UI: ${step.id}, uiId: ${UIID.Guide}`);
// 关闭之前的引导UI
@@ -164,17 +173,16 @@ export class GuideConComp extends CCComp {
console.log("[Tutorial] 关闭之前的引导UI", UIID.Guide);
}
this.doOpenGuideStepUI(step, targetNode);
this.doOpenGuideStepUI(step);
}
doOpenGuideStepUI(step: IGuideStep, targetNode?: Node) {
doOpenGuideStepUI(step: IGuideStep) {
try {
console.log("[Tutorial] 打开新的引导UI", UIID.Guide);
oops.gui.open(UIID.Guide, {
step: step,
stepIndex: 0,
totalSteps: 1,
targetNode: targetNode,
callbacks: {
onStepComplete: this.onStepCompleted.bind(this),
onComplete: this.completeAllGuide.bind(this)
@@ -194,37 +202,7 @@ export class GuideConComp extends CCComp {
oops.gui.remove(UIID.Guide);
}
/** 查找目标节点 */
private findTargetNode(path: string): Node | null {
console.log(`[GuideCon] 开始查找目标节点: ${path}`);
const pathParts = path.split('/');
let currentNode: any = director.getScene();
for (const part of pathParts) {
if (!currentNode || !currentNode.getChildByName) {
console.error(`[GuideCon] 节点 ${part} 不存在或没有getChildByName方法`);
break;
}
const childNode = currentNode.getChildByName(part);
if (!childNode) {
console.error(`[GuideCon] 找不到子节点: ${part}`);
console.log(`[GuideCon] 当前节点 ${currentNode.name} 的子节点:`, currentNode.children.map(c => c.name));
break;
}
currentNode = childNode;
}
if (currentNode) {
console.log(`[GuideCon] 目标节点查找成功:`, currentNode.position, currentNode.getWorldPosition());
return currentNode as Node;
} else {
console.error(`[GuideCon] 目标节点查找失败: ${path}`);
return null;
}
}
/** 重置引导 */
resetGuide() {