Exemplo n.º 1
0
    }                 // CreateMarketGridObjects()

    // Creates card game objects, places them on the screen, and populates them with deck data
    public void CreateHandObjects(int playerNum, SyncListCardData hand)
    {
        // if (!isLocalPlayer) {
        //  Debug.Log("[GridManager] A non-local player tried to spawn hand objects!");
        //  return;
        // }

        // Debug.Log(debug + "Spawning Cards for ID " + playerNum);
        // Debug.Log(debug + "Hand size of: " + hand.Count);

        // Populate the Card prefab

        // Creates card prefabs and places them on the screen
        for (int i = 0; i < hand.Count; i++)
        {
            float xOff = i * 11 + (((GameManager.width - GameManager.handSize) / 2f) * 11);
            float yOff = -10;

            GameObject cardObj = (GameObject)Instantiate(gameCardPrefab,
                                                         new Vector3(xOff, yOff, 40),
                                                         Quaternion.identity);

            // Debug.Log("[GridManager] Spawning Card...");
            // NetworkServer.Spawn(cardObj);

            // Debug.Log("[GridManager] Trying to fill out Hand Card info...");
            CardState cardState = cardObj.GetComponent <CardState>();

            if (cardState != null)
            {
                // Generate and Push the string of the object's name
                cardState.objectName = (GameManager.CreateCardObjectName("GameCard", playerNum, i));
                // Push new values to the CardState to be synchronized across the network
                FillOutCardState(hand[i], ref cardState);
            }
            else
            {
                Debug.Log(debug + "This object's card state was null!");
            } // if (cardState != null)
        }     // for
    }         // CreateHandObjects()