Пример #1
0
    void CardList()
    {
        if (hands[0] == null)
        {
            hands[0] = new List <int>();
        }
        else
        {
            hands[0].Clear();
        }
        if (hands[1] == null)
        {
            hands[1] = new List <int>();
        }
        else
        {
            hands[1].Clear();
        }
        if (hands[2] == null)
        {
            hands[2] = new List <int>();
        }
        else
        {
            hands[2].Clear();
        }
        if (hands[3] == null)
        {
            hands[3] = new List <int>();
        }
        else
        {
            hands[3].Clear();
        }

        foreach (int l in deck.GetCards())
        {
            if (k >= 0 && k < 13)
            {
                hands[0].Add(l);
            }
            else if (k > 12 && k < 26)
            {
                hands[1].Add(l);
            }
            else if (k > 25 && k < 39)
            {
                hands[2].Add(l);
            }
            else
            {
                hands[3].Add(l);
            }
            k++;
        }
    }
Пример #2
0
    void DistributeCards()   //メソッド本体
    {
        int cardCount = 0;   //内部で使う値cardCountの宣言

        foreach (int i in deck.GetCards())
        {
            float      co = cardOffset * (cardCount / player); //オフセット幅の計算
            Vector3    temp;
            GameObject cardCopy  = (GameObject)Instantiate(cardPrefab);
            CardModel  cardModel = cardCopy.GetComponent <CardModel>();
            //Transform transform = cardCopy.GetComponent<Transform>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            switch (cardCount % player)
            {
            case 0:
                temp = start1 + new Vector3(co, 0f);
                //tempというオフセットした位置の計算
                cardCopy.transform.position = temp;
                //現在の位置にtempを代入
                cardCopy.transform.Rotate(new Vector3(0f, 0f, 90f));
                cardModel.cardIndex = i;
                cardModel.ToggleFace(true);

                spriteRenderer.sortingOrder = cardModel.faces.Length - cardCount;
                break;

            case 1:
                temp = start2 + new Vector3(0f, co);
                //tempというオフセットした位置の計算
                cardCopy.transform.position = temp;
                //現在の位置にtempを代入
                cardModel.cardIndex = i;
                cardModel.ToggleFace(true);

                spriteRenderer.sortingOrder = cardModel.faces.Length - cardCount;
                break;

            case 2:
                temp = start3 - new Vector3(co, 0f);
                //tempというオフセットした位置の計算
                cardCopy.transform.position = temp;
                //現在の位置にtempを代入
                cardCopy.transform.Rotate(new Vector3(0f, 0f, 270f));
                cardModel.cardIndex = i;
                cardModel.ToggleFace(true);

                spriteRenderer.sortingOrder = cardModel.faces.Length - cardCount;
                break;

            case 3:
                temp = start4 - new Vector3(0f, co);
                //tempというオフセットした位置の計算
                cardCopy.transform.position = temp;
                //現在の位置にtempを代入
                cardModel.cardIndex = i;
                cardModel.ToggleFace(true);

                spriteRenderer.sortingOrder = cardModel.faces.Length - cardCount;
                break;
            }



            cardCount++; //cardCountをインクリメント
        }
    }