装备系统完结,修复并加入很多
This commit is contained in:
@@ -20,6 +20,8 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
[Header("player unique so")]
|
||||
public Player_SO player_SO;
|
||||
public Text playerCoins_legacy;
|
||||
public Text player_mmrFragment;
|
||||
public Text player_rks;
|
||||
[Header("put prefabs here")]
|
||||
public GameObject putPrefabsHere;
|
||||
[Header("son buttons")]
|
||||
@@ -30,6 +32,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
public Button email_display;
|
||||
public Button notice_display;
|
||||
public Button market_launch;
|
||||
public Button button_userBag;
|
||||
|
||||
[Header("User Guide")]
|
||||
[SerializeField] private Button userGuideButton;
|
||||
@@ -62,6 +65,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
public GameObject userInfo_prefab;
|
||||
public GameObject email_prefab;
|
||||
public GameObject notice_prefab;
|
||||
public GameObject userBag_prefab;
|
||||
|
||||
[Header("New Back Buttons")]
|
||||
[SerializeField] private Button back_navButton;
|
||||
@@ -102,6 +106,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
private UnityAction navSettingsAction;
|
||||
private UnityAction navGuideAction;
|
||||
private UnityAction instantiateMarket;
|
||||
private UnityAction instantiateUserBag;
|
||||
|
||||
// cached reference to the settings instance to ensure only one exists
|
||||
private GameObject settingsInstance;
|
||||
@@ -110,6 +115,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
private GameObject showLevelInstance;
|
||||
private GameObject emailInstance;
|
||||
private GameObject noticeInstance;
|
||||
private GameObject userBagInstance;
|
||||
private CanvasGroup musicPicGroup;
|
||||
private Coroutine musicPicFade;
|
||||
private bool musicPicVisible = true;
|
||||
@@ -118,6 +124,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
private bool lastOverlayPanelsVisibilityState;
|
||||
private readonly Dictionary<string, int> guideIndexByScene = new Dictionary<string, int>();
|
||||
private string currentGuideScene = string.Empty;
|
||||
private static btmandtopController activeInstance;
|
||||
|
||||
private static readonly List<string> sceneHistory = new List<string>();
|
||||
private static bool sceneHistoryHooked = false;
|
||||
@@ -125,6 +132,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
void Awake()
|
||||
{
|
||||
activeInstance = this;
|
||||
EnsureMusicPicRoot();
|
||||
InitializeSceneHistoryIfNeeded();
|
||||
}
|
||||
@@ -133,7 +141,12 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
{
|
||||
PlayerEconomyLedger.EnsureInstance().AttachPlayerData(player_SO);
|
||||
PlayerEconomyLedger.EnsureInstance().OnCoinsChanged += HandleCoinsChanged;
|
||||
PlayerEconomyLedger.EnsureInstance().OnMaterialChanged += HandleMaterialChanged;
|
||||
PlayerRksService.EnsureLoaded(player_SO);
|
||||
PlayerRksService.OnRksChanged += HandleRksChanged;
|
||||
UpdatePlayerCoinsLegacyText(PlayerEconomyLedger.EnsureInstance().GetCoins());
|
||||
UpdatePlayerMmrFragmentText(PlayerEconomyLedger.EnsureInstance().GetMaterial());
|
||||
UpdatePlayerRksText(PlayerRksService.GetBestOverallRks(player_SO));
|
||||
|
||||
if (button_Music == null)
|
||||
{
|
||||
@@ -156,6 +169,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
// instantiateNotice = () => ShowNoticePrefab();
|
||||
navGuideAction = () => ToggleGuideDisplay();
|
||||
instantiateMarket = () => ShowStorePrefab();
|
||||
instantiateUserBag = () => ShowUserBagPrefab();
|
||||
|
||||
if (settings_launch != null)
|
||||
settings_launch.onClick.AddListener(instantiateSettings);
|
||||
@@ -171,6 +185,8 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
notice_display.onClick.AddListener(instantiateNotice);
|
||||
if (market_launch != null)
|
||||
market_launch.onClick.AddListener(instantiateMarket);
|
||||
if (button_userBag != null)
|
||||
button_userBag.onClick.AddListener(instantiateUserBag);
|
||||
if (userGuideButton != null)
|
||||
userGuideButton.onClick.AddListener(navGuideAction);
|
||||
if (preIMGb != null)
|
||||
@@ -473,6 +489,8 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
notice_display.onClick.RemoveListener(instantiateNotice);
|
||||
if (market_launch != null)
|
||||
market_launch.onClick.RemoveListener(instantiateMarket);
|
||||
if (button_userBag != null)
|
||||
button_userBag.onClick.RemoveListener(instantiateUserBag);
|
||||
if (userGuideButton != null)
|
||||
userGuideButton.onClick.RemoveListener(navGuideAction);
|
||||
if (preIMGb != null)
|
||||
@@ -493,7 +511,17 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
settings_navButton.onClick.RemoveListener(navSettingsAction);
|
||||
|
||||
if (PlayerEconomyLedger.Instance != null)
|
||||
{
|
||||
PlayerEconomyLedger.Instance.OnCoinsChanged -= HandleCoinsChanged;
|
||||
PlayerEconomyLedger.Instance.OnMaterialChanged -= HandleMaterialChanged;
|
||||
}
|
||||
|
||||
PlayerRksService.OnRksChanged -= HandleRksChanged;
|
||||
|
||||
if (ReferenceEquals(activeInstance, this))
|
||||
{
|
||||
activeInstance = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCoinsChanged(int coinAmount)
|
||||
@@ -501,6 +529,16 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
UpdatePlayerCoinsLegacyText(coinAmount);
|
||||
}
|
||||
|
||||
private void HandleMaterialChanged(int materialAmount)
|
||||
{
|
||||
UpdatePlayerMmrFragmentText(materialAmount);
|
||||
}
|
||||
|
||||
private void HandleRksChanged(float rksAmount)
|
||||
{
|
||||
UpdatePlayerRksText(rksAmount);
|
||||
}
|
||||
|
||||
private void UpdatePlayerCoinsLegacyText(int coinAmount)
|
||||
{
|
||||
if (playerCoins_legacy != null)
|
||||
@@ -509,6 +547,46 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePlayerMmrFragmentText(int fragmentAmount)
|
||||
{
|
||||
if (player_mmrFragment != null)
|
||||
{
|
||||
player_mmrFragment.text = fragmentAmount.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePlayerRksText(float rksAmount)
|
||||
{
|
||||
if (player_rks == null)
|
||||
{
|
||||
player_rks = FindLegacyTextByLiteral("player_rks");
|
||||
}
|
||||
|
||||
if (player_rks != null)
|
||||
{
|
||||
player_rks.text = rksAmount.ToString("F2");
|
||||
}
|
||||
}
|
||||
|
||||
private Text FindLegacyTextByLiteral(string literal)
|
||||
{
|
||||
if (string.IsNullOrEmpty(literal))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Text[] texts = GetComponentsInChildren<Text>(true);
|
||||
for (int i = 0; i < texts.Length; i++)
|
||||
{
|
||||
if (texts[i] != null && texts[i].text == literal)
|
||||
{
|
||||
return texts[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ToggleGuideDisplay()
|
||||
{
|
||||
if (guideDisplayImage == null)
|
||||
@@ -751,7 +829,8 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|| (storeInstance != null && storeInstance.activeInHierarchy)
|
||||
|| (showLevelInstance != null && showLevelInstance.activeInHierarchy)
|
||||
|| (emailInstance != null && emailInstance.activeInHierarchy)
|
||||
|| (noticeInstance != null && noticeInstance.activeInHierarchy);
|
||||
|| (noticeInstance != null && noticeInstance.activeInHierarchy)
|
||||
|| (userBagInstance != null && userBagInstance.activeInHierarchy);
|
||||
}
|
||||
|
||||
private void BroadcastOverlayPanelsVisibility()
|
||||
@@ -764,8 +843,12 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void ShowLevelPrefab()
|
||||
{
|
||||
bool opened = ShowPrefab(showLevel_prefab, ref showLevelInstance);
|
||||
if (opened)
|
||||
if (ToggleIfAlreadyOpen(ref showLevelInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (OpenPrefab(showLevel_prefab, ref showLevelInstance))
|
||||
{
|
||||
CloseInfoPanels(showLevelInstance);
|
||||
}
|
||||
@@ -773,8 +856,12 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void ShowStorePrefab()
|
||||
{
|
||||
bool opened = ShowPrefab(store_prefab, ref storeInstance);
|
||||
if (opened)
|
||||
if (ToggleIfAlreadyOpen(ref storeInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (OpenPrefab(store_prefab, ref storeInstance))
|
||||
{
|
||||
CloseInfoPanels(storeInstance);
|
||||
}
|
||||
@@ -782,8 +869,12 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void ShowEmailPrefab()
|
||||
{
|
||||
bool opened = ShowPrefab(email_prefab, ref emailInstance);
|
||||
if (opened)
|
||||
if (ToggleIfAlreadyOpen(ref emailInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (OpenPrefab(email_prefab, ref emailInstance))
|
||||
{
|
||||
CloseInfoPanels(emailInstance);
|
||||
}
|
||||
@@ -791,14 +882,48 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void ShowNoticePrefab()
|
||||
{
|
||||
bool opened = ShowPrefab(notice_prefab, ref noticeInstance);
|
||||
if (opened)
|
||||
if (ToggleIfAlreadyOpen(ref noticeInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (OpenPrefab(notice_prefab, ref noticeInstance))
|
||||
{
|
||||
CloseInfoPanels(noticeInstance);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShowPrefab(GameObject prefab, ref GameObject instance)
|
||||
private void ShowUserBagPrefab()
|
||||
{
|
||||
if (ToggleIfAlreadyOpen(ref userBagInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (OpenPrefab(userBag_prefab, ref userBagInstance))
|
||||
{
|
||||
CloseInfoPanels(userBagInstance);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ToggleIfAlreadyOpen(ref GameObject instance)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!instance.activeInHierarchy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
instance.SetActive(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool OpenPrefab(GameObject prefab, ref GameObject instance)
|
||||
{
|
||||
if (prefab == null || putPrefabsHere == null) return false;
|
||||
|
||||
@@ -816,14 +941,16 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldOpen = !instance.activeSelf;
|
||||
instance.SetActive(shouldOpen);
|
||||
if (!shouldOpen)
|
||||
if (instance == null)
|
||||
{
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!instance.activeSelf)
|
||||
{
|
||||
instance.SetActive(true);
|
||||
}
|
||||
|
||||
PlacePanelBelowSettings(instance);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
return true;
|
||||
@@ -868,6 +995,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
CloseInstance(ref showLevelInstance, keep);
|
||||
CloseInstance(ref emailInstance, keep);
|
||||
CloseInstance(ref noticeInstance, keep);
|
||||
CloseInstance(ref userBagInstance, keep);
|
||||
}
|
||||
|
||||
private void CloseInstance(ref GameObject instance, GameObject keep)
|
||||
@@ -915,6 +1043,18 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void RefreshOverlayVisibilityState()
|
||||
{
|
||||
if (activeInstance != null)
|
||||
{
|
||||
activeInstance.BroadcastOverlayPanelsVisibility();
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentOverlayPanelsVisible = false;
|
||||
GlobalOverlayPanelVisibilityChanged?.Invoke(false);
|
||||
}
|
||||
|
||||
private void InstantiatePrefab(GameObject prefab)
|
||||
{
|
||||
if (prefab != null && putPrefabsHere != null)
|
||||
|
||||
Reference in New Issue
Block a user