void showGames() { if (mRoom == null || mGames == null) { return; } setText(transform, "title/roomid", "房间号:" + mRoom.room_id); setText(transform, "title/desc", mRoom.info.huafen + "/" + mRoom.info.huafen + (mRoom.info.maima ? "带苍蝇" : "不带苍蝇") + mRoom.info.maxGames + "局"); for (int i = 0; i < mGames.Count; i++) { HistoryGame game = mGames[i]; Transform item = getItem(i); setText(item, "id", "" + (game.game_index + 1)); setText(item, "time", PUtils.formatTime(game.create_time, "yyyy/MM/dd HH:mm:ss")); Transform seats = item.Find("seats"); UITable table = seats.GetComponent <UITable>(); List <HistorySeats> ss = mRoom.info.seats; int j = 0; for (; j < seats.childCount && j < ss.Count; j++) { Transform seat = seats.GetChild(j); HistorySeats s = ss[j]; seat.gameObject.SetActive(true); setText(seat, "name", s.name); setText(seat, "score", "" + game.result [j]); setIcon(seat, "bghead/icon", s.uid); } for (int k = j; k < seats.childCount; k++) { Transform seat = seats.GetChild(k); seat.gameObject.SetActive(false); } table.Reposition(); setBtnEvent(item, "btn_share", () => { }); setBtnEvent(item, "btn_replay", () => { onBtnReplay(game.id); }); } updateItems(mGames.Count); }
public void prepareReplay(RoomHistory room, GameBaseInfo baseInfo) { reset(); info.roomid = room.room_tag; info.numofseats = room.info.seats.Count; info.numofgames = baseInfo.index + 1; int nSeats = room.info.seats.Count; state.state = "playing"; for (int i = 0; i < nSeats; i++) { PlayerInfo p = new PlayerInfo(); p.reset(); HistorySeats hs = room.info.seats[i]; p.name = hs.name; p.score = hs.score; p.userid = hs.uid; p.seatindex = i; p.online = true; p.ip = "127.0.0.1"; p.ready = true; players.Add(p); SeatInfo s = new SeatInfo(); s.reset(); s.holds = new List <int>(baseInfo.game_seats[i].holds); s.flowers = new List <int>(baseInfo.game_seats[i].flowers); seats.Add(s); if (p.userid == GameMgr.GetInstance().userMgr.userid) { seatindex = i; } } if (seatindex < 0) { seatindex = 0; } conf = baseInfo.conf; int button = baseInfo.button; state.button = button; state.turn = button; int count = baseInfo.mahjongs.Count; foreach (GameSeatInfo seat in baseInfo.game_seats) { count -= seat.holds.Count + seat.flowers.Count; } state.numofmj = count; }