コード例 #1
0
    public void Reshuffle()
    {
        list = RX_CardManager.DefaultManager.Reshuffle();

        #region Clear the existing cards on the screen
        List <UISprite> clearBottom = new List <UISprite>(bottom_pool.GetComponentsInChildren <UISprite>());
        List <UISprite> clearLeft   = new List <UISprite>(left_pool.GetComponentsInChildren <UISprite>());
        List <UISprite> clearAll    = new List <UISprite>(right_pool.GetComponentsInChildren <UISprite>());
        clearAll.AddRange(clearBottom);
        clearAll.AddRange(clearLeft);
        clearAll.RemoveAll((UISprite obj) => { return(obj.tag == "cbottom" ||
                                                      obj.tag == "cleft" || obj.tag == "cright"); });
        for (int i = 0; i < clearAll.Count; i++)
        {
            Destroy(clearAll[i].gameObject);
        }
        #endregion

        bottom_seat           = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_BOTTOM, this.bottom_pool);
        bottom_seat.Card_list = list.GetRange(0, 17);
        RX_CardManager.ClearPool();
        left_seat           = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_LEFT, this.left_pool);
        left_seat.Card_list = list.GetRange(17, 17);
        RX_CardManager.ClearPool();
        right_seat           = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_RIGHT, this.right_pool);
        right_seat.Card_list = list.GetRange(34, 17);
        RX_CardManager.ClearPool();

        foreach (KeyValuePair <RX_SEAT_POSITION, List <UISprite> > item in RX_CardManager.HandedSprites)
        {
            for (int i = 0; i < item.Value.Count; i++)
            {
                Destroy(item.Value[i]);
            }
        }

        prevCardSet = null;
    }
コード例 #2
0
    void InitReshuffleRPC(string pokerInfos)
    {
        #region Clear the existing cards on the screen
        List <UISprite> clearBottom = new List <UISprite>(bottom_pool.GetComponentsInChildren <UISprite>());
        List <UISprite> clearLeft   = new List <UISprite>(left_pool.GetComponentsInChildren <UISprite>());
        List <UISprite> clearAll    = new List <UISprite>(right_pool.GetComponentsInChildren <UISprite>());
        clearAll.AddRange(clearBottom);
        clearAll.AddRange(clearLeft);
        clearAll.RemoveAll((UISprite obj) =>
        {
            return(obj.tag == "cbottom" ||
                   obj.tag == "cleft" || obj.tag == "cright");
        });
        for (int i = 0; i < clearAll.Count; i++)
        {
            Destroy(clearAll[i].gameObject);
        }
        #endregion

        string[] pairs = pokerInfos.Split('|');

        //convert pokerInfo to cardList
        int[] cardsdInfo = new int[54];
        for (int i = 0; i < 54; i++)
        {
            cardsdInfo[i] = int.Parse(pairs[i].Split(':')[1]);
        }
        list = CreateCardList(cardsdInfo);

        //if current player is the 2nd player...
        if (pairs[17].Split(':')[0] == RX_UserManager.DefaultUser.user_name)
        {
            //generate cardInfo array,(killed userName)  -- me bottom
            labelBottom.text             = (pairs[17].Split(':')[0]);
            bottom_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_BOTTOM, this.bottom_pool);
            bottom_seat.Card_list        = list.GetRange(17, 17);
            bottom_seat.Seat_user        = pairs[17].Split(':')[0];
            bottom_seat.Handed_container = handed_bootom;
            RX_CardManager.ClearPool();

            //server -- right
            labelRight.text             = (pairs[0].Split(':')[0]);
            right_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_RIGHT, this.right_pool);
            right_seat.Card_list        = list.GetRange(0, 17);
            right_seat.Seat_user        = pairs[0].Split(':')[0];
            right_seat.Handed_container = handed_right;
            RX_CardManager.ClearPool();

            //3rd -- left
            labelLeft.text             = (pairs[34].Split(':')[0]);
            left_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_LEFT, this.left_pool);
            left_seat.Card_list        = list.GetRange(34, 17);
            left_seat.Seat_user        = pairs[34].Split(':')[0];
            left_seat.Handed_container = handed_left;
            RX_CardManager.ClearPool();

            //set diZhu....
            InitGame(right_seat);
        }

        //if current player is the 3nd player...
        if (pairs[34].Split(':')[0] == RX_UserManager.DefaultUser.user_name)
        {
            //generate cardInfo array,(killed userName)  -- me bottom
            labelBottom.text             = (pairs[34].Split(':')[0]);
            bottom_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_BOTTOM, this.bottom_pool);
            bottom_seat.Card_list        = list.GetRange(34, 17);
            bottom_seat.Seat_user        = pairs[34].Split(':')[0];
            bottom_seat.Handed_container = handed_bootom;
            RX_CardManager.ClearPool();

            //server -- left
            labelLeft.text             = (pairs[0].Split(':')[0]);
            left_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_LEFT, this.left_pool);
            left_seat.Card_list        = list.GetRange(0, 17);
            left_seat.Seat_user        = pairs[0].Split(':')[0];
            left_seat.Handed_container = handed_left;
            RX_CardManager.ClearPool();

            //3rd -- right
            labelRight.text             = (pairs[17].Split(':')[0]);
            right_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_RIGHT, this.right_pool);
            right_seat.Card_list        = list.GetRange(17, 17);
            right_seat.Seat_user        = pairs[17].Split(':')[0];
            right_seat.Handed_container = handed_right;
            RX_CardManager.ClearPool();

            //set diZhu....
            InitGame(left_seat);
        }

        //if current player is the server player...
        if (pairs[0].Split(':')[0] == RX_UserManager.DefaultUser.user_name)
        {
            //generate cardInfo array,(killed userName)  -- me bottom
            labelBottom.text             = (pairs[0].Split(':')[0]);
            bottom_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_BOTTOM, this.bottom_pool);
            bottom_seat.Card_list        = list.GetRange(0, 17);
            bottom_seat.Seat_user        = pairs[0].Split(':')[0];
            bottom_seat.Handed_container = handed_bootom;
            RX_CardManager.ClearPool();

            //server -- left
            labelLeft.text             = (pairs[17].Split(':')[0]);
            left_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_LEFT, this.left_pool);
            left_seat.Card_list        = list.GetRange(17, 17);
            left_seat.Seat_user        = pairs[17].Split(':')[0];
            left_seat.Handed_container = handed_left;
            RX_CardManager.ClearPool();

            //3rd -- right
            labelRight.text             = (pairs[34].Split(':')[0]);
            right_seat                  = new RX_SeatInfo(RX_SEAT_POSITION.RX_SEAT_RIGHT, this.right_pool);
            right_seat.Card_list        = list.GetRange(34, 17);
            right_seat.Seat_user        = pairs[34].Split(':')[0];
            right_seat.Handed_container = handed_right;
            RX_CardManager.ClearPool();

            //set diZhu....
            InitGame(bottom_seat);
        }

        //clear handed cards
        foreach (KeyValuePair <RX_SEAT_POSITION, List <UISprite> > item in RX_CardManager.HandedSprites)
        {
            for (int i = 0; i < item.Value.Count; i++)
            {
                Destroy(item.Value[i]);
            }
        }
        //new prevCardSet
        prevCardSet = null;
    }