public void Setup(RoomHistory room, GameBaseInfo baseInfo, List <int> records) { actionRecords = records; mRoom = room; mBaseInfo = baseInfo; current = 0; lastAction = null; mCount = baseInfo.mahjongs.Count; foreach (GameSeatInfo seat in baseInfo.game_seats) { mCount -= seat.holds.Count + seat.flowers.Count; } }
void onBtnReplay(int id) { NetMgr nm = NetMgr.GetInstance(); RoomMgr rm = RoomMgr.GetInstance(); nm.request_apis("get_detail_of_game", "id", id, data => { GetDetailOfGame ret = JsonUtility.FromJson <GetDetailOfGame> (data.ToString()); if (ret.errcode != 0) { return; } Debug.Log("base_info: "); Debug.Log(ret.data.base_info); GameBaseInfo baseInfo = JsonUtility.FromJson <GameBaseInfo> (ret.data.base_info); List <int> actionRecords = ret.data.action_records; rm.prepareReplay(mRoom, baseInfo); ReplayMgr.GetInstance().Setup(mRoom, baseInfo, actionRecords); LoadingScene.LoadNewScene("04.table3d"); }); }
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; }