void ProcessReady(JSONObject messageObj) { string uid = messageObj["body"].ToString(); GameObject player = GameObject.Find(_nnPlayerName + uid); TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>(); //去掉牌型显示 if (uid == EginUser.Instance.uid) { //StartCoroutine(ctrl.SetDeal(false, null)); ctrl.SetDeal(false, null); ctrl.SetCardTypeUser(null, 0); ctrl.SetScore(-1); } else { //如果主玩家已经重新开始,则清除当前用户的牌型显示 if (!btnBegin.activeSelf) { //StartCoroutine(ctrl.SetDeal(false, null)); ctrl.SetDeal(false, null); ctrl.SetCardTypeOther(null, 0); ctrl.SetScore(-1); } } //显示准备 ctrl.SetReady(true); _playingPlayerList.Add(player); }
void ProcessEnter(JSONObject messageObj) { JSONObject body = messageObj["body"]; List <JSONObject> memberinfos = body["memberinfos"].list; userPlayerCtrl = userPlayerObj.GetComponent <TBTWPlayerCtrl>(); foreach (JSONObject memberinfo in memberinfos) { if (memberinfo != null) { if (memberinfo["uid"].ToString() == EginUser.Instance.uid) { _userIndex = (int)(memberinfo["position"].n); bool waiting = (bool)memberinfo["waiting"].b; if (waiting) { _waitPlayerList.Add(userPlayerObj); } else { _playingPlayerList.Add(userPlayerObj); _reEnter = true; } int height = userPlayerObj.transform.root.GetComponent <UIRoot>().manualHeight; userCardScore.transform.localPosition = new Vector3(0, (-.07f * height - 52) - userPlayerObj.transform.localPosition.y, 0); userPlayerObj.name = _nnPlayerName + EginUser.Instance.uid; if (SettingInfo.Instance.autoNext == true || SettingInfo.Instance.deposit == true) { UserReady(); } break; } } } foreach (JSONObject memberinfo in memberinfos) { if (memberinfo != null) { if (memberinfo["uid"].ToString() != EginUser.Instance.uid) { AddPlayer(memberinfo, _userIndex); } } } JSONObject deskinfo = body["deskinfo"]; int t = (int)deskinfo["continue_timeout"].n; TBTWCount.Instance.UpdateHUD(t); }
GameObject AddPlayer(JSONObject memberinfo, int _userIndex) { string uid = memberinfo["uid"].ToString(); string bag_money = memberinfo["bag_money"].ToString(); string nickname = memberinfo["nickname"].str; int avatar_no = (int)(memberinfo["avatar_no"].n); int position = (int)(memberinfo["position"].n); bool ready = (bool)memberinfo["ready"].b; bool waiting = (bool)memberinfo["waiting"].b; string level = memberinfo["level"].ToString(); GameObject player = NGUITools.AddChild(this.gameObject, tbtwPlayerPrefab); player.name = _nnPlayerName + uid; //myplayer.Add(player); SetAnchorPosition(player, _userIndex, position); TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>(); ctrl.SetPlayerInfo(avatar_no, nickname, bag_money, level); if (waiting) { if (ready) { ctrl.SetReady(true); _readyPlayerList.Add(player); } _waitPlayerList.Add(player); } else { _playingPlayerList.Add(player); } return(player); }
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; }
/// <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(); } } }
IEnumerator ProcessLate(JSONObject messageObj) { if (!_reEnter) { _late = true; msgWaitNext.SetActive(true); } //(late进入时不显示开始按钮,显示等待) btnBegin.SetActive(false); JSONObject body = messageObj["body"]; int chip = (int)body["chip"].n; if (chip > 0) { List <JSONObject> infos = body["infos"].list; foreach (JSONObject info in infos) { string uid = info[0].ToString(); int waitting = (int)info[1].n; int show = (int)info[2].n; List <JSONObject> cards = info[3].list; int cardType = (int)info[4].n; GameObject player = GameObject.Find(_nnPlayerName + uid); if (player != null) { TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>(); if (waitting == 0) { //显示筹码 ctrl.SetBet(chip); if (player == userPlayerObj) { ctrl.SetLate(cards); if (show == 1) { ctrl.SetCardTypeUser(cards, cardType); } else { if (SettingInfo.Instance.deposit == true) { yield return(new WaitForSeconds(2.5f)); UserShow(); } //btnShow.SetActive(true); } } else { //显示正在游戏的玩家的牌 ctrl.SetLate(null); if (show == 1) { ctrl.SetShow(true); } } } else { ctrl.SetWait(true); } } } } int t = (int)body["t"].n; TBTWCount.Instance.UpdateHUD(t); }