test week rc
This commit is contained in:
@@ -46,6 +46,7 @@ public class GameOverCanvas : MonoBehaviour
|
||||
const int MinimumRematchRcCoins = 20;
|
||||
|
||||
[Header("Bet Limit")]
|
||||
public TMP_Text txtRcBalance;
|
||||
public TMP_Text txtBetLimitWarning;
|
||||
public CanvasGroup betLimitAdjustPanel;
|
||||
//minVal: 2, max Val 500, when its 500, show ∞ on the text
|
||||
@@ -59,6 +60,8 @@ public class GameOverCanvas : MonoBehaviour
|
||||
const int BetLimitMax = 500;
|
||||
const int BetLimitUnlimited = 500;
|
||||
|
||||
int rematchOpponentBetLimitCoins = BetLimitUnlimited;
|
||||
|
||||
[Header("Rematch panel")]
|
||||
public CanvasGroup rematchPanel;
|
||||
public RectTransform rematchPopup;
|
||||
@@ -130,6 +133,38 @@ public class GameOverCanvas : MonoBehaviour
|
||||
return PlayerPrefs.GetInt(PersonalBetLimitPrefsKey, BetLimitUnlimited);
|
||||
}
|
||||
|
||||
static int EffectiveBetLimitCap(int limitCoins) =>
|
||||
limitCoins >= BetLimitUnlimited ? int.MaxValue : limitCoins;
|
||||
|
||||
int GetRematchMaxBetCoins()
|
||||
{
|
||||
int maxBet = Mathf.Min(
|
||||
EffectiveBetLimitCap(rematchOpponentBetLimitCoins),
|
||||
GetRcCoins(LevelLoadManager.myPlayer),
|
||||
GetRcCoins(LevelLoadManager.opponentPlayer));
|
||||
return Mathf.Max(0, maxBet);
|
||||
}
|
||||
|
||||
void ApplyRematchBetSliderLimits()
|
||||
{
|
||||
if (betSlider == null)
|
||||
return;
|
||||
|
||||
int maxBet = GetRematchMaxBetCoins();
|
||||
betSlider.maxValue = maxBet;
|
||||
if (maxBet <= 0)
|
||||
{
|
||||
betSlider.minValue = 0;
|
||||
betSlider.value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
betSlider.minValue = Mathf.Clamp(maxBet / 10f, 5, 10000);
|
||||
betSlider.value = Mathf.Clamp(maxBet / 2, betSlider.minValue, maxBet);
|
||||
}
|
||||
OnBetSliderValueChanged(betSlider.value);
|
||||
}
|
||||
|
||||
static void SetPersonalBetLimit(int limitCoins)
|
||||
{
|
||||
limitCoins = Mathf.Clamp(limitCoins, BetLimitMin, BetLimitMax);
|
||||
@@ -221,13 +256,16 @@ public class GameOverCanvas : MonoBehaviour
|
||||
void OnBtnRematchClicked(){
|
||||
if (!BothPlayersHaveMinimumRematchRc())
|
||||
return;
|
||||
if (txtBetLimitWarning != null)
|
||||
txtBetLimitWarning.gameObject.SetActive(false);
|
||||
NetPlayer.localPlayer.RequestRematch();
|
||||
SetRematchPendingState(true);
|
||||
}
|
||||
|
||||
public void OnRematchRequested(){
|
||||
public void OnRematchRequested(int opponentMaxBetLimitCoins){
|
||||
rematchOpponentBetLimitCoins = opponentMaxBetLimitCoins;
|
||||
if(winningTeam == myTeam){
|
||||
//Only i can initiate the rematch, so here we go
|
||||
//Only the loser can initiate the rematch; winner sets the stake
|
||||
ShowRematchPanel();
|
||||
}else{
|
||||
rematchWarningLoser.text = "Waiting for opponent to accept";
|
||||
@@ -378,6 +416,7 @@ public class GameOverCanvas : MonoBehaviour
|
||||
}
|
||||
|
||||
UpdateRematchAvailability();
|
||||
ApplyRcBalancesToUi(null);
|
||||
|
||||
StartCoroutine(CoroutineShow());
|
||||
|
||||
@@ -461,11 +500,8 @@ public class GameOverCanvas : MonoBehaviour
|
||||
|
||||
public void ShowRematchPanel(){
|
||||
SetRematchPendingState(true);
|
||||
ApplyRematchBetSliderLimits();
|
||||
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(){
|
||||
@@ -528,9 +564,15 @@ public class GameOverCanvas : MonoBehaviour
|
||||
txtMyRCBalance.text = myText;
|
||||
if (txtOpponentRCBalance != null)
|
||||
txtOpponentRCBalance.text = oppText;
|
||||
if (txtRcBalance != null)
|
||||
txtRcBalance.text = loadingPlaceholder ?? (my != null ? CoinHelper.FormatString((int)my.rc) + " RC" : "0.0 RC");
|
||||
|
||||
if (loadingPlaceholder == null)
|
||||
{
|
||||
UpdateRematchAvailability();
|
||||
if (rematchPanel != null && rematchPanel.alpha > 0.01f)
|
||||
ApplyRematchBetSliderLimits();
|
||||
}
|
||||
}
|
||||
|
||||
static int GetRcCoins(MatchmadePlayer player) =>
|
||||
|
||||
Reference in New Issue
Block a user