Roulette/Assets/Scripts/RouletteManager.cs

62 lines
2.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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;}}
public static UnityEvent<float> OnMoneyAvailablChanged = new UnityEvent<float>();
public static Dictionary<float, Chip> chipsBoard {get; private set;}
public static bool RegisterChip(Chip chip){
if(chipsBoard == null){chipsBoard = new Dictionary<float, Chip>();}
if(chipsBoard.ContainsKey(chip.value)){return false;}
chipsBoard.Add(chip.value, chip);
selectedChipChanged.AddListener(chip.OnSelectedChanged);
chip.OnSelectedChanged(SelectedChip);
return true;
}
public static UnityEvent<float> selectedChipChanged = new UnityEvent<float>();
private static float m_selectedChip = 0.2f;
public static float SelectedChip { get{ return m_selectedChip; } set{
m_selectedChip = value;
selectedChipChanged.Invoke(value);
}}
public static Chip SelectedChipItem{get{return chipsBoard[SelectedChip];}}
public static int[] RouletteNumbers = {0,32,15,19,4,21,2,25,17,34,6,27,13,36,11,30,8,23,10,5,24,16,33,1,20,14,31,9,22,18,29,7,28,12,35,3,26};
public static List<int> Reds = new List<int>(){1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36};
public static float bets;
public TMP_Text betsvalue;
public static void AddBet(float value){
bets += value;
MoneyAvailable-=value;
instance.BetsChanged();
}
void Awake(){
instance =this;
}
void Start()
{
Spinner.OnSpinStopped.AddListener(OnSpinStopped);
}
void OnSpinStopped(int landedValue){
MoneyAvailable -= 100;
}
void BetsChanged(){
betsvalue.text = "$"+bets.ToString();
}
}