Beispiel #1
0
    public void RenderCards(IEnumerable <int> cardIDs, bool isOpponent)
    {
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }
        int cardCount = cardIDs.Count();
        int index     = 0;

        foreach (var cardID in cardIDs)
        {
            CardRecord card;
            if (isOpponent)
            {
                GameObject handCard = Instantiate(cardBackBlockPrefab, transform);
                handCard.GetComponent <RectTransform>().anchoredPosition = new Vector2(-130 * cardCount / 2 + index * 130, 0);
            }
            else if (GameInstance.Game.GameCardManager.FindCard(cardID, out card))
            {
                CardRecordBlock handCard = null;
                switch (card.Card.CardType)
                {
                case CardTypeCode.Servant:
                    handCard = Instantiate(servantCardRecordBlockPrefab, transform);
                    break;

                case CardTypeCode.Spell:
                    handCard = Instantiate(spellCardRecordBlockPrefab, transform);
                    break;

                case CardTypeCode.Weapon:
                    handCard = Instantiate(weaponCardRecordBlockPrefab, transform);
                    break;
                }
                handCard.SetCard(card, GameInstance.SelfGamePlayer.GamePlayerID);
                handCard.GetComponent <RectTransform>().anchoredPosition = new Vector2(-130 * cardCount / 2 + index * 130, 0);
            }
            index++;
        }
    }
Beispiel #2
0
    public void RenderHand(GamePlayer gamePlayer, bool isOpponent)
    {
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }
        int handCardCount = gamePlayer.HandCardIDs.Count();
        int index         = 0;

        foreach (var cardRecordID in gamePlayer.HandCardIDs)
        {
            CardRecord card;
            if (isOpponent)
            {
                GameObject handCard = Instantiate(emptyHandCardBlockPrefab, transform);
                handCard.GetComponent <RectTransform>().anchoredPosition = new Vector2(-95 * handCardCount / 2 + index * 95, 10);
            }
            else if (GameInstance.Game.GameCardManager.FindCard(cardRecordID, out card))
            {
                CardRecordBlock handCard = null;
                switch (card.Card.CardType)
                {
                case CardTypeCode.Servant:
                    handCard = Instantiate(handServantCardRecordBlockPrefab, transform);
                    break;

                case CardTypeCode.Spell:
                    handCard = Instantiate(handSpellCardRecordBlockPrefab, transform);
                    break;

                case CardTypeCode.Weapon:
                    handCard = Instantiate(handWeaponCardRecordBlockPrefab, transform);
                    break;
                }
                handCard.SetCard(card, gamePlayer.GamePlayerID);
                handCard.GetComponent <RectTransform>().anchoredPosition = new Vector2(-95 * handCardCount / 2 + index * 95, 10);
            }
            index++;
        }
    }