// COROUTINES ################################################################################## // [Client/Server] The main initialization coroutine for the match. // Dependant on LoadMatchConfigCoroutine finishing. private IEnumerator InitializeMatchCoroutine() { // Will not run if LoadMatchConfigCoroutine() has not been run. // This gives the functionality of yield return LoadMatchConfigCoroutine() // without needing to pass this/it the MatchSetupController. while (this.config == null) { yield return(null); } Debug.Log(debugTag + "Initializing Match from Config data..."); masterDeck = new MasterDeck(config.DeckFlavor); masterDeckMutable = new MasterDeck(config.DeckFlavor); // [Server] if (hasAuthority) { InitPlayers(); this.matchData = new MatchData(); Debug.Log(debugTag + "Sending current Match Data to Broadcaster... " + this.matchData.ToString()); matchDataBroadcaster.MatchDataStr = JsonUtility.ToJson(this.matchData); } }
private void Start() { gameOverUI.SetActive(false); dealerHand = new PlayerData(CardPrefab, DealerMatt, dealerScoreUI); playerHand = new PlayerData(CardPrefab, PlayerMatt, playerScoreUI); MasterDeck.InitialDeal(playerHand, dealerHand); }
public void Awake() { if (deck == null) { deck = MasterDeck.GetRandomDeck(); } MasterDeck.Reset(); }
/// <summary> /// Resets the Master Deck to have all of the possible Cards again /// </summary> public static void Reset() { lock (padLock) { instance = new MasterDeck(); instance.Shuffle(); } }
public void DrawCardClick() { MasterDeck.DrawCard(playerHand, true, 1); if (playerHand.HandValues[1] == 21 || playerHand.HandValues[0] == 21) { StandClick(); } else if (playerHand.HandValues[0] > 21) { StartCoroutine(GameOverText(0)); } }
public void ResetGame() { //wipe existing data MasterDeck.ResetMasterDeck(); playerHand.ResetPlayerData(); dealerHand.ResetPlayerData(); gameOverUI.SetActive(false); //set up new game MasterDeck.InitialDeal(playerHand, dealerHand); //enable buttons hitButton.interactable = true; standButton.interactable = true; }
private void Start() { DelegateCreation(); gameOverUI.SetActive(false); quitPromptUI.SetActive(false); dealerHand = new PlayerData(CardPrefab, DealerMatt, dealerScoreUI); playerHand = new PlayerData(CardPrefab, PlayerMatt, playerScoreUI); MasterDeck.InitialDeal(playerHand, dealerHand); if (playerHand.HandValues[1] == 21 || playerHand.HandValues[0] == 21) { StandClick(); } }
private static MasterDeck GetInstance() { if (instance == null) { lock (padLock) { if (instance == null) { instance = new MasterDeck(); instance.Shuffle(); } } } return(instance); }
/// <summary> /// Gets a random deck of cards from the master Deck. This will also remove /// those cards from the master deck. There is also a possibility that the /// master deck will run out of cards. In this case, this function will only /// return the remaining cards in the deck. This function also goes ahead and /// shuffles the cards before they are returned. /// </summary> /// <param name="size">The size of the deck to create. Defaults to 10.</param> /// <returns>A new Deck of cards.</returns> public static Deck GetRandomDeck(int size = 10) { lock (padLock) { MasterDeck master = MasterDeck.GetInstance(); Deck newDeck = new Deck(); while (newDeck.Size() < size && master.Size() > 0) { newDeck.AddCard(master.DrawCard()); } newDeck.Shuffle(); return(newDeck); } }
public IEnumerator DealerDraw() { //checks if dealer has blackjack if (dealerHand.HandValues[1] == 21) { CheckScore(playerHand.HandValues, dealerHand.HandValues); } else { while (dealerHand.HandValues[0] <= 17 && !(dealerHand.HandValues[1] > 17 && dealerHand.HandValues[1] < 21)) { MasterDeck.DrawCard(dealerHand, false, 1); while (AnimPlaying) { yield return(null); } } } CheckScore(playerHand.HandValues, dealerHand.HandValues); }
void Start() { Debug.Log(debugTag + "Initializing..."); // [Client/Server] if (!hasAuthority) { this.config = JsonUtility.FromJson <MatchConfig>(matchDataBroadcaster.MatchConfigStr); Debug.Log(debugTag + "Grabbed config for client: " + matchDataBroadcaster.MatchConfigStr); Debug.Log(debugTag + "Creating Decks..."); masterDeck = new MasterDeck(config.DeckFlavor); masterDeckMutable = new MasterDeck(config.DeckFlavor); return; } // [Server] InitializeMatch(); }
// FUTURE IDEA: When the clients parse the string above, have them increment this number by one. // When this string is set by GameManager, reset this number to 0. // While the clients check for parsing, have them check this number to make sure it's not // equal to the number of players, implying a stale string. // [SyncVar] // public int purchasedTileInfoReceived = 0; // private static List<GameObject> playerMoneyObj = new List<GameObject>(); // private static List<TMP_Text> playerMoneyText = new List<TMP_Text>(); // Used for initialization void Start() { if (!hasAuthority) { return; } Debug.Log(debug + "Initializing GameManager..."); Debug.Log(debug + "Creating Master Deck \"Vanilla\""); masterDeck = new MasterDeck("Vanilla"); masterDeckMutable = new MasterDeck("Vanilla"); Debug.Log(debug + "Initializing Players..."); InitPlayers(); // Initialize the internal grids gridMan.InitGameGrid(); gridMan.InitMarketGrid(); // FINAL ############################################################### // Make sure that there is at least 1 Grace Round if (graceRounds < 1) { graceRounds = 1; } // if (graceRounds < 1) // GameObject cameraObj = transform.Find("Main Camera").gameObject; // mainCam = cameraObj.GetComponent<Camera>(); // Push the first UI Update // guiMan.InitGuiManager(); // guiMan.UpdateUI(); Debug.Log(debug + "#################### Turn " + this.turn + " | Round " + this.round + " | Phase " + this.phase + " ####################"); } // Start()
public void RefreshDeck(string type) { switch (type) { case "LandTile": MasterDeck tempDeck = new MasterDeck(config.DeckFlavor); masterDeckMutable.landTileDeck = tempDeck.landTileDeck; break; case "CoastTile": // MasterDeck tempDeck = new MasterDeck(config.DeckFlavor); // masterDeckMutable.coastTileDeck = masterDeck.coastTileDeck; break; case "GameCard": // MasterDeck tempDeck = new MasterDeck(config.DeckFlavor); masterDeckMutable.gameCardDeck = masterDeck.gameCardDeck; break; default: break; } }