Пример #1
0
    public GameObject IDtoGameobeject(int ID) //輸入ID就可以抓到卡牌
    {
        int[]        cardIDmanager = CardIDManager(ID);
        Color        color         = cardColor[cardIDmanager[0]];
        CardFunction cardfunction  = cardFunctions[cardIDmanager[1]];
        int          repeatTimes   = cardIDmanager[2];
        string       CardName      = "Card_" + color.ToString() + " " + cardfunction.ToString() + " " + repeatTimes.ToString();
        GameObject   TheCard       = GameObject.Find(CardName);

        return(TheCard);
    }
Пример #2
0
    void AddNewCard(Color color, CardFunction cardfunction, int ID, int repeatTimes) //新增一張牌
    {
        GameObject card = Instantiate(Resources.Load <GameObject>("Prefabs/TheCard"));

        card.GetComponent <Card>().color        = color;
        card.GetComponent <Card>().CardFunction = cardfunction;
        card.GetComponent <Card>().ID           = ID;
        card.name = "Card_" + color.ToString() + " " + cardfunction.ToString() + " " + repeatTimes.ToString();
        card.GetComponent <Card>().cardState = CardState.InDeck;

        GameObject graphic = Instantiate(Resources.Load <GameObject>("Prefabs/Pattern"));

        graphic.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("graphic/" + color.ToString() + cardfunction.ToString());
        graphic.transform.SetParent(card.transform);
        graphic.transform.localPosition = new Vector3(0, 0, -0.1f);
        graphic.transform.eulerAngles   = new Vector3(0, 180, 0);
    }