示例#1
0
    void OnGUI()
    {
        GameStatus status = GameStatus.getInstance();

        if (status.nowStatus != 3)
        {
            return;
        }
        if (!CommonFunction.isMyTurn())
        {
            return;
        }
        if (!status.jkMark)
        {
            return;
        }

        int cx, cy;

        cx = Screen.width / 2;
        cy = Screen.height / 2;
        GUI.Box(new Rect(cx - 100, cy - 60, 200, 120), "조커 문양 설정");
        int        mx      = cx - 75;
        WWWRequest request = new WWWRequest();

        foreach (Mark mark in new Mark[] { Mark.S, Mark.D, Mark.H, Mark.C })
        {
            if (GUI.Button(new Rect(mx, cy - 30, 30, 30), mark.ToString()))
            {
                StartCoroutine(request.RequestThrow("Jk", mark.ToString()));
                status.jkMark = false;
            }
            mx += 40;
        }
        if (GUI.Button(new Rect(cx - 50, cy + 10, 100, 30), "설정안함"))
        {
            StartCoroutine(request.RequestThrow("Jk", "_"));
            status.jkMark = false;
        }
    }
示例#2
0
    void OnGUI()
    {
        GameStatus status = GameStatus.getInstance();

        if (status.nowStatus != 3)
        {
            return;
        }
        if (!CommonFunction.isMyTurn())
        {
            return;
        }
        if (!status.jcMark)
        {
            return;
        }

        int cx, cy;

        cx = Screen.width / 2;
        cy = Screen.height / 2;

        GUI.Box(new Rect(cx - 50, cy - 30, 100, 60), "조커콜?");
        WWWRequest request = new WWWRequest();

        if (GUI.Button(new Rect(cx - 30, cy, 20, 20), "Y"))
        {
            StartCoroutine(request.RequestJC(status.jcStr));
            status.jcMark = false;
        }
        if (GUI.Button(new Rect(cx + 10, cy, 20, 20), "N"))
        {
            StartCoroutine(request.RequestThrow(status.jcStr));
            status.jcMark = false;
        }
    }
示例#3
0
        public void draw(JsonData data)
        {
            Dictionary <GameObject, bool> used = new Dictionary <GameObject, bool>();

            foreach (GameObject card in deck.cardMap.Values)
            {
                used.Add(card, false);
            }

            int      back_count  = 0;
            JsonData game_status = data["game_status"];
            int      status      = (int)game_status["status"];

            if (status == 0)
            {
                return;
            }
            JsonData player = data["player"];

            JsonData hands       = player["hands"];
            int      OWN         = 0;
            int      count       = 0;
            string   selectedStr = "";

            for (int i = 0; i < hands.Count; i++)
            {
                string     strCard    = hands[i].ToString();
                GameObject cardObject = getCardObjectByString(strCard);
                used[cardObject] = true;
                if (changeCardColor(cardObject))
                {
                    if (count > 0)
                    {
                        selectedStr += ",";
                    }
                    selectedStr += strCard;
                    count++;
                }
                cardObject.transform.position = TablePosition.getCardPositionForHand(OWN, i, hands.Count);
                SpriteRenderer sr = cardObject.GetComponent <SpriteRenderer>();
                sr.sortingOrder = 100 + i;
            }
            if (GameStatus.getInstance().remain)
            {
                if (count == 3)
                {
                    WWWRequest request = new WWWRequest();
                    GameStatus.getInstance().remainFrom.StartCoroutine(request.RequestRemain(selectedStr));
                }
                GameStatus.getInstance().remain     = false;
                GameStatus.getInstance().remainFrom = null;
            }
            if (GameStatus.getInstance().card)
            {
                if (count == 1)
                {
                    WWWRequest request = new WWWRequest();
                    bool       isLead  = CommonFunction.isLead();
                    if (isLead && CommonFunction.isJC(selectedStr))
                    {
                        GameStatus.getInstance().jcStr  = selectedStr;
                        GameStatus.getInstance().jcMark = true;
                    }
                    else if (isLead && selectedStr == "Jk")
                    {
                        GameStatus.getInstance().jkMark = true;
                    }
                    else
                    {
                        GameStatus.getInstance().cardFrom.StartCoroutine(request.RequestThrow(selectedStr));
                    }
                }
                GameStatus.getInstance().card     = false;
                GameStatus.getInstance().cardFrom = null;
            }

            JsonData players      = game_status["players"];
            int      player_order = (int)player["order"];
            int      order        = player_order;

            for (int i = 0; i < 5; i++)
            {
                string   player_name = "player" + order.ToString();
                JsonData player_data = players[player_name];
                if (i != 0)
                {
                    int hand_count = (int)player_data["hands"];
                    for (int c = 0; c < hand_count; c++)
                    {
                        GameObject cardObject = deck.getDefaultCard(back_count++);
                        changeCardColor(cardObject, true);
                        cardObject.transform.position = TablePosition.getCardPositionForHand(i, c, hand_count);
                        SpriteRenderer sr = cardObject.GetComponent <SpriteRenderer>();
                        sr.sortingOrder = c;
                    }
                }
                JsonData point_card = player_data["point_card"];
                for (int c = 0; c < point_card.Count; c++)
                {
                    GameObject cardObject = getCardObjectByString(point_card[c].ToString());
                    used[cardObject] = true;
                    changeCardColor(cardObject, true);
                    cardObject.transform.position = TablePosition.getCardPositionForPointCard(i, c, point_card.Count);
                    SpriteRenderer sr = cardObject.GetComponent <SpriteRenderer>();
                    sr.sortingOrder = c;
                }
                order = (order + 1) % 5;
            }

            JsonData trick = game_status["trick"];

            for (int i = 0; i < trick.Count; i++)
            {
                int    trick_order = (int)trick[i]["order"];
                int    rela_order  = (trick_order - player_order + 5) % 5;
                string strCard     = trick[i]["card"].ToString();

                GameObject cardObject = getCardObjectByString(strCard);
                used[cardObject] = true;
                changeCardColor(cardObject, true);
                cardObject.transform.position = TablePosition.getThrowPosition(rela_order);
                SpriteRenderer sr = cardObject.GetComponent <SpriteRenderer>();
                sr.sortingOrder = i;
            }


            foreach (GameObject card in deck.cardMap.Values)
            {
                if (!used[card])
                {
                    card.transform.position = new Vector3(0, 0, -20);
                }
            }

            deck.decreaseDefaultCard(back_count);
        }