1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -10,4 +8,21 @@ public class SeccionItem : MonoBehaviour
|
||||
public Button btn_SelectGameRoom;
|
||||
public TextMeshProUGUI txt_VenueInfo; // 场地信息:初级场/中级场/高级场
|
||||
public TextMeshProUGUI txt_EntryCondition; // 入场条件文字
|
||||
|
||||
[Header("快速进入按钮按下缩放")]
|
||||
public float pressScale = 0.95f; // 按下时卡片缩放比例
|
||||
public float pressDuration = 0.1f; // 缩放动画时长
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (btn_JoinGame == null) return;
|
||||
|
||||
// 「快速进入」按钮:按下缩小卡片,抬起还原
|
||||
// 用只处理按下/抬起、不含拖动接口的 UIPressScale,避免抢走所在 ScrollRect 的滑动
|
||||
var effect = btn_JoinGame.gameObject.GetComponent<UIPressScale>();
|
||||
if (effect == null) effect = btn_JoinGame.gameObject.AddComponent<UIPressScale>();
|
||||
effect.target = transform; // 缩放整个 SeccionItem 卡片
|
||||
effect.pressScale = pressScale;
|
||||
effect.duration = pressDuration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
/// <summary>
|
||||
/// 按下缩小、抬起还原。
|
||||
/// 只实现 IPointerDownHandler / IPointerUpHandler,不实现 IDragHandler 等拖动接口,
|
||||
/// 所以挂在 ScrollRect 内的按钮上不会抢走 ScrollRect 的滑动。
|
||||
/// </summary>
|
||||
public class UIPressScale : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
[Tooltip("缩放目标,留空则缩放自身")]
|
||||
public Transform target;
|
||||
public float pressScale = 0.95f; // 按下时缩放比例
|
||||
public float duration = 0.1f; // 缩放动画时长
|
||||
|
||||
private Vector3 _standardScale;
|
||||
private bool _captured;
|
||||
private bool _isPressing;
|
||||
|
||||
private Transform Target => target != null ? target : transform;
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData) => SetPressing(true);
|
||||
public void OnPointerUp(PointerEventData eventData) => SetPressing(false);
|
||||
|
||||
private void SetPressing(bool pressing)
|
||||
{
|
||||
if (_isPressing == pressing) return;
|
||||
_isPressing = pressing;
|
||||
|
||||
var t = Target;
|
||||
if (!_captured)
|
||||
{
|
||||
_standardScale = t.localScale; // 首次使用时记录原缩放
|
||||
_captured = true;
|
||||
}
|
||||
t.DOKill();
|
||||
t.DOScale(pressing ? _standardScale * pressScale : _standardScale, duration)
|
||||
.SetEase(Ease.OutQuad);
|
||||
}
|
||||
|
||||
// 被隐藏时立即还原,避免按下瞬间目标被关掉而停在缩小状态
|
||||
private void OnDisable()
|
||||
{
|
||||
_isPressing = false;
|
||||
if (!_captured) return;
|
||||
Target.DOKill();
|
||||
Target.localScale = _standardScale;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1435cae0f5e87f24c9f0c3581b81f36a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -55,6 +55,8 @@ public class UIHomeMain : UIBase
|
||||
public SeccionItem HHWKButton1;
|
||||
public SeccionItem HHWKButton2;
|
||||
public SeccionItem HHWKButton3;
|
||||
|
||||
public Button btn_KuaiSuKaiShi;
|
||||
[Header("中国象棋")]
|
||||
public Button ZGXQBtn;
|
||||
|
||||
@@ -153,6 +155,8 @@ public class UIHomeMain : UIBase
|
||||
BindRoomLevelItem(HHWKButton1, GameType.HHWK, 1);
|
||||
BindRoomLevelItem(HHWKButton2, GameType.HHWK, 2);
|
||||
BindRoomLevelItem(HHWKButton3, GameType.HHWK, 3);
|
||||
// 快速开始:在所有场次中随机进入
|
||||
if (btn_KuaiSuKaiShi != null) btn_KuaiSuKaiShi.onClick.AddListener(QuickStartRandom);
|
||||
#endregion
|
||||
|
||||
#region left
|
||||
@@ -341,6 +345,19 @@ public class UIHomeMain : UIBase
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>快速开始:在所有玩法场次(风雷之渊/星际迷航/黑化悟空 × 初/中/高级场)中随机进入一个</summary>
|
||||
private void QuickStartRandom()
|
||||
{
|
||||
var rooms = new (GameType gameType, int leave)[]
|
||||
{
|
||||
(GameType.FLZY, 1), (GameType.FLZY, 2), (GameType.FLZY, 3),
|
||||
(GameType.XJMH, 1), (GameType.XJMH, 2), (GameType.XJMH, 3),
|
||||
(GameType.HHWK, 1), (GameType.HHWK, 2), (GameType.HHWK, 3),
|
||||
};
|
||||
var pick = rooms[UnityEngine.Random.Range(0, rooms.Length)];
|
||||
QuickJoinRoom(pick.gameType, pick.leave);
|
||||
}
|
||||
|
||||
/// <summary>手动选座:VIP 校验通过后按正常子UI流程打开房间列表面板,并拉取该场次房间列表</summary>
|
||||
private void ManualSelectRoom(GameType gameType, int leave)
|
||||
{
|
||||
|
||||
@@ -587,8 +587,6 @@ GameObject:
|
||||
- component: {fileID: 8853572317385043517}
|
||||
- component: {fileID: 9049912857469479422}
|
||||
- component: {fileID: 6955909806736836364}
|
||||
- component: {fileID: 6754374072825034577}
|
||||
- component: {fileID: 4946178425992029769}
|
||||
m_Layer: 5
|
||||
m_Name: SelectRoomLV2_FXZY_1
|
||||
m_TagString: Untagged
|
||||
@@ -642,46 +640,8 @@ MonoBehaviour:
|
||||
btn_SelectGameRoom: {fileID: 7142047261565016865}
|
||||
txt_VenueInfo: {fileID: 0}
|
||||
txt_EntryCondition: {fileID: 2928962507984365505}
|
||||
--- !u!223 &6754374072825034577
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1872093705705470253}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 2
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &4946178425992029769
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1872093705705470253}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
pressScale: 0.95
|
||||
pressDuration: 0.1
|
||||
--- !u!1 &1894325380142951813
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3011,6 +2971,11 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6436429307221650635, guid: bddd0261a39953e448c469636a3ec884,
|
||||
type: 3}
|
||||
propertyPath: m_MeshSharing
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7323817790329658132, guid: bddd0261a39953e448c469636a3ec884,
|
||||
type: 3}
|
||||
propertyPath: m_SortingLayer
|
||||
|
||||
Reference in New Issue
Block a user