CardFlipper

mail@pastecode.io avatar
unknown
plain_text
3 years ago
999 B
2
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CardFlipper : MonoBehaviour
{
    public Sprite atkCardFront;
    public Sprite atkCardBack;
    public Sprite defCardFront;
    public Sprite defCardBack;

    public void defFlip()
    {
        Sprite currentSprite = gameObject.GetComponent<Image>().sprite;

        if (currentSprite == defCardFront)
        {
            gameObject.GetComponent<Image>().sprite = defCardBack;
        }
        else
        {
            gameObject.GetComponent<Image>().sprite = defCardFront;
        }
    }

    public void atkFlip()
    {
        Sprite currentSprite = gameObject.GetComponent<Image>().sprite;

        if (currentSprite == atkCardFront)
        {
            gameObject.GetComponent<Image>().sprite = atkCardBack;
        }
        else
        {
            gameObject.GetComponent<Image>().sprite = atkCardFront;
        }
    }

}