/// <summary> /// 初始化单元信息 /// </summary> /// <param name="itemInfo"></param> public void InitItem(HistoryItemInfo itemInfo) { InitTurn(itemInfo.RoundVal); InitTime(itemInfo.Time); //先将所有的玩家信息隐藏 foreach (Transform child in _usersParent) { child.gameObject.SetActive(false); } List <HistoryUserInfo> userInfoList = itemInfo.Users; int count = userInfoList.Count; int setCount = (count - 1) / 2; _line1.gameObject.SetActive(setCount > 0); int lens = _hLines.Length; for (int i = 0; i < lens; i++) { _hLines[i].SetActive(i < setCount); } _backGround.height = _backGroundheight[setCount]; for (int i = 0; i < count; i++) //不对应座位号 { Transform child = _usersParent.GetChild(i); child.GetComponent <HistoryUser>().InitUser(userInfoList[i]); } }
public void GetHistoryInfo(List <UserMatchInfo> matchInfos) { var gdata = App.GetGameData <SssGameData>(); HistoryItemInfo historyInfo = new HistoryItemInfo { Users = new List <HistoryUserInfo>(), RoundVal = gdata.CurRound, }; int bankerSeat = gdata.BankerSeat; foreach (UserMatchInfo info in matchInfos) { SssPlayer user = gdata.GetPlayer <SssPlayer>(info.Seat, true); if (user.Info == null) { continue; } HistoryUserInfo userInfo = new HistoryUserInfo { SssUserInfo = user.GetInfo <SssUserInfo>(), Seat = user.Info.Seat, Pokers = info.Cards.ToArray(), AddScore = info.AddScore.ToArray(), NormalScore = info.NormalScores.ToArray(), Score = info.TtScore, DunType = info.DunTypeList.ToArray(), Sprcial = info.Special, ShootInfo = info.Shoot, IsBanker = gdata.IsBankerModel && bankerSeat == user.Info.Seat }; historyInfo.Users.Add(userInfo); } SetGetShootTime(historyInfo.Users); HistoryList.Add(historyInfo); if (MaxCount == 0) //如果是0,则不限制个数 { return; } while (HistoryList.Count > MaxCount) { HistoryList.Remove(HistoryList[0]); } }
///// <summary> ///// 将数据加入到战绩中 ///// </summary> ///// <param name="data">传入的数据</param> //public void GetHistoryInfo(ISFSObject data) //{ // //解析人物牌信息 // ISFSArray dataArray = data.GetSFSArray("playerinfo"); // foreach (ISFSObject item in dataArray) // { // int seat = item.GetInt("seat"); // SssPlayer sssUser = main.UserSeatSort[main.ToLocalSeat(seat)]; // if (sssUser.CurSssUserInfo != null) // { // //存入玩家信息 // HistoryUserInfo sssUserInfo = new HistoryUserInfo // { // SssUserInfo = sssUser.CurSssUserInfo, // Seat = seat, // }; // //存入扑克信息 // List<int> cards = new List<int>(); // ISFSArray dunsInfo = item.GetSFSArray("duninfo"); // foreach (ISFSObject dun in dunsInfo) // { // int[] tempArrey = dun.GetIntArray("cards"); // foreach (int card in tempArrey) // { // cards.Add(card); // } // } // //把信息处理完的玩家加入列表 // sssUserInfo.Pokers = cards.ToArray(); // historyInfo.Users.Add(sssUserInfo); // } // } // HistoryList.Add(historyInfo); // if (MaxCount == 0) //如果是0,则不限制个数 // return; // while(HistoryList.Count > MaxCount) // { // HistoryList.Remove(HistoryList[0]); // } //} public void AddHistoryInfo(ISFSObject data) { if (HistoryList == null) { return; } int listCount = HistoryList.Count; if (listCount <= 0) { return; } HistoryItemInfo curItem = HistoryList[listCount - 1]; List <HistoryUserInfo> usersInfo = curItem.Users; if (usersInfo == null || usersInfo.Count == 0) { YxDebug.LogError("HistoryItem init error,the HistoryUserInfo.users is NULL or EMPTY !!!!"); return; } if (data.ContainsKey("st")) { curItem.Time = data.GetLong("st"); } ISFSArray scoreArray = data.GetSFSArray("score"); foreach (ISFSObject scoreItem in scoreArray) { int scoreSeat = scoreItem.GetInt("seat"); for (int i = 0; i < usersInfo.Count; i++) { HistoryUserInfo info = usersInfo[i]; if (info.Seat != scoreSeat) { continue; } info.Score = scoreItem.GetInt("score"); usersInfo[i] = info; //由于是值类型,需要重新赋值 } } HistoryList[HistoryList.Count - 1] = curItem; }