Beispiel #1
0
    private void PopulateCard(BaseCard card, Transform parent)
    {
        var col = card.color;

        col.a = 1f;
        parent.GetChild(0).GetComponent <Image>().sprite = card.sprite;
        parent.GetChild(1).GetComponent <Image>().color  = col;
        parent.GetChild(2).GetComponent <TMPro.TextMeshProUGUI>().text             = card.cardName;
        parent.GetChild(2).GetComponent <TMPro.TextMeshProUGUI>().color            = col;
        parent.GetChild(3).GetComponent <TMPro.TextMeshProUGUI>().text             = card.GetDescription();
        parent.GetChild(4).GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = card.cost.ToString();
    }
Beispiel #2
0
    public void Setup(BaseCard card, DeckManager manager)
    {
        this.card        = card;
        sprite.sprite    = card.sprite;
        description.text = card.GetDescription();
        energy.text      = card.cost.ToString();
        this.manager     = manager;
        var col = card.color;

        col.a          = 1f;
        border.color   = col;
        nameText.text  = card.cardName;
        nameText.color = col;

        cam                      = Camera.main;
        line1.enabled            = false;
        line2.enabled            = false;
        line2.startColor         = card.color;
        line2.endColor           = card.color;
        line1.transform.rotation = Quaternion.LookRotation(-transform.up, transform.forward);
        line2.transform.rotation = Quaternion.LookRotation(-transform.up, transform.forward);

        eventTrigger = GetComponent <EventTrigger>();
        var start = new EventTrigger.Entry();

        start.eventID = EventTriggerType.BeginDrag;
        start.callback.AddListener((d) => OnBeginDrag((PointerEventData)d));
        eventTrigger.triggers.Add(start);
        var drag = new EventTrigger.Entry();

        drag.eventID = EventTriggerType.Drag;
        drag.callback.AddListener((d) => OnDrag((PointerEventData)d));
        eventTrigger.triggers.Add(drag);
        var stop = new EventTrigger.Entry();

        stop.eventID = EventTriggerType.PointerUp;
        stop.callback.AddListener((d) => OnPointerUp((PointerEventData)d));
        eventTrigger.triggers.Add(stop);
    }