引导 基本完成
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _decorator, BlockInputEvents, Button, Label, Node, UITransform, Vec3 } from "cc";
|
||||
import { _decorator, BlockInputEvents, Button, director, Label, Node, UITransform, Vec3 } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { IGuideStep, GuideStepType } from "../common/config/Guide";
|
||||
@@ -33,6 +33,8 @@ export class GuideSetpComp extends CCComp {
|
||||
private totalSteps: number = 0;
|
||||
/** 目标节点 */
|
||||
private _targetNode: Node | null = null;
|
||||
/** 提示父节点 */
|
||||
private _tipParent: Node | null = null;
|
||||
private _showTip: boolean = false;
|
||||
private _showHand: boolean = false;
|
||||
private _callback: any = null;
|
||||
@@ -104,7 +106,8 @@ export class GuideSetpComp extends CCComp {
|
||||
}
|
||||
/** 处理步骤信息 */
|
||||
private handleStepInfo(data: any) {
|
||||
const { step, stepIndex, totalSteps, targetNode,callbacks } = data;
|
||||
const { step, stepIndex, totalSteps,callbacks } = data;
|
||||
const targetNode=this.findTargetNode(step.targetPath);
|
||||
this._noInput.enabled=step.noInput??false;
|
||||
this._callback=callbacks;
|
||||
if(targetNode){
|
||||
@@ -116,10 +119,15 @@ export class GuideSetpComp extends CCComp {
|
||||
this._showTip=true;
|
||||
this._showHand=false;
|
||||
}
|
||||
if(step.tipParent){
|
||||
this._tipParent=this.findTargetNode(step.tipParent);
|
||||
}else{
|
||||
this._tipParent=this._targetNode;
|
||||
}
|
||||
console.log("[GuideSetpComp] 处理步骤信息:", step);
|
||||
|
||||
// 显示步骤
|
||||
this.showStep(step, stepIndex, totalSteps,targetNode);
|
||||
this.showStep(step, stepIndex, totalSteps,targetNode,this._tipParent);
|
||||
// 如果有手指位置,直接设置
|
||||
// this.setHandPosition(this._targetNode);
|
||||
|
||||
@@ -137,18 +145,22 @@ export class GuideSetpComp extends CCComp {
|
||||
}
|
||||
|
||||
/** 显示引导步骤 */
|
||||
showStep(step: IGuideStep, stepIndex: number, totalSteps: number,targetNode: Node) {
|
||||
showStep(step: IGuideStep, stepIndex: number, totalSteps: number,targetNode: Node,tipParent: Node) {
|
||||
this.currentStep = step;
|
||||
this.currentStepIndex = stepIndex;
|
||||
this.totalSteps = totalSteps;
|
||||
// 将handNode和tipNode从当前父节点移除
|
||||
this.handNode.parent=this._targetNode;
|
||||
this.tipNode.parent=this._targetNode;
|
||||
// if(this._tipParent){
|
||||
// this.tipNode.parent=this._tipParent;
|
||||
// }else{
|
||||
// this.tipNode.parent=this._targetNode;
|
||||
// }
|
||||
this.handNode.setPosition(this.currentStep?.handOffset?.x || 0, this.currentStep?.handOffset?.y || 0);
|
||||
this.tipNode.setPosition(this.currentStep?.tipOffset?.x || 0, this.currentStep?.tipOffset?.y || 0);
|
||||
// this.tipNode.setPosition(this.currentStep?.tipOffset?.x || 0, this.currentStep?.tipOffset?.y || 0);
|
||||
// 设置setSiblingIndex最大
|
||||
this.handNode.setSiblingIndex(this._targetNode.children.length - 1);
|
||||
this.tipNode.setSiblingIndex(this._targetNode.children.length - 1);
|
||||
// this.tipNode.setSiblingIndex(this._targetNode.children.length - 1);
|
||||
// 更新UI内容
|
||||
this.updateStepContent()
|
||||
// 显示组件
|
||||
@@ -185,7 +197,38 @@ export class GuideSetpComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** 查找目标节点 */
|
||||
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;
|
||||
console.log("[GuideCon] 当前节点:", currentNode)
|
||||
}
|
||||
|
||||
if (currentNode) {
|
||||
console.log(`[GuideCon] 目标节点查找成功:`, currentNode.position, currentNode.getWorldPosition());
|
||||
return currentNode as Node;
|
||||
} else {
|
||||
console.error(`[GuideCon] 目标节点查找失败: ${path}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** 跳过按钮点击事件 */
|
||||
@@ -220,5 +263,6 @@ export class GuideSetpComp extends CCComp {
|
||||
this.removeTouchListener();
|
||||
this.tipNode.destroy();
|
||||
this.handNode.destroy();
|
||||
console.log("[GuideSetpComp] 监听onDestroy", this.node);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { HttpReturn } from 'db://oops-framework/libs/network/HttpRequest';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
|
||||
import { CCComp } from 'db://oops-framework/module/common/CCComp';
|
||||
import { finishCurrGuide, startGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HCardUICom')
|
||||
@@ -75,6 +76,8 @@ export class HCardUICom extends CCComp {
|
||||
oops.gui.open(UIID.HeroInfo,this.h_uuid)
|
||||
break
|
||||
case HeroConSet.SELECT:
|
||||
finishCurrGuide(9)
|
||||
startGuide(10)
|
||||
if(oops.gui.has(UIID.HeroSelect)) {
|
||||
this.check_in_slot()
|
||||
smc.setFightHero(this.slot,this.h_uuid,true)
|
||||
|
||||
@@ -6,35 +6,19 @@ import { smc } from '../common/SingletonModuleComp';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
import { NumberFormatter } from '../common/config/BoxSet';
|
||||
import { Items } from '../common/config/Items';
|
||||
import { finishCurrGuide, GuideConfig } from '../common/config/Guide';
|
||||
import { finishCurrGuide, GuideConfig, startGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HInfoComp')
|
||||
export class HInfoComp extends Component {
|
||||
h_uuid:number=0
|
||||
private guides:any=[0,1]
|
||||
private guideends:any=[3,5]
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
onAdded(args: any) {
|
||||
// console.log("[HInfoComp]:onAdded",args)
|
||||
this.endGuide()
|
||||
this.startNextGuide()
|
||||
console.log("[HInfoComp]:onAdded",this.node)
|
||||
this.update_data(args)
|
||||
}
|
||||
startNextGuide(){
|
||||
this.guides.forEach(guide_key=>{
|
||||
if(smc.guides[guide_key]==0){
|
||||
console.log("[HInfoComp]:推送启动引导:key",guide_key)
|
||||
oops.message.dispatchEvent(GameEvent.GuideStart, guide_key)
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
endGuide(){
|
||||
finishCurrGuide(3)
|
||||
startGuide(5)
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
|
||||
@@ -74,6 +58,12 @@ export class HInfoComp extends Component {
|
||||
need_node.getChildByName("gold").getChildByName("has").getComponent(Label).string=NumberFormatter.formatNumber(smc.data.gold)
|
||||
}
|
||||
show_lock(lv:number){
|
||||
|
||||
if(lv==0){
|
||||
console.log("[HInfoComp]:show_lock lv==0",this.node)
|
||||
finishCurrGuide(3)
|
||||
startGuide(4)
|
||||
}
|
||||
this.node.getChildByName("upBtn").active=lv > 0
|
||||
this.node.getChildByName("upNeed").active=lv > 0
|
||||
this.node.getChildByName("lock").active=lv == 0
|
||||
@@ -105,8 +95,9 @@ export class HInfoComp extends Component {
|
||||
return
|
||||
}
|
||||
oops.gui.toast("英雄< "+HeroInfo[this.h_uuid].name+" >解锁成功")
|
||||
finishCurrGuide(4)
|
||||
startGuide(5)
|
||||
this.update_data(this.h_uuid)
|
||||
oops.message.dispatchEvent(GameEvent.GuideEnd,GuideConfig[3].key)
|
||||
oops.message.dispatchEvent(GameEvent.HeroUnlock, {uuid:this.h_uuid})
|
||||
}
|
||||
uplevel(){
|
||||
@@ -127,6 +118,8 @@ export class HInfoComp extends Component {
|
||||
return
|
||||
}
|
||||
this.update_data(this.h_uuid)
|
||||
finishCurrGuide(5)
|
||||
startGuide(6)
|
||||
oops.gui.toast(`英雄< ${HeroInfo[this.h_uuid].name} >升级成功`)
|
||||
oops.message.dispatchEvent(GameEvent.HeroLvUp, {uuid:this.h_uuid})
|
||||
}
|
||||
@@ -147,6 +140,8 @@ export class HInfoComp extends Component {
|
||||
this.update_data(prevHero)
|
||||
}
|
||||
close(){
|
||||
finishCurrGuide(6)
|
||||
startGuide(7)
|
||||
oops.gui.removeByNode(this.node)
|
||||
}
|
||||
reset() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { HCardUICom } from './HCardUICom';
|
||||
import { HeroConSet } from '../common/config/BoxSet';
|
||||
import { getHeroList } from '../common/config/heroSet';
|
||||
import { finishCurrGuide, startGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroPageComp')
|
||||
@@ -14,6 +15,11 @@ export class HeroPageComp extends Component {
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
onEnable(){
|
||||
this.update_heros()
|
||||
startGuide(3)
|
||||
|
||||
}
|
||||
update_heros(){
|
||||
let heros=getHeroList()
|
||||
|
||||
@@ -5,6 +5,7 @@ import { GameEvent } from '../common/config/GameEvent';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { UIID } from '../common/config/GameUIConfig';
|
||||
import { GameSet } from '../common/config/BoxSet';
|
||||
import { finishCurrGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroReadyCom')
|
||||
@@ -50,7 +51,10 @@ export class HeroReadyCom extends Component {
|
||||
this.node.getChildByName("icon").active=false
|
||||
}
|
||||
select_hero(){
|
||||
if(oops.gui.has(UIID.HeroSelect)) return
|
||||
if(oops.gui.has(UIID.HeroSelect)) return
|
||||
if(smc.fight_heros[this.slot]==0) {
|
||||
finishCurrGuide(8)
|
||||
}
|
||||
oops.gui.open(UIID.HeroSelect,{slot:this.slot})
|
||||
}
|
||||
reset() {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { HCardUICom } from './HCardUICom';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { HeroConSet } from '../common/config/BoxSet';
|
||||
import { startGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroSelectCom')
|
||||
@@ -14,6 +15,7 @@ export class HeroSelectCom extends Component {
|
||||
onAdded(args: any) {
|
||||
// console.log("[HeroSelectCom]:onAdded",args)
|
||||
this.slot=args.slot
|
||||
startGuide(9)
|
||||
this.update_heros()
|
||||
}
|
||||
protected onDisable(): void {
|
||||
|
||||
@@ -22,7 +22,6 @@ export class MissionHomeComp extends CCComp {
|
||||
this.home_active()
|
||||
}
|
||||
onEnable(){
|
||||
this.endGuide()
|
||||
this.startNextGuide(); // 启动第一个引导
|
||||
startGuide(1)
|
||||
startGuide(2)
|
||||
@@ -36,11 +35,10 @@ export class MissionHomeComp extends CCComp {
|
||||
}
|
||||
|
||||
}
|
||||
private endGuide(){
|
||||
// finishCurrGuide(0)
|
||||
}
|
||||
|
||||
start_mission() {
|
||||
finishCurrGuide(1)
|
||||
finishCurrGuide(10)
|
||||
oops.message.dispatchEvent(GameEvent.MissionStart, {})
|
||||
this.node.active=false;
|
||||
}
|
||||
@@ -86,13 +84,13 @@ export class MissionHomeComp extends CCComp {
|
||||
btn_shop.getChildByName("act").active=true
|
||||
break
|
||||
case "heros":
|
||||
page_heros.active=true
|
||||
finishCurrGuide(2)
|
||||
let page_heros_com=page_heros.getComponent(HeroPageComp)!
|
||||
page_heros_com.update_heros()
|
||||
page_heros.active=true
|
||||
btn_heros.getChildByName("act").active=true
|
||||
break
|
||||
case "fight":
|
||||
finishCurrGuide(7)
|
||||
startGuide(8)
|
||||
btn_fight.getChildByName("act").active=true
|
||||
break
|
||||
case "skill":
|
||||
|
||||
@@ -5,6 +5,7 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { ItemComp } from "./ItemComp";
|
||||
import { startGuide } from "../common/config/Guide";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -64,6 +65,7 @@ export class VictoryComp extends CCComp {
|
||||
}
|
||||
victory_end(){
|
||||
this.clear_data()
|
||||
// startGuide(2)
|
||||
oops.message.dispatchEvent(GameEvent.MissionEnd)
|
||||
oops.gui.removeByNode(this.node)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user