// Start is called before the first frame update void Start() { cartilha = FindObjectOfType <Cartilha>(); List <string> deck = Cartilha.generateDeck(); //Identify which sprite is the card by the card's name int i = 0; foreach (string card in deck) { if (this.name == card) { //for multiplayer if (cartilha == null) { MatchManager matchManager = FindObjectOfType <MatchManager>(); cardFace = matchManager.cardFaces[i]; } else { cardFace = cartilha.cardFaces[i]; break; } } i++; } //if you're assigned to a player or the board, your face is up. if not, it should remain down. if (transform.parent.name == "Player" || transform.parent.name == "Board") { spriteRenderer = GetComponent <SpriteRenderer>(); spriteRenderer.sprite = cardFace; } //for multiplayer if (cartilha == null) { spriteRenderer = GetComponent <SpriteRenderer>(); spriteRenderer.sprite = cardFace; if (transform.parent.GetComponent <Player>().hasAuthority) { spriteRenderer.sprite = cardFace; } else { spriteRenderer.sprite = cardBack; } } }
//[Server] public static void dealCards(GameObject[] playerList, int numberOfCards) { List <string> deck = Cartilha.generateDeck(); int numberOfCardsStillInTheDeck = deck.Count; System.Random random = new System.Random(); MatchManager matchManager = FindObjectOfType <MatchManager>(); foreach (GameObject p in playerList) { List <string> hands = new List <string>(); for (int i = 0; i < numberOfCards; i++) { int k = random.Next(numberOfCardsStillInTheDeck); string newCard = deck[k]; hands.Add(newCard); deck.RemoveAt(k); numberOfCardsStillInTheDeck--; } matchManager.playerHands.Add(hands); } }
// Start is called before the first frame update void Start() { cartilha = FindObjectOfType <Cartilha>(); }
// Start is called before the first frame update void Start() { cartilha = FindObjectOfType <Cartilha>(); realNames = cartilha.realNames; DontDestroyOnLoad(this.gameObject); }