settings
This commit is contained in:
@@ -120,6 +120,7 @@ public class GameOverCanvas : MonoBehaviour
|
||||
btnLeave.interactable = !val;
|
||||
if(val){
|
||||
StopCoroutine(countdownCoroutine);
|
||||
countdownTxt.text = "";
|
||||
}else{
|
||||
countdownCoroutine = StartCoroutine(CoroutineCountdown());
|
||||
}
|
||||
@@ -336,6 +337,8 @@ public class GameOverCanvas : MonoBehaviour
|
||||
StartCoroutine(CoroutineShowRematchPanel());
|
||||
|
||||
betSlider.maxValue = (LevelLoadManager.myPlayer.rc < LevelLoadManager.opponentPlayer.rc) ? LevelLoadManager.myPlayer.rc : LevelLoadManager.opponentPlayer.rc;
|
||||
betSlider.value = betSlider.maxValue / 2;
|
||||
betSlider.minValue = Mathf.Clamp(betSlider.maxValue /10f,5,10000);
|
||||
}
|
||||
|
||||
IEnumerator CoroutineShowRematchPanel(){
|
||||
@@ -358,7 +361,6 @@ public class GameOverCanvas : MonoBehaviour
|
||||
StartCoroutine(CoroutineHideRematchPanel());
|
||||
|
||||
countdownCoroutine = StartCoroutine(CoroutineCountdown());
|
||||
|
||||
}
|
||||
|
||||
IEnumerator CoroutineHideRematchPanel(){
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -5,6 +6,8 @@ using UnityEngine.UI;
|
||||
|
||||
public class MainMenuManager : MonoBehaviour
|
||||
{
|
||||
public const string MainMenuSceneName = "MainMenu";
|
||||
|
||||
const string CryptoAddressPrefsKey = "MainMenu.CryptoAddress";
|
||||
/// <summary>500 CC fee to process a withdrawal.</summary>
|
||||
const int WithdrawalFeeCc = 500;
|
||||
@@ -25,6 +28,8 @@ public class MainMenuManager : MonoBehaviour
|
||||
[Header("Play")]
|
||||
public Button btnPlay;
|
||||
public TMP_Text rcPlayText;
|
||||
public TMP_Text entryFeeTxt;
|
||||
public TMP_Text rcPrizeTxt;
|
||||
|
||||
[Header("Dummy Buy")]
|
||||
public Button btnBuyUsd5;
|
||||
@@ -42,6 +47,11 @@ public class MainMenuManager : MonoBehaviour
|
||||
public ToggleButton toggleSfx;
|
||||
public ToggleButton toggleMusic;
|
||||
|
||||
/// <summary>Default play cost (coin units) if <c>/settings</c> is not loaded yet.</summary>
|
||||
const int FallbackEntryFeeCoins = 21;
|
||||
|
||||
int _matchEntryFeeCoins = FallbackEntryFeeCoins;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if(LoginManager.instance==null){
|
||||
@@ -92,6 +102,9 @@ public class MainMenuManager : MonoBehaviour
|
||||
|
||||
toggleSfx.SetIsOn(AudioManager.instance.IsSFXOn());
|
||||
toggleMusic.SetIsOn(AudioManager.instance.IsMusicOn());
|
||||
|
||||
if (!LevelLoadManager.BlocksMainMenuSettingsBootstrap)
|
||||
StartCoroutine(CoBootstrapSettingsWithoutLoader());
|
||||
}
|
||||
|
||||
void OnDestroy(){
|
||||
@@ -117,7 +130,7 @@ public class MainMenuManager : MonoBehaviour
|
||||
Debug.LogError("Play blocked: user profile not loaded.");
|
||||
return;
|
||||
}
|
||||
if (LoginManager.CurrentUser.rc < 21)
|
||||
if (LoginManager.CurrentUser.rc < _matchEntryFeeCoins)
|
||||
{
|
||||
Debug.LogError("Not enough RC to play");
|
||||
return;
|
||||
@@ -213,10 +226,13 @@ public class MainMenuManager : MonoBehaviour
|
||||
ccText.text = user.cc.ToString("N0") + " CC";
|
||||
rcText.text = CoinHelper.FormatString(user.rc) + " RC";
|
||||
|
||||
if(LoginManager.CurrentUser.rc < 21){
|
||||
if (LoginManager.CurrentUser.rc < _matchEntryFeeCoins)
|
||||
{
|
||||
rcPlayText.text = "Not enough RC to play";
|
||||
btnPlay.interactable = false;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
rcPlayText.text = "";
|
||||
btnPlay.interactable = true;
|
||||
}
|
||||
@@ -224,6 +240,62 @@ public class MainMenuManager : MonoBehaviour
|
||||
UpdateWithdrawalStatus(user);
|
||||
}
|
||||
|
||||
/// <summary>Called by <see cref="LevelLoadManager"/> so the loading overlay stays until matchmaker settings are refreshed.</summary>
|
||||
public IEnumerator FinishLoadingScreenAndApplySettings()
|
||||
{
|
||||
yield return CoReadyMatchmakerSettingsThenApply();
|
||||
}
|
||||
|
||||
IEnumerator CoBootstrapSettingsWithoutLoader()
|
||||
{
|
||||
yield return null;
|
||||
yield return CoReadyMatchmakerSettingsThenApply();
|
||||
}
|
||||
|
||||
IEnumerator CoReadyMatchmakerSettingsThenApply()
|
||||
{
|
||||
const float endpointWaitSec = 30f;
|
||||
float deadline = Time.realtimeSinceStartup + endpointWaitSec;
|
||||
while (!Cupid.IsEndpointReady && Time.realtimeSinceStartup < deadline)
|
||||
yield return null;
|
||||
|
||||
yield return Cupid.CoRefreshSettings();
|
||||
|
||||
ApplyMatchmakerFeeUi();
|
||||
|
||||
if (LoginManager.CurrentUser != null)
|
||||
OnUserUpdated(LoginManager.CurrentUser);
|
||||
}
|
||||
|
||||
void ApplyMatchmakerFeeUi()
|
||||
{
|
||||
if (Cupid.Settings == null)
|
||||
{
|
||||
_matchEntryFeeCoins = FallbackEntryFeeCoins;
|
||||
if (entryFeeTxt != null)
|
||||
entryFeeTxt.text = "—";
|
||||
if (rcPrizeTxt != null)
|
||||
rcPrizeTxt.text = "—";
|
||||
return;
|
||||
}
|
||||
|
||||
CupidSettings s = Cupid.Settings;
|
||||
_matchEntryFeeCoins = s.entry_fee > 0 ? s.entry_fee : FallbackEntryFeeCoins;
|
||||
|
||||
if (entryFeeTxt != null)
|
||||
{
|
||||
entryFeeTxt.text = s.entry_fee > 0
|
||||
? CoinHelper.FormatString(s.entry_fee) + " RC"
|
||||
: "—";
|
||||
}
|
||||
if (rcPrizeTxt != null)
|
||||
{
|
||||
rcPrizeTxt.text = s.rc_prize > 0
|
||||
? CoinHelper.FormatString(s.rc_prize) + " RC"
|
||||
: "—";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ShowMainMenuScreen(){
|
||||
statsPanel.SetActive(true);
|
||||
|
||||
@@ -51,13 +51,36 @@ public class LevelLoadManager : MonoBehaviour
|
||||
StartCoroutine(CoroutineLoadLevel(levelName));
|
||||
}
|
||||
|
||||
/// <summary>When true, Main Menu bootstrap (matchmaker settings) owns the overlay; suppress duplicate work in <see cref="MainMenuManager"/>.</summary>
|
||||
public static bool BlocksMainMenuSettingsBootstrap { get; private set; }
|
||||
|
||||
IEnumerator CoroutineLoadLevel(string levelName){
|
||||
instance.Show();
|
||||
yield return new WaitForSeconds(transitionDuration);
|
||||
if(matchmadeUI.activeSelf){
|
||||
yield return new WaitForSeconds(3f);
|
||||
}
|
||||
yield return SceneManager.LoadSceneAsync(levelName);
|
||||
|
||||
bool mainMenuDestination = levelName == MainMenuManager.MainMenuSceneName;
|
||||
if (mainMenuDestination)
|
||||
BlocksMainMenuSettingsBootstrap = true;
|
||||
|
||||
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(levelName);
|
||||
yield return asyncLoad;
|
||||
|
||||
if (mainMenuDestination)
|
||||
{
|
||||
try
|
||||
{
|
||||
MainMenuManager menu = UnityEngine.Object.FindObjectOfType<MainMenuManager>();
|
||||
if (menu != null)
|
||||
yield return menu.FinishLoadingScreenAndApplySettings();
|
||||
}
|
||||
finally
|
||||
{
|
||||
BlocksMainMenuSettingsBootstrap = false;
|
||||
}
|
||||
}
|
||||
|
||||
instance.Hide();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user