예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if ((Time.time - _currTime) >= 1)
        {
            if (_num > 0)
            {
                _num--;
                UpdateHUD(_num, 11);

                if (_num <= 5 && soundCount != null)
                {
                    gameObject.GetComponent <UISprite>().spriteName = "timerBgRed";
                    EginTools.PlayEffect(soundCount);
                    if (_num == 0 && timeUpCallback != null)
                    {
                        timeUpCallback();
                    }
                }
                else
                {
                    gameObject.GetComponent <UISprite>().spriteName = "timerBgGreen";
                }
            }
        }
    }
예제 #2
0
    /// <summary>
    /// 发牌(带动画效果,需要在编辑器里将扑克牌的Active设为false)
    /// </summary>
    /// <returns>The deal.</returns>
    /// <param name="toShow">If set to <c>true</c> to show.</param>
    /// <param name="infos">Infos.</param>
    public void SetDeal(bool toShow, List <JSONObject> infos)
    {
        if (!toShow)
        {
            cardsTrans.gameObject.SetActive(false);
        }
        else
        {
            //bosonA.SetActive(true);
            float x = parentX + 2 * _cardInterval;
            //cardsTrans.gameObject.SetActive(true);

            for (int i = 0; i < cardsArray.Length; i++)
            {
                if (null != soundSend)
                {
                    EginTools.PlayEffect(soundSend);
                }
                // cardsTrans.localPosition = new Vector3(x - _cardInterval / 2 * i, parentY, parentZ);
                //cardsArray[i].gameObject.SetActive(true);

                if (null != infos && infos.Count > 0)
                {
                    cardsArray[i].spriteName = _cardPre + infos[i].ToString();
                }
                //yield return new WaitForSeconds(.2f);
            }
        }
    }
예제 #3
0
 // Update is called once per frame
 void Update()
 {
     if ((Time.time - _currTime) >= 1)
     {
         if (_num > 0)
         {
             _num--;
             UpdateHUD(_num);
             if (isShakeStyle)
             {
                 transform.Find("timebackground").gameObject.GetComponent <UISprite>().alpha = 0;
                 spriteL.alpha = 0;
                 spriteR.alpha = 0;
             }
             if (_num <= 5 && soundCount != null)
             {
                 EginTools.PlayEffect(soundCount);
                 //NGUITools.PlaySound(soundCount);
                 if (isShakeStyle)
                 {
                     transform.Find("timebackground").gameObject.GetComponent <UISprite>().alpha = 1;
                     spriteL.alpha = 1;
                     spriteR.alpha = 1;
                     iTween.ShakeRotation(transform.Find("timebackground").gameObject, iTween.Hash("time", 0.8f, "z", 30.0f, "easetype", iTween.EaseType.linear));
                 }
             }
         }
     }
 }
예제 #4
0
    public void UserReady()
    {
        //向服务器发送消息(开始游戏)
        JSONObject startJson = new JSONObject();

        startJson.AddField("type", "tbtw");
        startJson.AddField("tag", "start");
        base.SendPackageWithJson(startJson);

        EginTools.PlayEffect(soundStart);

        btnBegin.SetActive(false);
    }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        if ((Time.time - _currTime) >= 1)
        {
            if (_num > 0)
            {
                _num--;
                UpdateHUD(_num);

                if (_num <= 5 && soundCount != null)
                {
//					NGUITools.PlaySound(soundCount);
                    EginTools.PlayEffect(soundCount);
                }
            }
        }
    }
예제 #6
0
    void ProcessOk(JSONObject messageObj)
    {
        JSONObject body = messageObj["body"];
        string     uid  = body["uid"].ToString();

        if (uid != EginUser.Instance.uid)
        {
            GameObject.Find(_nnPlayerName + uid).GetComponent <TBTWPlayerCtrl>().SetShow(true);
        }
        else
        {
            List <JSONObject> cards = body["cards"].list;
            int cardType            = (int)body["type"].n;
            userPlayerCtrl.SetCardTypeUser(cards, cardType);
        }

        EginTools.PlayEffect(soundTanover);
    }
예제 #7
0
    IEnumerator ProcessEnd(JSONObject messageObj)
    {
        //去掉下注额
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != userPlayerObj)
            {
                player.GetComponent <TBTWPlayerCtrl>().SetShow(false);
            }
        }

        if (msgWaitNext.activeSelf)
        {
            msgWaitNext.SetActive(false);
        }

        _playingPlayerList.Clear();


        JSONObject        body  = messageObj["body"];
        List <JSONObject> infos = body["infos"].list;

        //玩家扑克牌信息
        foreach (JSONObject info in infos)
        {
            List <JSONObject> jos   = info.list;
            string            uid   = jos[0].ToString();
            TBTWPlayerCtrl    ctrl  = GameObject.Find(_nnPlayerName + uid).GetComponent <TBTWPlayerCtrl>();
            List <JSONObject> cards = jos[1].list;
            //牌型
            int cardType = (int)jos[2].n;
            //得分
            int score = (int)jos[3].n;

            //明牌
            if (uid != EginUser.Instance.uid)
            {
                ctrl.SetCardTypeOther(cards, cardType);
            }
            else
            {
                if (btnShow.activeSelf)
                {
                    btnShow.SetActive(false);
                    ctrl.SetCardTypeUser(cards, cardType);
                }
                if (cardType == 10)
                {
                    EginTools.PlayEffect(soundNiuniu);
                }
                if (score > 0)
                {
                    EginTools.PlayEffect(soundWin);
                }
                else if (score < 0)
                {
                    EginTools.PlayEffect(soundFail);
                }
            }
            //更新bagmoney
            //			ctrl.UpdateIntoMoney(score);
            ctrl.SetScore(score);
        }


        //去掉所有等待中玩家的”等待中“, 显示开始换桌按钮
        foreach (GameObject player in _waitPlayerList)
        {
            if (player != userPlayerObj)
            {
                player.GetComponent <TBTWPlayerCtrl>().SetWait(false);
            }
        }
        _waitPlayerList.Clear();


        if (_late)
        {
            EginTools.PlayEffect(soundEnd);
            _late = false;
        }
        else
        {
            btnBegin.transform.localPosition = new Vector3(350, 0, 0);
        }

        if (SettingInfo.Instance.autoNext == true || SettingInfo.Instance.deposit == true)
        {
            yield return(new WaitForSeconds(2));

            UserReady();
        }
        else
        {
            btnBegin.SetActive(true);
        }

        int t = (int)body["t"].n;

        TBTWCount.Instance.UpdateHUD(t);

        _isPlaying = false;
    }
예제 #8
0
    /// <summary>
    /// Processes the deal.(带发牌动画)
    /// </summary>
    /// <returns>The deal.</returns>
    /// <param name="messageObj">Message object.</param>
    IEnumerator ProcessDeal(JSONObject messageObj)
    {
        //游戏已经开始
        _isPlaying = true;
        foreach (GameObject player in _readyPlayerList)
        {
            if (!_playingPlayerList.Contains(player))
            {
                Debug.Log(player.name);
                _playingPlayerList.Add(player);
            }
        }
        _readyPlayerList.Clear();

        StartCoroutine(TimeAnimation());
        //清除未被清除的牌
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null && player != userPlayerObj)
            {
                TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>();
                //StartCoroutine(ctrl.SetDeal(false, null));
                ctrl.SetDeal(false, null);
                ctrl.SetCardTypeOther(null, 0);
                ctrl.SetScore(-1);
            }
        }
        //去掉“准备”
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null)
            {
                player.GetComponent <TBTWPlayerCtrl>().SetReady(false);
            }
        }
        //去掉筹码显示
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null)
            {
                player.GetComponent <TBTWPlayerCtrl>().SetBet(0);
            }
        }
        EginTools.PlayEffect(soundXiazhu);

        JSONObject        body  = messageObj["body"];
        List <JSONObject> cards = body["cards"].list;
        int chip = (int)body["chip"].n;
        int t    = (int)body["t"].n;

        TBTWCount.Instance.UpdateHUD(t);
        //下注
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null)
            {
                TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>();

                ctrl.SetBet(chip);
                ctrl.SetUserChip(chip);
            }
        }

        //发牌
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null)
            {
                TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>();
                ctrl.SetBet(chip);
                ctrl.SetUserChip(chip);
                if (player == userPlayerObj)
                {
                    //StartCoroutine(ctrl.SetDeal(true, cards));
                    ctrl.SetDeal(true, cards);
                }
                else
                {
                    //StartCoroutine(ctrl.SetDeal(true, null));
                    ctrl.SetDeal(true, null);
                }
            }
        }

        yield return(new WaitForSeconds(2.5f));

        //非late进入时才显示摊牌按钮
        if (!_late)
        {
            if (SettingInfo.Instance.deposit == true)
            {
                yield return(new WaitForSeconds((_playingPlayerList.Count * 0.5f)));

                UserShow();
            }
        }
    }