/// <summary> /// 将GameInfo放到本地 /// </summary> /// <param name="data"></param> public void InitData(ISFSObject data) { #region 解析数据 string pCards; int pNum; int round; int state; ISFSArray otherUsers; int bank0; ISFSObject currentUser; int rate; int gtype; string roomName; int quan; int cardLenth; int id; string cargs; bool rejoin; int showRoomID; int totalRound; string rule; int ownerId; GameTools.TryGetValueWitheKey(data, out pCards, RequestKey.KeyPCards); GameTools.TryGetValueWitheKey(data, out pNum, RequestKey.KeyPlayerNum); GameTools.TryGetValueWitheKey(data, out round, RequestKey.KeyNowRound); GameTools.TryGetValueWitheKey(data, out state, RequestKey.KeyState); GameTools.TryGetValueWitheKey(data, out otherUsers, RequestKey.KeyUsers); GameTools.TryGetValueWitheKey(data, out bank0, RequestKey.KeyBanker0); GameTools.TryGetValueWitheKey(data, out currentUser, RequestKey.KeyUser); GameTools.TryGetValueWitheKey(data, out rate, RequestKey.KeyRate); GameTools.TryGetValueWitheKey(data, out gtype, RequestKey.KeyGameType); GameTools.TryGetValueWitheKey(data, out roomName, RequestKey.KeyRoomName); GameTools.TryGetValueWitheKey(data, out cardLenth, RequestKey.KeyCardLenth); GameTools.TryGetValueWitheKey(data, out id, RequestKey.KeyId); GameTools.TryGetValueWitheKey(data, out cargs, RequestKey.KeyCargs); GameTools.TryGetValueWitheKey(data, out rejoin, RequestKey.KeyRejoin); GameTools.TryGetValueWitheKey(data, out showRoomID, RequestKey.KeyShowRoomID); GameTools.TryGetValueWitheKey(data, out totalRound, RequestKey.KeyTotalRound); GameTools.TryGetValueWitheKey(data, out rule, RequestKey.KeyRule); GameTools.TryGetValueWitheKey(data, out ownerId, RequestKey.KeyOwnerId); #endregion #region 处理数据 PlayerNum = pNum; OwnerId = ownerId; int index = 0; _typeList.Clear(); //检查牌型 while (index < pCards.Length) { _typeList.Add(Convert.ToInt32(pCards.Substring(index, 2), 16)); index += 2; } SetGameEnv(cargs); if (data.ContainsKey(RequestKey.KeyQuan)) { IsQuanExist = true; GameTools.TryGetValueWitheKey(data, out quan, RequestKey.KeyQuan); CurrentGame.Quan = quan; } Bank0 = bank0; CurrentGame.RealRoomId = id; CurrentGame.GameRoomType = gtype; CurrentGame.ShowRoomId = showRoomID; CurrentGame.NowRound = round; CurrentGame.IsQuanExist = IsQuanExist; CurrentGame.Ante = 0; CurrentGame.Rate = rate; CurrentGame.RoomName = roomName; CurrentGame.TotalRound = totalRound; GetGameInfoShow(); FengGangHelper.Instance.InitFengDic(_luanfeng); if (string.IsNullOrEmpty(rule)) { CurrentGame.Rules = SaveInfo; } else { CurrentGame.Rules = rule; } TotalNum = cardLenth; GameTotalStatus = (TotalState)state; LeftNum = TotalNum; UserDatas = new List <ISFSObject>(); UserDatas.Add(currentUser); foreach (ISFSObject user in otherUsers) { UserDatas.Add(user); } if (gameObject.activeInHierarchy) { StartCoroutine(SureCreateRoomAction.WaitExcuteCalls()); } #endregion }
/// <summary> /// 将GameInfo放到本地 /// </summary> /// <param name="data"></param> public void InitData(ISFSObject data) { #region 解析数据 string pCards; int pNum; int round; int state; ISFSArray otherUsers; int bank0; ISFSObject currentUser; int rate; int gtype; int ante; string roomName; int quan; int cardLenth; int id; string cargs; bool rejoin; int showRoomID; int totalRound; GameTools.TryGetValueWitheKey(data, out pCards, RequestKey.KeyPCards); GameTools.TryGetValueWitheKey(data, out pNum, RequestKey.KeyPlayerNum); GameTools.TryGetValueWitheKey(data, out round, RequestKey.KeyNowRound); GameTools.TryGetValueWitheKey(data, out state, RequestKey.KeyState); GameTools.TryGetValueWitheKey(data, out otherUsers, RequestKey.KeyUsers); GameTools.TryGetValueWitheKey(data, out bank0, RequestKey.KeyBanker0); GameTools.TryGetValueWitheKey(data, out currentUser, RequestKey.KeyUser); GameTools.TryGetValueWitheKey(data, out rate, RequestKey.KeyRate); GameTools.TryGetValueWitheKey(data, out gtype, RequestKey.KeyGameType); GameTools.TryGetValueWitheKey(data, out roomName, RequestKey.KeyRoomName); GameTools.TryGetValueWitheKey(data, out cardLenth, RequestKey.KeyCardLenth); GameTools.TryGetValueWitheKey(data, out id, RequestKey.KeyId); GameTools.TryGetValueWitheKey(data, out cargs, RequestKey.KeyCargs); GameTools.TryGetValueWitheKey(data, out rejoin, RequestKey.KeyRejoin); GameTools.TryGetValueWitheKey(data, out showRoomID, RequestKey.KeyShowRoomID); GameTools.TryGetValueWitheKey(data, out totalRound, RequestKey.KeyTotalRound); GameTools.TryGetValueWitheKey(data, out CurrentGame.RuleInfo, RequestKey.KeyRule); GameTools.TryGetValueWitheKey(data, out CurrentGame.OwnerId, RequestKey.KeyOwnerId); YxDebug.LogError("当前局的起始庄座位号是:" + bank0); #endregion #region 处理数据 var index = 0; _typeList.Clear(); //检查牌型 while (index < pCards.Length) { _typeList.Add(Convert.ToInt32(pCards.Substring(index, 2), 16)); index += 2; } YxDebug.LogError(string.Format("当前游戏中的牌型有{0}种", _typeList.Count)); if (!(PlayerNum * _typeList.Count).Equals(cardLenth)) { YxDebug.LogError(string.Format("所有玩家总牌数为{0},玩家的牌数是{1}", _typeList.Count, cardLenth)); } SetGameEnv(cargs); if (data.ContainsKey(RequestKey.KeyQuan)) { IsQuanExist = true; GameTools.TryGetValueWitheKey(data, out quan, RequestKey.KeyQuan); CurrentGame.Quan = quan; } Bank0 = bank0; CurrentGame.RealRoomId = id; CurrentGame.GameRoomType = gtype; CurrentGame.ShowRoomId = showRoomID; CurrentGame.NowRound = round; CurrentGame.IsQuanExist = IsQuanExist; CurrentGame.Ante = 0; CurrentGame.Rate = rate; CurrentGame.TotalRound = totalRound; TotalNum = cardLenth; GameTotalStatus = (TotalState)state; LeftNum = TotalNum; UserDatas = new List <ISFSObject>(); UserDatas.Add(currentUser); foreach (ISFSObject user in otherUsers) { UserDatas.Add(user); } #endregion }
//public GameObject DisplayAfterText; void ReceiveData() { Debug.Log("Actually run"); int b1 = 0; int b2 = 0; int b3 = 0; while (Thread.CurrentThread.IsAlive) { LoopNum++; //Debug.Log("Running receive data"); byte[] data = Client.Receive(ref LocalEp); ArrayList parsed = ParseBin(data); //PrintAL(parsed); TotalState state = new TotalState(parsed); //Debug.Log(state.Describe()); UnityThread.executeInUpdate(() => { StateText.GetComponent <Text>().text = "Loop: " + LoopNum + "\n" + state.Describe(); SystemAdapter cmSA = CMSystemGameObject.GetComponent <SystemAdapter>(); cmSA.UpdateSystem(state.CMSystemState); SystemAdapter lasSA = LASSystemGameObject.GetComponent <SystemAdapter>(); lasSA.UpdateSystem(state.LASSystemState); SystemAdapter boosterSA = BoosterSystemGameObject.GetComponent <SystemAdapter>(); boosterSA.UpdateSystem(state.BoosterSystemState); //Debug.Log(state.EngineFlag); Debug.Log(state.EngineFlag); if (state.EngineFlag == 1 && particleBooster != null) { particleBooster.SetActive(true); } else if (particleBooster != null) { particleBooster.SetActive(false); } if (state.EngineFlag == 3 && particleCM != null) { particleCM.SetActive(true); } else if (particleCM != null) { particleCM.SetActive(false); } if (state.EngineFlag == 2 && particleLAS != null) { particleLAS.SetActive(true); } else if (particleLAS != null) { particleLAS.SetActive(false); } if (state.EngineFlag == 3 && b1 != 1) { //Do Steam b1 = 1; b3 = 1; if (displayEngine != null) { int timeBreak1 = (int)System.Math.Round(LoopNum * .025); displayEngine.GetComponent <Text>().text = "Break at " + timeBreak1 + "s"; } } if (state.EngineFlag == 0 && b2 != 1 && b3 == 1) { //Do fire b2 = 1; if (displayEngine2 != null) { int timeBreak2 = (int)System.Math.Round(LoopNum * .025); displayEngine2.GetComponent <Text>().text = "Break at " + timeBreak2 + "s"; } } //Debug.Log(cmSA);ngin }); } //Print both max values }