コード例 #1
0
    void distribute()
    {
        //player0のoriginalsを表示
        int cardCount = 0;

        foreach (int i in hands.Gethand0())
        {
            GameObject     cardCopy       = Instantiate(cardPrefab);
            CardModel      cardModel      = cardCopy.GetComponent <CardModel>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            Vector3        temp;
            float          co = cardOffset * cardCount;

            temp = start0 + new Vector3(co, 0f);
            cardModel.backIndex = hands.GetBack(i);
            cardModel.cardIndex = i;

            sources.Add(cardCopy);

            cardCopy.transform.position = temp;
            cardModel.ToggleFace(true);

            spriteRenderer.sortingOrder = cardCount;

            cardCount++;
        }
        //player3のoriginalsを表示
        cardCount = 0;
        foreach (int i in hands.Gethand3())
        {
            GameObject     cardCopy       = (GameObject)Instantiate(cardPrefab);
            CardModel      cardModel      = cardCopy.GetComponent <CardModel>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            Vector3        temp;
            float          co = cardOffset * cardCount;

            temp = start3 + new Vector3(0f, co);
            cardModel.backIndex = hands.GetBack(i);
            cardModel.cardIndex = i;

            sources.Add(cardCopy);

            cardCopy.transform.position = temp;
            cardCopy.transform.Rotate(new Vector3(0f, 0f, 90f));
            cardModel.ToggleFace(false);

            spriteRenderer.sortingOrder = cardCount;

            cardCount++;
        }
        //player2のoriginalsを表示
        cardCount = 0;
        foreach (int i in hands.Gethand2())
        {
            GameObject     cardCopy       = (GameObject)Instantiate(cardPrefab);
            CardModel      cardModel      = cardCopy.GetComponent <CardModel>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            Vector3        temp;
            float          co = cardOffset * cardCount;

            temp = start2 - new Vector3(co, 0f);
            cardModel.backIndex = hands.GetBack(i);
            cardModel.cardIndex = i;

            sources.Add(cardCopy);

            cardCopy.transform.position = temp;
            cardCopy.transform.Rotate(new Vector3(0f, 0f, 180f));
            cardModel.ToggleFace(false);

            spriteRenderer.sortingOrder = cardCount;

            cardCount++;
        }
        //player1のoriginalを表示
        cardCount = 0;
        foreach (int i in hands.Gethand1())
        {
            GameObject     cardCopy       = (GameObject)Instantiate(cardPrefab);
            CardModel      cardModel      = cardCopy.GetComponent <CardModel>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            Vector3        temp;
            float          co = cardOffset * cardCount;

            temp = start1 - new Vector3(0f, co);
            cardModel.backIndex = hands.GetBack(i);
            cardModel.cardIndex = i;

            sources.Add(cardCopy);

            cardCopy.transform.position = temp;
            cardCopy.transform.Rotate(new Vector3(0f, 0f, 270f));
            cardModel.ToggleFace(false);

            spriteRenderer.sortingOrder = cardCount;

            cardCount++;
        }

        //player0のdrawnsを表示
        cardCount = 0;
        foreach (int i in hands.drawns[0])
        {
            GameObject     cardCopy       = Instantiate(cardPrefab);
            CardModel      cardModel      = cardCopy.GetComponent <CardModel>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            Vector3        temp;
            float          co = cardOffset * cardCount;

            temp = d_start0 + new Vector3(co, 0f) * 1.7f;
            cardModel.backIndex = hands.GetBack(i);
            cardModel.cardIndex = i;

            sources.Add(cardCopy);

            cardCopy.transform.position = temp;
            cardModel.ToggleFace(true);

            spriteRenderer.sortingOrder = cardCount;

            cardCount++;
        }
        //player3のdrawnsを表示
        cardCount = 0;
        foreach (int i in hands.drawns[3])
        {
            GameObject     cardCopy       = (GameObject)Instantiate(cardPrefab);
            CardModel      cardModel      = cardCopy.GetComponent <CardModel>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            Vector3        temp;
            float          co = cardOffset * cardCount;

            temp = d_start3 + new Vector3(0f, co) * 1.7f;
            cardModel.backIndex = hands.GetBack(i);
            cardModel.cardIndex = i;

            sources.Add(cardCopy);

            cardCopy.transform.position = temp;
            cardCopy.transform.Rotate(new Vector3(0f, 0f, 90f));
            cardModel.ToggleFace(false);

            spriteRenderer.sortingOrder = cardCount;

            cardCount++;
        }
        //player2のdrawnsを表示
        cardCount = 0;
        foreach (int i in hands.drawns[2])
        {
            GameObject     cardCopy       = (GameObject)Instantiate(cardPrefab);
            CardModel      cardModel      = cardCopy.GetComponent <CardModel>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            Vector3        temp;
            float          co = cardOffset * cardCount;

            temp = d_start2 - new Vector3(co, 0f) * 1.7f;
            cardModel.backIndex = hands.GetBack(i);
            cardModel.cardIndex = i;

            sources.Add(cardCopy);

            cardCopy.transform.position = temp;
            cardCopy.transform.Rotate(new Vector3(0f, 0f, 180f));
            cardModel.ToggleFace(false);

            spriteRenderer.sortingOrder = cardCount;

            cardCount++;
        }
        //player1のdrawnsを表示
        cardCount = 0;
        foreach (int i in hands.drawns[1])
        {
            GameObject     cardCopy       = (GameObject)Instantiate(cardPrefab);
            CardModel      cardModel      = cardCopy.GetComponent <CardModel>();
            SpriteRenderer spriteRenderer = cardCopy.GetComponent <SpriteRenderer>();
            Vector3        temp;
            float          co = cardOffset * cardCount;

            temp = d_start1 - new Vector3(0f, co) * 1.7f;
            cardModel.backIndex = hands.GetBack(i);
            cardModel.cardIndex = i;

            sources.Add(cardCopy);

            cardCopy.transform.position = temp;
            cardCopy.transform.Rotate(new Vector3(0f, 0f, 270f));
            cardModel.ToggleFace(false);

            spriteRenderer.sortingOrder = cardCount;

            cardCount++;
        }
    }