using System; using System.Collections.Generic; using LitJson; namespace Wizard; public class RoomBattleWatchTaskBase : BaseTask { public class UserInfo { public int battlePoint; public int degreeId; public long emblemId; public string countryCode; public int rank; public string userName; public int viewerId; public bool IsOfficialUser { get; set; } public UserInfo() { } public UserInfo(Dictionary data) { viewerId = Convert.ToInt32(data["viewerId"]); countryCode = data["country_code"].ToString(); userName = data["userName"].ToString(); rank = Convert.ToInt32(data["rank"]); battlePoint = Convert.ToInt32(data["battlePoint"]); emblemId = Convert.ToInt32(data["emblemId"]); degreeId = Convert.ToInt32(data["degreeId"]); IsOfficialUser = Convert.ToInt32(data["isOfficial"]) == 1; } } public int result_reason; public string node_server_url; public UserInfo owner_info; public UserInfo visitor_info; public BattleParameter BattleParameterInstance { get; private set; } protected override int Parse() { int num = base.Parse(); if (num != 1) { return num; } JsonData jsonData = base.ResponseData["data"]; result_reason = jsonData["result_reason"].ToInt(); if (result_reason == 0) { if (jsonData.Keys.Contains("owner_info")) { ParseUserInfo(jsonData["owner_info"], ref owner_info); } if (jsonData.Keys.Contains("visitor_info")) { ParseUserInfo(jsonData["visitor_info"], ref visitor_info); } node_server_url = jsonData["node_server_url"].ToString(); } if (jsonData.Keys.Contains("is_admin")) { bool flag = Convert.ToBoolean(jsonData["is_admin"].ToInt()); GameMgr.GetIns().IsAdmin = flag; GameMgr.GetIns().HasAuthAdmin = flag; } else { GameMgr.GetIns().IsAdmin = false; GameMgr.GetIns().HasAuthAdmin = false; } BattleParameterInstance = BattleParameter.JsonToBattleParameter(base.ResponseData["data"]); if (BattleParameterInstance.BattleType == NetworkDefine.ServerBattleType.RoomTwoPick) { GameMgr.GetIns().GetDataMgr().m_BattleType = DataMgr.BattleType.RoomTwoPick; GameMgr.GetIns().GetDataMgr().TwoPickFormat = BattleParameterInstance.TwoPickFormat; } else { GameMgr.GetIns().GetDataMgr().m_BattleType = DataMgr.BattleType.RoomBattle; } return num; } private void ParseUserInfo(JsonData receive, ref UserInfo info) { if (receive != null) { info = new UserInfo(); info.viewerId = receive["viewer_id"].ToInt(); info.battlePoint = receive["battlePoint"].ToInt(); info.degreeId = receive["degreeId"].ToInt(); info.emblemId = receive["emblemId"].ToLong(); info.countryCode = receive["country_code"].ToString(); info.rank = receive["rank"].ToInt(); info.userName = receive["userName"].ToString(); info.IsOfficialUser = receive["isOfficial"].ToInt() == 1; } } }