From 0c3a0519a0f526fd67ac3df22fe801c51a81c5e7 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 30 五月 2025 17:06:09 +0800
Subject: [PATCH] 18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建
---
Main/Login/ServerListCenter.cs | 11 +-
Main/UI/OneLevelWin.cs.meta | 11 ++
Main/Component/UI/Common/FunctionButtonGroup.cs | 6
Main/UI/UIBase.cs | 46 +++++++++++
Main/UI/OneLevelWin.cs | 155 ++++++++++++++++++++++++++++++++++++++
5 files changed, 220 insertions(+), 9 deletions(-)
diff --git a/Main/Component/UI/Common/FunctionButtonGroup.cs b/Main/Component/UI/Common/FunctionButtonGroup.cs
index 1bd65c7..daede41 100644
--- a/Main/Component/UI/Common/FunctionButtonGroup.cs
+++ b/Main/Component/UI/Common/FunctionButtonGroup.cs
@@ -7,7 +7,7 @@
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.Events;
-
+using System;
public class FunctionButtonGroup : MonoBehaviour
{
@@ -225,11 +225,11 @@
return functionButton;
}
- public void SetFunctionListener(int order, UnityAction callBack)
+ public void SetFunctionListener(int order, Action callBack)
{
if (functionButtons.ContainsKey(order))
{
- functionButtons[order].SetListener(callBack);
+ functionButtons[order].SetListener(() => callBack?.Invoke());
}
}
diff --git a/Main/Login/ServerListCenter.cs b/Main/Login/ServerListCenter.cs
index 3a9759d..c39bbc1 100644
--- a/Main/Login/ServerListCenter.cs
+++ b/Main/Login/ServerListCenter.cs
@@ -234,7 +234,6 @@
{
if (_ok)
{
- Debug.LogError(" OnGetServerList " + _result);
ServerListParser.Instance.PushCommonServerListRawData(_result);
NetLinkWin.Hide();
}
@@ -263,12 +262,12 @@
}
}
- List<string> prints = FieldPrint.PrintFieldsExpand(serverInfoCommon.common[0], true);
+ // List<string> prints = FieldPrint.PrintFieldsExpand(serverInfoCommon.common[0], true);
- for (int i = 0; i < prints.Count; i++)
- {
- Debug.LogError($"index : {i} " + prints[i]);
- }
+ // for (int i = 0; i < prints.Count; i++)
+ // {
+ // Debug.Log($"index : {i} " + prints[i]);
+ // }
serverInfoCommon.recommend.group_list = recommendServers.ToArray();
FiltrateDefaultServerAndServerGroup();
diff --git a/Main/UI/OneLevelWin.cs b/Main/UI/OneLevelWin.cs
new file mode 100644
index 0000000..04dd726
--- /dev/null
+++ b/Main/UI/OneLevelWin.cs
@@ -0,0 +1,155 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using DG.Tweening;
+using UnityEngine.UI; // DOTween 鎻掍欢寮曠敤
+using Cysharp.Threading.Tasks;
+using System;
+
+
+public class OneLevelWin : UIBase
+{
+ protected Image m_TitleIcon;
+ protected FunctionButtonGroup m_Group;
+ protected Button m_Left;
+ protected Button m_Right;
+ protected Button m_Close;
+
+ protected Text m_Copper;
+ protected Text m_Diamond;
+ protected Text m_BindDiamond;
+
+ protected RectTransform m_SubWindowContainer;
+ public RectTransform subWindowContainer { get { return m_SubWindowContainer; } }
+
+ private UIBase subWindow = null;
+
+ // init once
+ protected override void InitComponent()
+ {
+ base.InitComponent();
+
+ m_TitleIcon = this.GetComponent<Image>("Pivot/Container_BackGround/Img_Title");
+ m_Group = this.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");
+ m_Left = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");
+ m_Right = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");
+ m_Close = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");
+
+ m_Copper = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText");
+ if (m_Copper != null)
+ m_Diamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText");
+ m_BindDiamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText");
+
+ m_SubWindowContainer = this.GetComponent<RectTransform>("Pivot/Container_SubWindow");
+
+ var name = this.gameObject.name;
+ var infos = WindowConfig.GetWindowFunctionInfos(name);
+ foreach (var info in infos)
+ {
+ var title = Language.Get(info.titleKey);
+ if (title.Length == 2)
+ {
+ title = title.Insert(1, " ");
+ }
+ m_Group.AddFunction("FunctionButton_Pattern_1", info.order, info.functionId, title, info.redPointId);
+ }
+
+ m_TitleIcon.SetSprite(WindowConfig.GetTitleIconKey(name));
+ m_TitleIcon.SetNativeSize();
+
+ m_Close.SetListener(CloseWindow);
+ m_Left.SetListener(() => { m_Group.TriggerLast(); });
+ m_Right.SetListener(() => { m_Group.TriggerNext(); });
+ }
+
+ protected override void OnPreOpen()
+ {
+ base.OnPreOpen();
+
+ if (m_Copper == null)
+ m_Copper = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText");
+ m_Diamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText");
+ m_BindDiamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText");
+
+
+ UpdateMoney();
+ }
+
+ protected override void OnPreClose()
+ {
+ base.OnPreClose();
+ CloseSubWindows();
+ }
+
+ protected override void OnOpen()
+ {
+ base.OnOpen();
+
+ PlayerDatas.Instance.playerDataRefreshEvent += OnPlayerDataUpdate;
+
+ ExecuteNextFrame(() => {
+ m_Group.TriggerByOrder(functionOrder);
+ m_Group.GotoOrder(functionOrder);
+ });
+
+ m_Left.SetActive(m_Group.unLockedCount > 1);
+ m_Right.SetActive(m_Group.unLockedCount > 1);
+ }
+
+ protected virtual void CloseSubWindows()
+ {
+ if (null != subWindow)
+ {
+ subWindow.CloseWindow();
+ }
+ subWindow = null;
+ }
+
+ public void SetFunctionListener(int order, Action callBack)
+ {
+ m_Group.SetFunctionListener(order, callBack);
+ }
+
+ public void SetFunctionButtonActive(int order, bool isShow)
+ {
+ m_Group.SetFunctionButtonActive(order, isShow);
+ }
+
+ public RedPointState GetFunctionButtonRedPointState(int order)
+ {
+ return m_Group.GetFunctionButtonRedPointState(order);
+ }
+
+ public void FunctionButtonInvoke(int order)
+ {
+ m_Group.TriggerByOrder(order);
+ m_Group.GotoOrder(order);
+ }
+
+ private void OnPlayerDataUpdate(PlayerDataType type)
+ {
+ switch (type)
+ {
+ case PlayerDataType.Gold:
+ case PlayerDataType.GoldPaper:
+ case PlayerDataType.Silver:
+ case PlayerDataType.ExAttr6:
+ case PlayerDataType.default5:
+ case PlayerDataType.default6:
+ UpdateMoney();
+ break;
+ }
+ }
+
+ void UpdateMoney()
+ {
+ if (m_Copper == null)
+ return;
+ m_Copper.text = ItemLogicUtility.Instance.OnChangeCoinsUnit(PlayerDatas.Instance.baseData.allCopper);
+ m_Diamond.text = UIHelper.GetMoneyCntEx(1).ToString();
+ if (PlayerDatas.Instance.baseData.bindDiamond > 0)
+ m_BindDiamond.text = ItemLogicUtility.Instance.OnChangeCoinsUnit(PlayerDatas.Instance.baseData.bindDiamond);
+ else
+ m_BindDiamond.text = UIHelper.GetMoneyCntEx(2).ToString();
+ }
+}
\ No newline at end of file
diff --git a/Main/UI/OneLevelWin.cs.meta b/Main/UI/OneLevelWin.cs.meta
new file mode 100644
index 0000000..a6d7f19
--- /dev/null
+++ b/Main/UI/OneLevelWin.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3439b4ac79c53fc44a7417ab90b5c18d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/UI/UIBase.cs b/Main/UI/UIBase.cs
index 79f73fd..7e0e1eb 100644
--- a/Main/UI/UIBase.cs
+++ b/Main/UI/UIBase.cs
@@ -4,6 +4,7 @@
using DG.Tweening;
using UnityEngine.UI; // DOTween 鎻掍欢寮曠敤
using Cysharp.Threading.Tasks;
+using System;
public enum UILayer
{
@@ -55,6 +56,18 @@
// 瀛怳I绠$悊
[HideInInspector] public List<UIBase> childrenUI = new List<UIBase>();
+ // 鎵撳紑閬僵
+ [SerializeField] public bool openMask = false;
+
+ // 鐐瑰嚮绌虹櫧鍖哄煙鍏抽棴鐣岄潰
+ [SerializeField] public bool clickEmptySpaceClose = false;
+
+ private GameObject screenMask = null;
+
+ private Button btnClickEmptyClose;
+
+ protected int functionOrder = 0;
+
// 鍐呴儴鐘舵��
protected bool isActive = false;
protected bool isAnimating = false;
@@ -88,6 +101,16 @@
originalScale = rectTransform.localScale;
originalPosition = rectTransform.anchoredPosition;
}
+
+ ApplySettings();
+
+ if (openMask)
+ {
+ screenMask = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ScreenMask"), transform);
+ screenMask.transform.localScale = Vector3.one;
+ screenMask.transform.localPosition = Vector3.zero;
+ screenMask.transform.SetAsFirstSibling();
+ }
}
protected virtual void Start()
@@ -95,6 +118,29 @@
// 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栧垵濮嬪寲
}
+ protected async UniTask ApplySettings()
+ {
+ await UniTask.DelayFrame(5);
+
+ if (null != transform)
+ {
+ if (clickEmptySpaceClose)
+ {
+ GameObject goBtnESC = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ClickEmptyCloseMask"), transform);
+ // Load
+ btnClickEmptyClose = goBtnESC.GetComponent<Button>();
+ btnClickEmptyClose.AddListener(CloseWindow);
+ btnClickEmptyClose.transform.SetAsFirstSibling();
+ }
+ }
+ }
+
+ protected async void ExecuteNextFrame(Action _action)
+ {
+ await UniTask.DelayFrame(1);
+ _action?.Invoke();
+ }
+
protected virtual void OnDestroy()
{
// 纭繚鍔ㄧ敾琚纭竻鐞�
--
Gitblit v1.8.0