예제 #1
0
        /// <summary>
        /// Creates the card, and populates the suit as well as the number with correct color
        /// </summary>
        public void Create(Card card)
        {
            // Makes sure the managers has been assigned
            if (_prefabManager == null)
            {
                _prefabManager = GameObject.FindGameObjectWithTag(Tags.PrefabManager).GetComponent <PrefabManager>();
            }

            if (_colorManager == null)
            {
                _colorManager = GameObject.FindGameObjectWithTag(Tags.ColorManager).GetComponent <ColorManager>();
            }

            this.PokerCard = card;

            var suit   = Instantiate(_prefabManager.GetCardSuitPrefab((CardSuitEnum)card.CardSuit), this.transform);
            var number = Instantiate(_prefabManager.GetCardNumberPrefab(card.CardNumber), this.transform);

            suit.transform.localPosition   = Vector3.zero;
            number.transform.localPosition = Vector3.zero;

            number.GetComponent <Image>().color = _colorManager.GetCardColorFromSuit((CardSuitEnum)card.CardSuit);
        }