UI redesigned

This commit is contained in:
2023-03-05 17:25:43 +05:30
parent dbf83bd69f
commit 0703745067
39 changed files with 24122 additions and 235 deletions

View File

@@ -8,7 +8,7 @@ public class RouletteManager : MonoBehaviour
{
public static RouletteManager instance { get; private set;}
private static float moneyAvailable = 1000;
public static float MoneyAvailable {get{ return moneyAvailable;} set{OnMoneyAvailablChanged.Invoke(value); moneyAvailable = value; instance.vcurrencyTxt.text = value.ToString();}}
public static float MoneyAvailable {get{ return moneyAvailable;} set{OnMoneyAvailablChanged.Invoke(value); moneyAvailable = value; foreach(TMP_Text txt in instance.vcurrencyTxt){txt.text = "$ " +value.ToString();}}}
public static UnityEvent<float> OnMoneyAvailablChanged = new UnityEvent<float>();
public static Dictionary<float, Chip> chipsBoard {get; private set;}
@@ -41,7 +41,10 @@ public class RouletteManager : MonoBehaviour
public static bool spinning;
public TMP_Text betsvalue;
public TMP_Text vcurrencyTxt;
public TMP_Text[] vcurrencyTxt;
public TMP_Text walletMoneyTxt;
public float walletMoney;
public Transform betsHistoryParent;
public static void RegisterBettingSpace(BettingSpace space){
@@ -112,19 +115,57 @@ public class RouletteManager : MonoBehaviour
}
void Start()
{
MoneyAvailable = 1000;
walletMoney = MoneyAvailable;
walletMoneyTxt.text = "$ " +MoneyAvailable;
Spinner.OnSpinStopped.AddListener(OnSpinStopped);
}
List<float> betsHistory = new List<float>();
void OnSpinStopped(int landedValue){
float prevMoney=walletMoney;
foreach(Bet bet in bets){
if(bet.Numbers.Contains(landedValue)){
MoneyAvailable += bet.BetAmount * bet.PayoutRatio;
MoneyAvailable += bet.BetAmount;
float addition = (bet.BetAmount * bet.PayoutRatio) + (bet.BetAmount);
MoneyAvailable += addition;
// profit += addition;
}else{
// profit -= bet.BetAmount;
}
}
Debug.Log("Bet profitted : " + (MoneyAvailable - prevMoney));
betsHistory.Add((MoneyAvailable - prevMoney));
walletMoneyTxt.text = "$ " +MoneyAvailable;
walletMoney = MoneyAvailable;
UpdateBetsHistory();
ClearBets();
}
void UpdateBetsHistory(){
int diff = betsHistory.Count - betsHistoryParent.childCount;
for(int i=0; i < diff; i++){
betsHistory.RemoveAt(i);
}
for(int i =0; i < betsHistoryParent.childCount; i++){
if(betsHistory.Count <= i){
betsHistoryParent.GetChild(i).GetChild(0).GetComponent<TMP_Text>().text = "-";
betsHistoryParent.GetChild(i).GetChild(1).GetComponent<TMP_Text>().text = "-";
betsHistoryParent.GetChild(i).GetChild(0).GetComponent<TMP_Text>().color = Color.white;
betsHistoryParent.GetChild(i).GetChild(1).GetComponent<TMP_Text>().color = Color.white;
}else{
Color txtColor = betsHistory[i] > 0 ? Color.green : Color.red;
betsHistoryParent.GetChild(i).GetChild(0).GetComponent<TMP_Text>().text = "$ " + Mathf.Abs(betsHistory[i]).ToString();
betsHistoryParent.GetChild(i).GetChild(1).GetComponent<TMP_Text>().text = betsHistory[i] > 0 ? "Win" : "Lose";
betsHistoryParent.GetChild(i).GetChild(0).GetComponent<TMP_Text>().color = txtColor;
betsHistoryParent.GetChild(i).GetChild(1).GetComponent<TMP_Text>().color = txtColor;
}
}
ClearBets();
}
void BetsChanged(){