This commit is contained in:
2026-09-02 23:40:52 +08:00
parent 8c90f6e853
commit 9862bf123c
4 changed files with 190 additions and 4 deletions
+45 -1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
/// <summary>炮台控制模式</summary>
@@ -14,8 +15,18 @@ public enum TurretControlMode
XJMH = 1
}
public class SitPosData : MonoBehaviour
public class SitPosData : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
[Tooltip("长按判定时间(秒):按住 img_OpenPT 超过此时间触发 OnOpenPTLongPress")]
public float openPTLongPressTime = 0.5f;
public Image img_OpenPT;
/// <summary>长按 img_OpenPT 触发一次(GameMainPanel 订阅后用它开关炮台面板,仅本地玩家座位有意义)</summary>
public event Action OnOpenPTLongPress;
private bool _openPTPressing;
private float _openPTPressTimer;
public bool IsBaoJiangingActive;
public Transform obj_BaoJiangZhongPanelPosition;
@@ -294,6 +305,39 @@ public class SitPosData : MonoBehaviour
private void Update()
{
UpdateZhanShenLaser();
// ⭐ 长按 img_OpenPT 计时:到达阈值触发一次(提前松手不触发)
if (_openPTPressing)
{
_openPTPressTimer += Time.deltaTime;
if (_openPTPressTimer >= openPTLongPressTime)
{
_openPTPressing = false;
_openPTPressTimer = 0f;
OnOpenPTLongPress?.Invoke();
}
}
}
// ==================== 长按 img_OpenPT(打开炮台面板) ====================
/// <summary>按下:命中 img_OpenPT(或其子对象)才开始长按计时(其他区域不响应)</summary>
public void OnPointerDown(PointerEventData eventData)
{
if (img_OpenPT == null) return;
var hit = eventData.pointerCurrentRaycast.gameObject;
if (hit == null) return;
if (hit != img_OpenPT.gameObject && !hit.transform.IsChildOf(img_OpenPT.transform)) return;
_openPTPressing = true;
_openPTPressTimer = 0f;
}
/// <summary>松开:取消长按计时(未达阈值不触发)</summary>
public void OnPointerUp(PointerEventData eventData)
{
_openPTPressing = false;
_openPTPressTimer = 0f;
}
// ==================== 战神激光(锁定时显示) ====================
@@ -278,7 +278,8 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
if (item.posID == roomJoinNotice.position)
{
currSitData = item;
// ⭐ 长按本地座位的 img_OpenPT 开关炮台面板(与 btn_ChangeTurret 同逻辑)
HookOpenPTLongPress(currSitData);
}
else
{
@@ -415,6 +416,9 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
// ⭐ 清理 XJMH 扇形切换UI(如果还在显示)
CleanupTurretSwitcher();
// ⭐ 解绑长按 img_OpenPT 打开炮台面板的订阅
UnhookOpenPTLongPress();
UnLoadResources();
// 场景可能未加载或已卸载,做保护避免重复卸载报错
var scene = SceneManager.GetSceneByName(sceneName);
@@ -432,6 +436,51 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
}
#endregion
#region 长按 img_OpenPT 开关炮台面板
/// <summary>已订阅长按事件的座位(换座位/重进房间时先解绑避免重复订阅)</summary>
private SitPosData _openPTHookedSit;
/// <summary>缓存的长按处理器(解绑用)</summary>
private Action _openPTLongPressHandler;
/// <summary>
/// 订阅本地座位的 img_OpenPT 长按事件:长按开关炮台面板(subUIManager,与 btn_ChangeTurret 同逻辑)。
/// XJMH 模式没有炮台面板(用扇形切换),不订阅。
/// </summary>
private void HookOpenPTLongPress(SitPosData sit)
{
// 先解绑旧订阅
UnhookOpenPTLongPress();
if (sit == null || sit.turretControlMode == TurretControlMode.XJMH) return;
_openPTLongPressHandler = () =>
{
// 与 btn_ChangeTurret 完全相同的开关逻辑:开着就关,没开就打开
var panel = subUIManager.Get<SubUIBase>(UIPanel.TurretPanel);
if (panel != null && panel.gameObject.activeSelf)
subUIManager.Hide(UIPanel.TurretPanel);
else
{
subUIManager.ShowAsync(UIPanel.TurretPanel, (ItemPanelSelect.Turrect, true));
StartCoroutine(CloseSettingList());
}
};
sit.OnOpenPTLongPress += _openPTLongPressHandler;
_openPTHookedSit = sit;
}
/// <summary>解绑长按 img_OpenPT 的订阅(面板隐藏/重新订阅前调用)</summary>
private void UnhookOpenPTLongPress()
{
if (_openPTHookedSit != null && _openPTLongPressHandler != null)
_openPTHookedSit.OnOpenPTLongPress -= _openPTLongPressHandler;
_openPTHookedSit = null;
_openPTLongPressHandler = null;
}
#endregion
#region 生命周期
private float baseAttackTime;
+94 -1
View File
@@ -739,6 +739,81 @@ MonoBehaviour:
y: 0
width: 1
height: 1
--- !u!1 &2018068718678918123
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 743621258860174113}
- component: {fileID: 5020678746128137213}
- component: {fileID: 1043577480745425357}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &743621258860174113
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2018068718678918123}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2732244402854446462}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 80.221466}
m_SizeDelta: {x: 210.2, y: 123.8501}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5020678746128137213
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2018068718678918123}
m_CullTransparentMesh: 1
--- !u!114 &1043577480745425357
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2018068718678918123}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &2025156255710582528
GameObject:
m_ObjectHideFlags: 0
@@ -1244,7 +1319,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 0.6745098}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
@@ -2132,6 +2207,7 @@ RectTransform:
- {fileID: 5516422369603436267}
- {fileID: 1688708463719695129}
- {fileID: 332937045809476598}
- {fileID: 743621258860174113}
m_Father: {fileID: 8303575886087428388}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
@@ -2780,6 +2856,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 16cfaab69e1fa404dbb8432276bd7537, type: 3}
m_Name:
m_EditorClassIdentifier:
openPTLongPressTime: 0.5
img_OpenPT: {fileID: 1043577480745425357}
IsBaoJiangingActive: 0
obj_BaoJiangZhongPanelPosition: {fileID: 6515038176716052403}
user:
@@ -4249,6 +4327,21 @@ PrefabInstance:
propertyPath: m_Name
value: gun_barrel_14901_multy
objectReference: {fileID: 0}
- target: {fileID: 2826291771310781170, guid: 3a10d8f351e3d52489bceee1b4740337,
type: 3}
propertyPath: m_LocalScale.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2826291771310781170, guid: 3a10d8f351e3d52489bceee1b4740337,
type: 3}
propertyPath: m_LocalScale.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2826291771310781170, guid: 3a10d8f351e3d52489bceee1b4740337,
type: 3}
propertyPath: m_LocalScale.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3658765242434420830, guid: 3a10d8f351e3d52489bceee1b4740337,
type: 3}
propertyPath: m_SortingLayer
+1 -1
View File
@@ -176,7 +176,7 @@ public class UIHomeMain : UIBase
APIRequestList.GetRankingRewardConfig(cfg =>
{
Debug.Log($"[排行榜入口] isEnabled={cfg.isEnabled} isMaintaining={cfg.isMaintaining}");
if (!cfg.isMaintaining)
if (cfg.isMaintaining|| !cfg.isEnabled)
{
// 排行榜维护中:弹提示弹窗(点确认关闭),不打开界面
UIManager.Instance.ShowTiShi(string.IsNullOrEmpty(cfg.maintainingMessage) ? "维护中..." : cfg.maintainingMessage);