From a7f4c5ecc5268c49f6a6caf769b3ebee6f237662 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 04 六月 2025 18:52:55 +0800
Subject: [PATCH] 目录迁移 整理
---
Main/System/Main/MainWin.cs | 406 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 203 insertions(+), 203 deletions(-)
diff --git a/Main/UI/Main/MainWin.cs b/Main/System/Main/MainWin.cs
similarity index 99%
rename from Main/UI/Main/MainWin.cs
rename to Main/System/Main/MainWin.cs
index 6b059df..bafdf44 100644
--- a/Main/UI/Main/MainWin.cs
+++ b/Main/System/Main/MainWin.cs
@@ -1,204 +1,204 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
-
-/// <summary>
-/// 娓告垙涓荤晫闈�
-/// </summary>
-public class MainWin : UIBase
-{
- private GameObject windowBackground;
-
- // 搴曢儴鎸夐挳缁�
- private Button[] bottomTabButtons;
-
- // 褰撳墠閫変腑鐨勫簳閮ㄦ爣绛剧储寮�
- private int currentTabIndex = 0;
-
- // 褰撳墠鎵撳紑鐨勫瓙鐣岄潰
- private UIBase currentSubUI;
-
- /// <summary>
- /// 鍒濆鍖栫粍浠�
- /// </summary>
- protected override void InitComponent()
- {
- base.InitComponent();
-
- windowBackground = transform.Find("RawImgBackground").gameObject;
-
- bottomTabButtons = new Button[5];
-
- for (int i = 1; i <= 5; i++)
- {
- string buttonName = "Buttons/Button" + i;
- bottomTabButtons[i-1] = transform.Find(buttonName).GetComponent<Button>();
- }
-
- // 鍒濆鍖朥I缁勪欢浜嬩欢
- InitButtonEvents();
- }
-
- /// <summary>
- /// 鍒濆鍖朥I缁勪欢浜嬩欢
- /// </summary>
- private void InitButtonEvents()
- {
- // 鍒濆鍖栧簳閮ㄦ寜閽�
- for (int i = 0; i < bottomTabButtons.Length; i++)
- {
- int index = i; // 鎹曡幏绱㈠紩
- bottomTabButtons[i].onClick.AddListener(() => {
- OnBottomTabButtonClicked(index);
- });
- }
- }
-
- protected override void OnOpen()
- {
- base.OnOpen();
-
- // 榛樿閫変腑绗竴涓爣绛�
- SelectBottomTab(0);
-
- // 鍒锋柊UI
- Refresh();
- }
-
- public override void Refresh()
- {
- UpdatePlayerInfo();
- UpdateCurrency();
- }
-
- /// <summary>
- /// 鏇存柊鐜╁淇℃伅
- /// </summary>
- private void UpdatePlayerInfo()
- {
- // 浠庣帺瀹舵暟鎹腑鑾峰彇淇℃伅骞舵洿鏂癠I
- // 渚嬪锛�
- // playerNameText.text = PlayerData.Instance.Name;
- // playerLevelText.text = "Lv." + PlayerData.Instance.Level;
- // powerText.text = PlayerData.Instance.Power.ToString();
- // expSlider.value = PlayerData.Instance.ExpRatio;
- }
-
- /// <summary>
- /// 鏇存柊璐у竵淇℃伅
- /// </summary>
- private void UpdateCurrency()
- {
- // 浠庣帺瀹舵暟鎹腑鑾峰彇璐у竵淇℃伅骞舵洿鏂癠I
- // 渚嬪锛�
- // goldText.text = PlayerData.Instance.Gold.ToString();
- // diamondText.text = PlayerData.Instance.Diamond.ToString();
- // energyText.text = PlayerData.Instance.Energy + "/" + PlayerData.Instance.MaxEnergy;
- }
-
- /// <summary>
- /// 搴曢儴鏍囩鎸夐挳鐐瑰嚮
- /// </summary>
- private void OnBottomTabButtonClicked(int index)
- {
- SelectBottomTab(index);
- }
-
- /// <summary>
- /// 閫夋嫨搴曢儴鏍囩
- /// </summary>
- private void SelectBottomTab(int index)
- {
- // 濡傛灉鐐瑰嚮褰撳墠宸查�変腑鐨勬爣绛撅紝涓嶅仛澶勭悊
- if (currentTabIndex == index && currentSubUI != null)
- {
- return;
- }
-
- // 鏇存柊褰撳墠閫変腑鐨勬爣绛剧储寮�
- currentTabIndex = index;
-
- // 鏇存柊鎸夐挳鐘舵��
- UpdateButtonsState();
-
- // 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
- CloseCurrentSubUI();
-
- // 鏍规嵁閫変腑鐨勬爣绛炬墦寮�瀵瑰簲鐨勭晫闈�
- OpenSubUIByTabIndex(index);
- }
-
- /// <summary>
- /// 鏇存柊鎸夐挳鐘舵��
- /// </summary>
- private void UpdateButtonsState()
- {
- // 閬嶅巻鎵�鏈夋寜閽紝璁剧疆閫変腑鐘舵��
- for (int i = 0; i < bottomTabButtons.Length; i++)
- {
- // 杩欓噷鍙互鏍规嵁鏄惁閫変腑璁剧疆鎸夐挳鐨勮瑙夋晥鏋�
- // 渚嬪锛氭敼鍙樺浘鐗囥�侀鑹茬瓑
- // bottomTabButtons[i].GetComponent<Image>().color = (i == currentTabIndex) ? Color.blue : Color.white;
-
- // 鎴栬�呮縺娲�/绂佺敤閫変腑鍥炬爣
- bottomTabButtons[i].image.color = (i == currentTabIndex) ? Color.white : Color.gray;
- }
- }
-
- /// <summary>
- /// 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
- /// </summary>
- private void CloseCurrentSubUI()
- {
- if (currentSubUI != null)
- {
- // 鍏抽棴褰撳墠鐣岄潰
- currentSubUI.CloseWindow();
- currentSubUI = null;
- }
- }
-
- /// <summary>
- /// 鏍规嵁鏍囩绱㈠紩鎵撳紑瀵瑰簲鐨勫瓙鐣岄潰
- /// </summary>
- private void OpenSubUIByTabIndex(int index)
- {
-
- Debug.Log("鎵撳紑瀛愮晫闈� : " + index);
- // 涓诲煄 闃靛 鍚岀洘 绂忓埄 鍐掗櫓
- windowBackground.SetActive(index != 4);
- //鏍规嵁绱㈠紩鎵撳紑涓嶅悓鐨勭晫闈�
- switch (index)
- {
- case 0:
- // 渚嬪锛氭墦寮�涓婚〉鐣岄潰
- // currentSubUI = UIManager.Instance.OpenUI<HomeUI>();
- Debug.Log("鎵撳紑涓诲煄鐣岄潰");
- break;
- case 1:
- // 渚嬪锛氭墦寮�瑙掕壊鐣岄潰
- // currentSubUI = UIManager.Instance.OpenUI<CharacterUI>();
- Debug.Log("鎵撳紑闃靛鐣岄潰");
- break;
- case 2:
- // 渚嬪锛氭墦寮�鑳屽寘鐣岄潰
- // currentSubUI = UIManager.Instance.OpenUI<BagUI>();
- Debug.Log("鎵撳紑鍚岀洘鐣岄潰");
- break;
- case 3:
- // 渚嬪锛氭墦寮�浠诲姟鐣岄潰
- // currentSubUI = UIManager.Instance.OpenUI<QuestUI>();
- Debug.Log("鎵撳紑绂忓埄鐣岄潰");
- break;
- case 4:
- // 渚嬪锛氭墦寮�璁剧疆鐣岄潰
- currentSubUI = UIManager.Instance.OpenWindow<PlaceWin>();
- Debug.Log("鎵撳紑鍐掗櫓鐣岄潰");
- break;
- default:
- Debug.LogWarning("鏈煡鐨勬爣绛剧储寮�: " + index);
- break;
- }
- }
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+/// <summary>
+/// 娓告垙涓荤晫闈�
+/// </summary>
+public class MainWin : UIBase
+{
+ private GameObject windowBackground;
+
+ // 搴曢儴鎸夐挳缁�
+ private Button[] bottomTabButtons;
+
+ // 褰撳墠閫変腑鐨勫簳閮ㄦ爣绛剧储寮�
+ private int currentTabIndex = 0;
+
+ // 褰撳墠鎵撳紑鐨勫瓙鐣岄潰
+ private UIBase currentSubUI;
+
+ /// <summary>
+ /// 鍒濆鍖栫粍浠�
+ /// </summary>
+ protected override void InitComponent()
+ {
+ base.InitComponent();
+
+ windowBackground = transform.Find("RawImgBackground").gameObject;
+
+ bottomTabButtons = new Button[5];
+
+ for (int i = 1; i <= 5; i++)
+ {
+ string buttonName = "Buttons/Button" + i;
+ bottomTabButtons[i-1] = transform.Find(buttonName).GetComponent<Button>();
+ }
+
+ // 鍒濆鍖朥I缁勪欢浜嬩欢
+ InitButtonEvents();
+ }
+
+ /// <summary>
+ /// 鍒濆鍖朥I缁勪欢浜嬩欢
+ /// </summary>
+ private void InitButtonEvents()
+ {
+ // 鍒濆鍖栧簳閮ㄦ寜閽�
+ for (int i = 0; i < bottomTabButtons.Length; i++)
+ {
+ int index = i; // 鎹曡幏绱㈠紩
+ bottomTabButtons[i].onClick.AddListener(() => {
+ OnBottomTabButtonClicked(index);
+ });
+ }
+ }
+
+ protected override void OnOpen()
+ {
+ base.OnOpen();
+
+ // 榛樿閫変腑绗竴涓爣绛�
+ SelectBottomTab(0);
+
+ // 鍒锋柊UI
+ Refresh();
+ }
+
+ public override void Refresh()
+ {
+ UpdatePlayerInfo();
+ UpdateCurrency();
+ }
+
+ /// <summary>
+ /// 鏇存柊鐜╁淇℃伅
+ /// </summary>
+ private void UpdatePlayerInfo()
+ {
+ // 浠庣帺瀹舵暟鎹腑鑾峰彇淇℃伅骞舵洿鏂癠I
+ // 渚嬪锛�
+ // playerNameText.text = PlayerData.Instance.Name;
+ // playerLevelText.text = "Lv." + PlayerData.Instance.Level;
+ // powerText.text = PlayerData.Instance.Power.ToString();
+ // expSlider.value = PlayerData.Instance.ExpRatio;
+ }
+
+ /// <summary>
+ /// 鏇存柊璐у竵淇℃伅
+ /// </summary>
+ private void UpdateCurrency()
+ {
+ // 浠庣帺瀹舵暟鎹腑鑾峰彇璐у竵淇℃伅骞舵洿鏂癠I
+ // 渚嬪锛�
+ // goldText.text = PlayerData.Instance.Gold.ToString();
+ // diamondText.text = PlayerData.Instance.Diamond.ToString();
+ // energyText.text = PlayerData.Instance.Energy + "/" + PlayerData.Instance.MaxEnergy;
+ }
+
+ /// <summary>
+ /// 搴曢儴鏍囩鎸夐挳鐐瑰嚮
+ /// </summary>
+ private void OnBottomTabButtonClicked(int index)
+ {
+ SelectBottomTab(index);
+ }
+
+ /// <summary>
+ /// 閫夋嫨搴曢儴鏍囩
+ /// </summary>
+ private void SelectBottomTab(int index)
+ {
+ // 濡傛灉鐐瑰嚮褰撳墠宸查�変腑鐨勬爣绛撅紝涓嶅仛澶勭悊
+ if (currentTabIndex == index && currentSubUI != null)
+ {
+ return;
+ }
+
+ // 鏇存柊褰撳墠閫変腑鐨勬爣绛剧储寮�
+ currentTabIndex = index;
+
+ // 鏇存柊鎸夐挳鐘舵��
+ UpdateButtonsState();
+
+ // 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
+ CloseCurrentSubUI();
+
+ // 鏍规嵁閫変腑鐨勬爣绛炬墦寮�瀵瑰簲鐨勭晫闈�
+ OpenSubUIByTabIndex(index);
+ }
+
+ /// <summary>
+ /// 鏇存柊鎸夐挳鐘舵��
+ /// </summary>
+ private void UpdateButtonsState()
+ {
+ // 閬嶅巻鎵�鏈夋寜閽紝璁剧疆閫変腑鐘舵��
+ for (int i = 0; i < bottomTabButtons.Length; i++)
+ {
+ // 杩欓噷鍙互鏍规嵁鏄惁閫変腑璁剧疆鎸夐挳鐨勮瑙夋晥鏋�
+ // 渚嬪锛氭敼鍙樺浘鐗囥�侀鑹茬瓑
+ // bottomTabButtons[i].GetComponent<Image>().color = (i == currentTabIndex) ? Color.blue : Color.white;
+
+ // 鎴栬�呮縺娲�/绂佺敤閫変腑鍥炬爣
+ bottomTabButtons[i].image.color = (i == currentTabIndex) ? Color.white : Color.gray;
+ }
+ }
+
+ /// <summary>
+ /// 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
+ /// </summary>
+ private void CloseCurrentSubUI()
+ {
+ if (currentSubUI != null)
+ {
+ // 鍏抽棴褰撳墠鐣岄潰
+ currentSubUI.CloseWindow();
+ currentSubUI = null;
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁鏍囩绱㈠紩鎵撳紑瀵瑰簲鐨勫瓙鐣岄潰
+ /// </summary>
+ private void OpenSubUIByTabIndex(int index)
+ {
+
+ Debug.Log("鎵撳紑瀛愮晫闈� : " + index);
+ // 涓诲煄 闃靛 鍚岀洘 绂忓埄 鍐掗櫓
+ windowBackground.SetActive(index != 4);
+ //鏍规嵁绱㈠紩鎵撳紑涓嶅悓鐨勭晫闈�
+ switch (index)
+ {
+ case 0:
+ // 渚嬪锛氭墦寮�涓婚〉鐣岄潰
+ // currentSubUI = UIManager.Instance.OpenUI<HomeUI>();
+ Debug.Log("鎵撳紑涓诲煄鐣岄潰");
+ break;
+ case 1:
+ // 渚嬪锛氭墦寮�瑙掕壊鐣岄潰
+ // currentSubUI = UIManager.Instance.OpenUI<CharacterUI>();
+ Debug.Log("鎵撳紑闃靛鐣岄潰");
+ break;
+ case 2:
+ // 渚嬪锛氭墦寮�鑳屽寘鐣岄潰
+ // currentSubUI = UIManager.Instance.OpenUI<BagUI>();
+ Debug.Log("鎵撳紑鍚岀洘鐣岄潰");
+ break;
+ case 3:
+ // 渚嬪锛氭墦寮�浠诲姟鐣岄潰
+ // currentSubUI = UIManager.Instance.OpenUI<QuestUI>();
+ Debug.Log("鎵撳紑绂忓埄鐣岄潰");
+ break;
+ case 4:
+ // 渚嬪锛氭墦寮�璁剧疆鐣岄潰
+ currentSubUI = UIManager.Instance.OpenWindow<PlaceWin>();
+ Debug.Log("鎵撳紑鍐掗櫓鐣岄潰");
+ break;
+ default:
+ Debug.LogWarning("鏈煡鐨勬爣绛剧储寮�: " + index);
+ break;
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0