You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
4.1 KiB
130 lines
4.1 KiB
|
|
|
|
//*********************
|
|
|
|
// create by 流云
|
|
|
|
// time: Sat Apr 25 2026
|
|
|
|
// desc:
|
|
|
|
//*********************
|
|
|
|
import { _decorator, Component, Node, find, RichText, sp, Tween } from 'cc';
|
|
|
|
import { Auto_PopTetriDoc } from './Auto_PopTetriDoc';
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
@ccclass('UIPopTetriDoc')
|
|
|
|
export class UIPopTetriDoc extends Auto_PopTetriDoc {
|
|
|
|
|
|
|
|
private _curentPage: number = 0;
|
|
|
|
private _isClosing = false;
|
|
|
|
/** 本实例是否已计入 pauseForTetriDoc */
|
|
|
|
private _pausedByDoc = false;
|
|
|
|
|
|
|
|
onLoad(): void {
|
|
|
|
super.onLoad();
|
|
|
|
}
|
|
|
|
|
|
|
|
onEnable(): void {
|
|
|
|
super.onEnable();
|
|
|
|
this._isClosing = false;
|
|
|
|
this._pausedByDoc = false;
|
|
|
|
const battle = gg.game?.CurentBattle;
|
|
|
|
if (battle) {
|
|
|
|
battle.pauseForTetriDoc();
|
|
|
|
this._pausedByDoc = true;
|
|
|
|
}
|
|
|
|
this.ui_bgMask.on(Node.EventType.TOUCH_END, this.onClickClose, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
onDisable(): void {
|
|
|
|
super.onDisable();
|
|
|
|
this.ui_bgMask?.off(Node.EventType.TOUCH_END, this.onClickClose, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected onDestroy(): void {
|
|
|
|
this._releaseDocPause();
|
|
|
|
super.onDestroy?.();
|
|
|
|
}
|
|
|
|
|
|
|
|
onInit(): void {
|
|
|
|
this._isClosing = false;
|
|
|
|
this._curentPage = 0;
|
|
|
|
if (this.prema && !Number.isNaN(this.prema)) this._curentPage = this.prema;
|
|
|
|
if (this.ui_center?.isValid) {
|
|
|
|
Tween.stopAllByTarget(this.ui_center);
|
|
|
|
}
|
|
|
|
if (this.ui_bgMask?.isValid) {
|
|
|
|
Tween.stopAllByTarget(this.ui_bgMask);
|
|
|
|
}
|
|
|
|
this.showOpenCenterEff();
|
|
|
|
this.showOpenMaskEff(2);
|
|
|
|
this.updateUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateUI(): void {
|
|
|
|
this.btnLeft.active = this._curentPage > 0;
|
|
|
|
this.btnRight.active = this._curentPage < 4;
|
|
|
|
|
|
|
|
this.ui_anim.active = this._curentPage <= 3;
|
|
|
|
this.ui_page4.active = this._curentPage == 4;
|
|
this.rt_title.string = gg.lang.get(`玩法说明第${this._curentPage + 1}页标题`);
this.rt_desc.string = gg.lang.get(`玩法说明第${this._curentPage + 1}页描述`);
if (this.ui_page4.active) {
for (let i = 0; i < this.ui_page4.children.length; i++) {
let n = this.ui_page4.children[i].getComponent(RichText);
n.string = gg.lang.get(`玩法说明页面5描述${i + 1}`);
}
}
if (this.ui_anim.active) {
let name = `1放置`;
if (this._curentPage == 1) name = `2移动`;
if (this._curentPage == 2) name = `3合成`;
if (this._curentPage == 3) name = `1放置无重力墙`;
this.ui_anim.getComponent(sp.Skeleton).setAnimation(0, name, true);
}
}
click_btnLeft(): void {
this._curentPage--;
if (this._curentPage < 0) this._curentPage = 0;
this.updateUI();
}
click_btnRight(): void {
this._curentPage++;
if (this._curentPage > 4) this._curentPage = 4;
this.updateUI();
}
onClickClose(): void {
this.requestClose();
}
click_btnClose(): void {
this.requestClose();
}
private _releaseDocPause(): void {
if (!this._pausedByDoc) return;
gg.game?.CurentBattle?.resumeForTetriDoc();
this._pausedByDoc = false;
}
/** 连点关闭/重开时避免 Sliced Sprite 在缩放到 0 时 updateUVs 空引用 */
private requestClose(): void {
if (this._isClosing) {
return;
}
this._isClosing = true;
if (this.ui_anim?.isValid) {
this.ui_anim.active = false;
}
if (this.ui_center?.isValid) {
Tween.stopAllByTarget(this.ui_center);
}
if (this.ui_bgMask?.isValid) {
Tween.stopAllByTarget(this.ui_bgMask);
}
// destroy 前释放 pause(不可依赖 panelIsShow,关闭当帧仍为 true)
this._releaseDocPause();
this.close(1);
}
}
|