Beispiel #1
0
    //ドラ表示牌を表示
    private void ShowBonusCards()
    {
        GameManagerScript.DestroyGameObjects(ref bonusObjects); //表示しているドラ表示牌のゲームオブジェクトを削除

        int[] cards = GetBonusCards();                          //ドラ表示牌を取得

        for (int i = 0; i < cards.Length / 2; i++)
        {
            GameObject cardObject = new GameObject();
            Sprite     sprite;
            if (i <= showBonusIndex)
            {
                sprite =
                    CardImages.Image_Front(cards[i]);    //表向きの牌画像
            }
            else
            {
                sprite = CardImages.Image_Back();                       //裏向きの牌画像
            }
            cardObject.AddComponent <SpriteRenderer>().sprite = sprite; //牌画像を格納
            cardObject.transform.localScale = Layouts.bonusScale;       //大きさを決定
            cardObject.transform.position   = Layouts.bonusOffset + Layouts.bonusLineupDirection * i;
            cardObject.transform.rotation   =
                Quaternion.Euler(Layouts.bonusRotation); //角度を決定

            bonusObjects.Add(cardObject);                //メモリ解放用のリストに格納
        }
    }
Beispiel #2
0
    //プレイヤー1名分の手牌を表示(基底関数)
    private void ShowHand_Only(int player, bool show)
    {
        GameManagerScript.DestroyGameObjects(ref handObjects[player]);    //表示している手牌のゲームオブジェクトを削除
        for (int i = 0; i < hands[player].Count; i++)
        {
            GameObject card = new GameObject();
            Sprite     sprite;
            int        handCard = hands[player][i];
            if (show)
            {
                sprite =
                    CardImages.Image_Front(handCard);    //表向きの牌画像
            }
            else
            {
                sprite = CardImages.Image_Back();    //裏向きの牌画像
            }

            card.AddComponent <SpriteRenderer>().sprite = sprite;       //牌画像を格納
            card.transform.localScale = Layouts.handScales[player];     //大きさを決定
            card.transform.position   = Layouts.handOffsets[player] + Layouts.handLineupDirections[player] * i;
            card.transform.rotation   =
                Quaternion.Euler(Layouts.handRotations[player]);    //角度を決定

            if (player == 0 && UserActions.Playing())
            {
                card.AddComponent <BoxCollider2D>();

                int index = i;
                for (int j = 0; j < UserActions.handIndexes_forCall.Length; j++)
                {
                    if (index == UserActions.handIndexes_forCall[j])
                    {
                        Color color = card.GetComponent <SpriteRenderer>().color;
                        color.a = 0.5f;
                        card.GetComponent <SpriteRenderer>().color = color;
                    }
                }

                EventTrigger.Entry down = new EventTrigger.Entry();
                down.eventID = EventTriggerType.PointerDown;
                down.callback.AddListener((f) => UserActions.MouseDown(handCard, index, this));
                card.AddComponent <EventTrigger>().triggers.Add(down);

                EventTrigger.Entry drag = new EventTrigger.Entry();
                drag.eventID = EventTriggerType.PointerEnter;
                drag.callback.AddListener((f) => UserActions.MouseMove(index, this, ref hands[0]));
                card.GetComponent <EventTrigger>().triggers.Add(drag);

                EventTrigger.Entry click = new EventTrigger.Entry();
                click.eventID = EventTriggerType.PointerClick;
                click.callback.AddListener((f) => UserActions.MouseClick(index, this));
                card.GetComponent <EventTrigger>().triggers.Add(click);
            }

            handObjects[player].Add(card);      //メモリ解放用のリストに格納
        }
    }
Beispiel #3
0
    //鳴き牌表示
    private void ShowCallCard_Only(int player)
    {
        GameManagerScript.DestroyGameObjects(ref callObjects[player]);    //表示している手牌のゲームオブジェクトを削除

        Vector2 position =
            new Vector2(Layouts.callOffsets[player].x, Layouts.callOffsets[player].y);  //表示位置の初期地点

        for (int s = 0; s < calls[player].Count; s++)
        {
            for (int i = 0; i < calls[player][s].callCards.Count; i++)
            {
                CallCard   callCard = calls[player][s].callCards[i]; //牌の情報を取得
                GameObject card     = new GameObject();
                Sprite     sprite;
                if (callCard.closedKan_hide)
                {
                    sprite = CardImages.Image_Back();   //裏向き
                }
                else
                {
                    sprite = CardImages.Image_Front(callCard.cardId);   //表向き
                }
                card.AddComponent <SpriteRenderer>().sprite = sprite;   //画像を格納
                card.transform.localScale = Layouts.callScales[player]; //大きさを決定

                float   addDirection;                                   //回転した牌のための余白を用意するかどうかのフラグ
                Vector3 addRotation;                                    //回転した牌の場合に追加する回転量
                Vector2 addY = new Vector2(0f, 0f);                     //加カン牌用のずらしフラグ
                if (callCard.discardPlayer == player)
                {
                    //自分の鳴き牌の場合は回転はなし
                    addDirection = 0f;
                    addRotation  = new Vector3(0f, 0f, 0f);
                }
                else
                {
                    //他家の捨て牌の場合は回転させる
                    position    += Layouts.callLineupRotatedAddDirections[player]; //回転分の座標補正
                    addDirection = 1.0f;                                           //余白用意フラグを立てる
                    addRotation  = new Vector3(0f, 0f, 90f);                       //回転させる
                    addY         = Layouts.callLineupRotatedAddYPositions[player]; //高さ補正
                }
                if (callCard.addKan)
                {
                    //加カン牌の場合は基本位置xを戻す。yはずらすフラグを立てる
                    position -=
                        Layouts.callLineupDirections[player] +
                        Layouts.callLineupRotatedAddDirections[player];
                    addY =
                        Layouts.callLineupRotatedAddYPositions[player] +
                        Layouts.callLineupAddDoubleYPositions[player];

                    addDirection = 1.0f;                     //余白用意フラグを立てる
                    addRotation  = new Vector3(0f, 0f, 90f); //回転させる
                }
                card.transform.position = position + addY;   //牌の表示位置を決定
                //回転の有無を考慮して次の牌の基本位置を決定
                position +=
                    Layouts.callLineupDirections[player] +
                    Layouts.callLineupRotatedAddDirections[player] * addDirection;
                card.transform.rotation =
                    Quaternion.Euler(Layouts.callRotations[player] + addRotation); //牌の角度を決定

                callObjects[player].Add(card);                                     //メモリ解放用のリストに格納
            }
        }
    }