Files
pixelheros/assets/script/game/map/GuideComp.ts
panFD 31f5340866 refactor: 移除多余的新手引导2、3、4相关代码和资源
1. 删除Guide2、Guide3、Guide4的UIID配置和对应弹窗资源
2. 移除MissionCardComp中关闭guide3、guide4的逻辑代码
3. 移除GuideComp中对应guide2、3、4的UIID判断逻辑
4. 简化云函数代码中冗余的get请求分支
5. 调整按钮抖动动画的时长参数优化视觉效果
6. 新增微信云开发客户端API封装代码
2026-08-06 23:09:47 +08:00

72 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { mLogger } from "../common/Logger";
import { _decorator, Animation, AnimationClip, EventTouch, Label, Node, NodeEventType, Sprite, SpriteAtlas, Tween, tween, UIOpacity, Vec3, resources, Light, UITransform, Widget, CCInteger, CCString, Component } from "cc";
import { smc } from "../common/SingletonModuleComp";
import { UIID } from "../common/config/GameUIConfig";
import { oops } from "db://oops-framework/core/Oops";
const { ccclass, property } = _decorator;
@ccclass('GuideComp')
export class GuideComp extends Component {
/** 是否开启调试日志 */
private debugMode: boolean = true;
// ======================== 编辑器绑定节点 ========================
/** 引导编号 ID */
@property({ type: CCInteger })
guide_id: number = 0
onLoad() {
// 监听自身节点(即弹窗任意位置)的点击事件
this.node.on(NodeEventType.TOUCH_START, this.onTouchStart, this);
this.node.on(NodeEventType.TOUCH_END, this.onGuideClick, this);
}
private onTouchStart(event: EventTouch) {
// 允许事件穿透,确保底层的实际功能按钮能正常接收到 TOUCH_START 事件
event.preventSwallow = true;
}
private onGuideClick(event: EventTouch) {
// 记录该引导 ID 已完成
if (!smc.finish_guides.includes(this.guide_id)) {
smc.finish_guides.push(this.guide_id);
mLogger.log(this.debugMode, 'Guide', `完成引导 ID: ${this.guide_id}`);
// TODO: 若需要持久化保存,可在此处调用本地存储或同步到服务器的方法
// oops.storage.set("finish_guides", smc.finish_guides);
}
// 允许事件穿透,确保底层的实际功能按钮能正常接收到点击事件
event.preventSwallow = true;
// 因为通过 oops.gui.open(UIID) 弹出的界面根节点可能会带有一个阻挡点击的遮罩组件BlockInputEvents
// 所以应当通过 oops.gui.remove 彻底从框架的层级管理中移除当前界面。
let targetUIID = -1;
if (this.guide_id === 1) targetUIID = UIID.Guide1;
if (targetUIID !== -1) {
oops.gui.remove(targetUIID);
} else {
// 兜底方案
this.node.active = false;
this.node.destroy();
}
}
/** 组件销毁时解绑所有事件,防止残留回调 */
onDestroy() {
if (this.node && this.node.isValid) {
this.node.off(NodeEventType.TOUCH_START, this.onTouchStart, this);
this.node.off(NodeEventType.TOUCH_END, this.onGuideClick, this);
}
}
/** 外部初始化入口(由 MissionGuideComp 调用) */
init() {
}
}