not enough rc for rematch
This commit is contained in:
@@ -42,6 +42,8 @@ public class GameOverCanvas : MonoBehaviour
|
||||
|
||||
public float returnToMenuCountdown = 15f;
|
||||
|
||||
/// <summary>Each player needs at least 2.0 RC (20 coin units) to rematch.</summary>
|
||||
const int MinimumRematchRcCoins = 20;
|
||||
|
||||
[Header("Rematch panel")]
|
||||
public CanvasGroup rematchPanel;
|
||||
@@ -102,7 +104,8 @@ public class GameOverCanvas : MonoBehaviour
|
||||
}
|
||||
|
||||
void OnBtnRematchClicked(){
|
||||
// LevelLoadManager.LoadLevel("Game");
|
||||
if (!BothPlayersHaveMinimumRematchRc())
|
||||
return;
|
||||
NetPlayer.localPlayer.RequestRematch();
|
||||
SetRematchPendingState(true);
|
||||
}
|
||||
@@ -250,12 +253,7 @@ public class GameOverCanvas : MonoBehaviour
|
||||
rcPrize = CoinHelper.Format(GameManager.MatchRcPrizeCoins);
|
||||
}
|
||||
|
||||
btnRematch.interactable = winningTeam != myTeam;
|
||||
if(winningTeam == myTeam){
|
||||
rematchWarningLoser.text = "Only the loser can request a rematch";
|
||||
}else{
|
||||
rematchWarningLoser.text = "";
|
||||
}
|
||||
UpdateRematchAvailability();
|
||||
|
||||
StartCoroutine(CoroutineShow());
|
||||
|
||||
@@ -406,6 +404,41 @@ public class GameOverCanvas : MonoBehaviour
|
||||
txtMyRCBalance.text = myText;
|
||||
if (txtOpponentRCBalance != null)
|
||||
txtOpponentRCBalance.text = oppText;
|
||||
|
||||
if (loadingPlaceholder == null)
|
||||
UpdateRematchAvailability();
|
||||
}
|
||||
|
||||
static int GetRcCoins(MatchmadePlayer player) =>
|
||||
player == null ? 0 : Mathf.Max(0, Mathf.FloorToInt(player.rc));
|
||||
|
||||
bool BothPlayersHaveMinimumRematchRc()
|
||||
{
|
||||
return GetRcCoins(LevelLoadManager.myPlayer) >= MinimumRematchRcCoins
|
||||
&& GetRcCoins(LevelLoadManager.opponentPlayer) >= MinimumRematchRcCoins;
|
||||
}
|
||||
|
||||
void UpdateRematchAvailability()
|
||||
{
|
||||
if (winningTeam == myTeam)
|
||||
{
|
||||
btnRematch.interactable = false;
|
||||
if (rematchWarningLoser != null)
|
||||
rematchWarningLoser.text = "Only the loser can request a rematch";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BothPlayersHaveMinimumRematchRc())
|
||||
{
|
||||
btnRematch.interactable = false;
|
||||
if (rematchWarningLoser != null)
|
||||
rematchWarningLoser.text = "Not enough RC";
|
||||
return;
|
||||
}
|
||||
|
||||
btnRematch.interactable = true;
|
||||
if (rematchWarningLoser != null)
|
||||
rematchWarningLoser.text = "";
|
||||
}
|
||||
|
||||
IEnumerator FetchPlayerRcAndApply(string baseUrl, MatchmadePlayer player)
|
||||
|
||||
Reference in New Issue
Block a user