Esempio n. 1
0
    // 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);
        }
    }
Esempio n. 2
0
 private void Start()
 {
     gameOverUI.SetActive(false);
     dealerHand = new PlayerData(CardPrefab, DealerMatt, dealerScoreUI);
     playerHand = new PlayerData(CardPrefab, PlayerMatt, playerScoreUI);
     MasterDeck.InitialDeal(playerHand, dealerHand);
 }
Esempio n. 3
0
 public void Awake()
 {
     if (deck == null)
     {
         deck = MasterDeck.GetRandomDeck();
     }
     MasterDeck.Reset();
 }
Esempio n. 4
0
 /// <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();
     }
 }
Esempio n. 5
0
    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));
        }
    }
Esempio n. 6
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;
 }
Esempio n. 7
0
 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();
     }
 }
Esempio n. 8
0
 private static MasterDeck GetInstance()
 {
     if (instance == null)
     {
         lock (padLock)
         {
             if (instance == null)
             {
                 instance = new MasterDeck();
                 instance.Shuffle();
             }
         }
     }
     return(instance);
 }
Esempio n. 9
0
    /// <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);
        }
    }
Esempio n. 10
0
 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);
 }
Esempio n. 11
0
    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();
    }
Esempio n. 12
0
    // 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()
Esempio n. 13
0
    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;
        }
    }