/// <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); _line2.width = _line2Width[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(); userInfo.SssUserInfo = user.GetInfo <SssUserInfo>(); userInfo.Seat = user.Info.Seat; userInfo.Pokers = info.Cards.ToArray(); userInfo.AddScore = info.AddScore.ToArray(); userInfo.NormalScore = info.NormalScores.ToArray(); userInfo.Score = info.TtScore; userInfo.DunType = info.DunTypeList.ToArray(); userInfo.Sprcial = info.Special; userInfo.ShootInfo = info.Shoot; userInfo.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) { HistoryItemInfo curItem = HistoryList[HistoryList.Count - 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; }