Exemple #1
0
    public void Generate(EntityExt entity)
    {
        var front   = transform.Find("Front");
        var artMask = front.Find("ArtMask");

        artMask.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/hero_mask");

        var art = artMask.Find("Art");

        if (TexturesUtil.GetArtFromResource(entity.CardId, out Texture2D artTexture))
        {
            art.GetComponent <Image>().sprite = Sprite.Create(artTexture, new Rect(0, 0, artTexture.width, artTexture.height), new Vector2(0, 0));
        }
        else
        {
            StartCoroutine(TexturesUtil.GetTexture(entity.CardId, art));
        }

        UpdateEntity(entity);
    }
Exemple #2
0
    internal void ShowEntity(EntityExt entity)
    {
        CardType  cardType  = (CardType)entity.Tags[GameTag.CARDTYPE];
        CardClass cardClass = entity.Tags.ContainsKey(GameTag.CLASS) ? (CardClass)entity.Tags[GameTag.CLASS] : CardClass.NEUTRAL;

        var front = transform.Find("Front");

        var artMask = front.Find("ArtMask");

        artMask.GetComponent <Image>().sprite = GetArtMaskSpirite(cardType);

        var art = artMask.Find("Art");

        if (TexturesUtil.GetArtFromResource(entity.CardId, out Texture2D artTexture))
        {
            art.GetComponent <Image>().sprite = Sprite.Create(artTexture, new Rect(0, 0, artTexture.width, artTexture.height), new Vector2(0, 0));
        }
        else
        {
            StartCoroutine(TexturesUtil.GetTexture(entity.CardId, art));
        }

        var legendary = front.Find("Legendary");
        var frame     = front.Find("Frame");

        frame.GetComponent <Image>().sprite = GetFrameSprite(cardType, cardClass);
        legendary.gameObject.SetActive((Rarity)entity.Tags[GameTag.RARITY] == Rarity.LEGENDARY);
        legendary.GetComponent <Image>().sprite = GetLegendarySprite(cardType);

        var name = frame.Find("Name");

        name.GetComponent <TextMeshProUGUI>().text = entity.Name;

        var description = frame.Find("Description");

        description.GetComponent <TextMeshProUGUI>().text = entity.Description;

        var mana   = frame.Find("Mana");
        var attack = frame.Find("Attack");
        var health = frame.Find("Health");

        switch (cardType)
        {
        case CardType.INVALID:
            break;

        case CardType.GAME:
            break;

        case CardType.PLAYER:
            break;

        case CardType.HERO:
            health.GetComponent <TextMeshProUGUI>().text = entity.Tags[GameTag.HEALTH].ToString();
            attack.GetComponent <TextMeshProUGUI>().text = entity.Tags[GameTag.ATK].ToString();
            break;

        case CardType.MINION:
            mana.GetComponent <TextMeshProUGUI>().text   = entity.Tags[GameTag.COST].ToString();
            health.GetComponent <TextMeshProUGUI>().text = entity.Tags[GameTag.HEALTH].ToString();
            attack.GetComponent <TextMeshProUGUI>().text = entity.Tags[GameTag.ATK].ToString();
            break;

        case CardType.SPELL:
            mana.GetComponent <TextMeshProUGUI>().text = entity.Tags[GameTag.COST].ToString();
            health.gameObject.SetActive(false);
            attack.gameObject.SetActive(false);
            break;

        case CardType.ENCHANTMENT:
            break;

        case CardType.WEAPON:
            mana.GetComponent <TextMeshProUGUI>().text         = entity.Tags[GameTag.COST].ToString();
            health.GetComponent <TextMeshProUGUI>().text       = entity.Tags[GameTag.DURABILITY].ToString();
            attack.GetComponent <TextMeshProUGUI>().text       = entity.Tags[GameTag.ATK].ToString();
            description.GetComponent <TextMeshProUGUI>().color = Color.white;
            break;

        case CardType.ITEM:
            break;

        case CardType.TOKEN:
            break;

        case CardType.HERO_POWER:
            break;
        }

        // set to visible
        Show(true);
    }