protected override void ParseData(SqliteDataReader reader) { if (reader == null || !reader.HasRows) { return; } while (reader.Read()) { DBMagicItem ad = new DBMagicItem(); ad.Id = DBTextResource.ParseUI(GetReaderString(reader, "id")); ad.SortId = DBTextResource.ParseI(GetReaderString(reader, "sort")); ad.Name = GetReaderString(reader, "name"); ad.IconName = GetReaderString(reader, "icon_name"); ad.Color = DBTextResource.ParseUI(GetReaderString(reader, "color")); ad.AssistAttrs = DBTextResource.ParseDBAttrItems(GetReaderString(reader, "attrs")); ad.SkillList = DBTextResource.ParseArrayUint(GetReaderString(reader, "skills"), ","); data.Add(ad.Id, ad); SortData.Add(ad); } SortData.Sort((a, b) => { if (a.SortId < b.SortId) { return(-1); } else if (a.SortId > b.SortId) { return(1); } return(0); }); }
public void OnPostRoleInfoFinished(string url, string error, string reply, System.Object userData) { int result = 0; Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable; if (hashtable != null) { result = DBTextResource.ParseI(hashtable["result"].ToString()); } if (result != 1) { if (mPostRoleInfoTimer != null) { mPostRoleInfoTimer.Destroy(); mPostRoleInfoTimer = null; } // 超过10次就不要再尝试了 if (mPostRoleInfoTimes <= 10) { mPostRoleInfoTimer = new Utils.Timer(3000, false, 3000, PostRoleInfoWithDelay); mPostRoleInfoTimes++; } else { mPostRoleInfoTimes = 0; } } else { mPostRoleInfoTimes = 0; } }
public void OnFeedback(string url, string error, string reply, System.Object userData) { bool result; if (string.IsNullOrEmpty(error)) { Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable; if (hashtable != null) { if (DBTextResource.ParseI(hashtable["result"].ToString()) == 1) { result = true; } else { result = false; } } else { result = false; } } else { result = false; } mPostFeedbackCallback?.Invoke(result); }
protected override void ParseData(SqliteDataReader reader) { if (reader == null || !reader.HasRows) { return; } mData.Clear(); while (reader.Read()) { Data data = new Data(); data.vocation = (Actor.EVocationType)DBTextResource.ParseUI(GetReaderString(reader, "vocation")); data.path = GetReaderString(reader, "path"); data.low_path = GetReaderString(reader, "low_path"); data.part = (BODY_PART)DBTextResource.ParseUI(GetReaderString(reader, "part")); data.isFashion = DBTextResource.ParseI(GetReaderString(reader, "is_show")) == 0 ? false : true; data.isShowWin = DBTextResource.ParseI(GetReaderString(reader, "is_show_win")) == 0 ? false : true; uint id = DBTextResource.ParseUI(GetReaderString(reader, "id")); // 身体部件模型有高模,程序内部增加一个id来对应高模 if (data.part == BODY_PART.BODY) { Data newData = data.Clone(); newData.path += "_high"; mData.Add(id * 100, newData); } mData.Add(id, data); } }
public void OnGetChannelList(string url, string error, string reply, System.Object userData) { if (string.IsNullOrEmpty(error) == false) { GameDebug.LogError("OnGetChannelList error: " + error); return; } mChannelList = new List <ChannelInfo>(); mChannelList.Clear(); Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable; if (hashtable != null) { if (DBTextResource.ParseI(hashtable["result"].ToString()) == 1) { ArrayList arrayList = hashtable["args"] as ArrayList; if (arrayList != null) { foreach (System.Object o in arrayList) { Hashtable channelInfoHashtable = o as Hashtable; if (channelInfoHashtable != null && channelInfoHashtable.Count > 0) { ChannelInfo channelInfo = new ChannelInfo(); channelInfo.Id = System.Convert.ToUInt32(channelInfoHashtable["id"]); channelInfo.Name = System.Convert.ToString(channelInfoHashtable["name"]); channelInfo.Title = System.Convert.ToString(channelInfoHashtable["title"]); mChannelList.Add(channelInfo); } } } } else { Hashtable argsHashtable = hashtable["args"] as Hashtable; if (argsHashtable != null) { string msg = argsHashtable["error_msg"].ToString(); GameDebug.LogError("GetChannelList error, msg:" + msg); } else { GameDebug.LogError("GetChannelList error, unknown reason"); } } } }
SuitEffectInfo GetItemInfo(uint id) { string query = string.Format("SELECT * FROM {0} WHERE {0}.{1}=\"{2}\"", mTableName, "id", id); var reader = DBManager.Instance.ExecuteSqliteQueryToReader(GlobalConfig.DBFile, mTableName, query); if (reader == null) { mSuitEffectInfos[id] = null; return(null); } if (!reader.HasRows || !reader.Read()) { mSuitEffectInfos[id] = null; reader.Close(); reader.Dispose(); return(null); } SuitEffectInfo info = new SuitEffectInfo(); info.id = id; info.effect_type = DBTextResource.ParseUI(GetReaderString(reader, "effect_type")); int effect_count = DBTextResource.ParseI(GetReaderString(reader, "effect_count")); info.bind_infos = new List <BindInfo>(effect_count); for (int i = 0; i < effect_count; ++i) { var bind_info = new BindInfo(); bind_info.model_id = DBTextResource.ParseUI(GetReaderString(reader, "model_id_" + (i + 1))); bind_info.low_model_id = DBTextResource.ParseUI(GetReaderString(reader, "low_model_id_" + (i + 1))); bind_info.ui_model_id = DBTextResource.ParseUI(GetReaderString(reader, "ui_model_id_" + (i + 1))); if (bind_info.ui_model_id == 0) { bind_info.ui_model_id = bind_info.model_id; } bind_info.bind_node = GetReaderString(reader, "bind_node_" + (i + 1)); info.bind_infos.Add(bind_info); } mSuitEffectInfos[info.id] = info; reader.Close(); reader.Dispose(); return(info); }
public void OnGetServerList(string url, string error, string reply, System.Object userData) { if (string.IsNullOrEmpty(error) == false) { GameDebug.LogError("OnGetServerList error: " + error); return; } Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable; if (hashtable != null) { if (DBTextResource.ParseI(hashtable["result"].ToString()) == 1) { ArrayList arrayList = hashtable["args"] as ArrayList; if (arrayList != null) { foreach (System.Object o in arrayList) { Hashtable serverInfoHashtable = o as Hashtable; if (serverInfoHashtable != null && serverInfoHashtable.Count > 0) { uint controlServerId = System.Convert.ToUInt32(serverInfoHashtable["server_id"]); uint serverId = System.Convert.ToUInt32(serverInfoHashtable["s_id"]); string name = System.Convert.ToString(serverInfoHashtable["name"]); SpanServerManager.Instance.AddServerNameFromControlServer(controlServerId, serverId, name); } } } } else { Hashtable argsHashtable = hashtable["args"] as Hashtable; if (argsHashtable != null) { string msg = argsHashtable["error_msg"].ToString(); GameDebug.LogError("OnGetServerList error, msg:" + msg); } else { GameDebug.LogError("OnGetServerList error, unknown reason"); } } } }
public void OnGetPackFinished(string url, string error, string reply, System.Object userData) { if (string.IsNullOrEmpty(error) == false) { GameDebug.LogError("OnGetPackFinished error: " + error); UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_FAIL")); mPostGetPackFinishedCallback?.Invoke(false); return; } bool ret = false; Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable; if (hashtable != null) { int result = DBTextResource.ParseI(hashtable["result"].ToString()); if (result == 1) { UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_EXCHANGE_SUCCESS")); ret = true; } else { Hashtable argsHashtable = hashtable["args"] as Hashtable; if (argsHashtable != null) { string msg = argsHashtable["error_msg"].ToString(); string translatedMsg = xc.TextHelper.GetTranslateText(msg); UINotice.GetInstance().ShowMessage(translatedMsg); } else { UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_FAIL")); } } } else { GameDebug.LogError("OnGetPackFinished error: " + reply); } mPostGetPackFinishedCallback?.Invoke(ret); }
public void OnGetServerStateFinished(string url, string error, string reply, System.Object userData) { #if UNITY_IPHONE reply = Utils.AES.Decode(reply, Const.CS_URL_KEY, Const.CS_URL_IV); #endif System.Object replyObject = MiniJSON.JsonDecode(reply); if (CheckReply(url, error, replyObject) == false) { if (mGetServerStateFinishedCallback != null) { mGetServerStateFinishedCallback(null, false); } return; } ServerInfo serverInfo = userData as ServerInfo; if (serverInfo == null) { GameDebug.LogError("Error in OnGetServerStateFinished, serverInfo is null!!!"); return; } Hashtable hashtable = (replyObject as Hashtable)["args"] as Hashtable; if (hashtable != null) { serverInfo.State = (EServerState)DBTextResource.ParseI(hashtable["status"].ToString()); } bool canEnter = CheckServerState(serverInfo); // 如果是不推荐进入的服务器,则读取recomm属性选中推荐的服务器 if (serverInfo.State == EServerState.NotRecomm) { if (hashtable != null) { Hashtable recommHashtable = hashtable["recomm"] as Hashtable; if (recommHashtable != null) { ServerInfo recommServerInfo = ParseServerInfo(recommHashtable); if (recommServerInfo != null) { xc.ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("SERVER_NOT_RECOMM_TIPS"), (x) => { ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_SELECT_SERVER, new CEventBaseArgs(recommServerInfo)); }); canEnter = false; } } } } if (mGetServerStateFinishedCallback != null) { mGetServerStateFinishedCallback(serverInfo, canEnter); } if (canEnter == false || mEnterWhenGetServerStateFinished == false) { return; } GlobalConfig.GetInstance().LoginInfo.ServerInfo = serverInfo; string[] ips = serverInfo.Url.Split(':'); Game game = Game.GetInstance(); game.ServerIP = ips[0]; game.ServerPort = DBTextResource.ParseI(ips[1]); game.ServerID = (uint)serverInfo.SId; ControlServerLogHelper.GetInstance().PostAccountLoginLogS(serverInfo.ServerId, serverInfo.State); game.GameMode = (Game.EGameMode)((int)game.GameMode | (int)xc.Game.EGameMode.GM_Net); game.Login(); }
/// <summary> /// 获取某个副本的信息 /// </summary> /// <returns>The instance info.</returns> /// <param name="id">Identifier.</param> public InstanceInfo GetInstanceInfo(uint id) { InstanceInfo info = null; if (mInstanceInfos.TryGetValue(id, out info)) { return(info); } string queryStr = string.Format("SELECT * FROM {0} WHERE {0}.{1}=\"{2}\"", mTableName, "id", id.ToString()); var table_reader = DBManager.Instance.ExecuteSqliteQueryToReader(GlobalConfig.DBFile, mTableName, queryStr); if (table_reader == null) { mInstanceInfos.Add(id, null); return(null); } if (!table_reader.HasRows) { mInstanceInfos.Add(id, null); table_reader.Close(); table_reader.Dispose(); return(null); } if (!table_reader.Read()) { mInstanceInfos.Add(id, null); table_reader.Close(); table_reader.Dispose(); return(null); } info = new InstanceInfo(); Type gameConstType = typeof(GameConst); info.mId = DBTextResource.ParseUI_s(GetReaderString(table_reader, "id"), 0); info.mMaxTime = DBTextResource.ParseI(GetReaderString(table_reader, "max_time")); info.mNeedGoods = DBTextResource.ParseDictionaryUintUint(GetReaderString(table_reader, "need_goods")); info.mDyNeedGoods = DBTextResource.ParseArrayUintUint(GetReaderString(table_reader, "dy_need_goods")); info.mNeedLv = DBTextResource.ParseUS_s(GetReaderString(table_reader, "need_lv"), 0); info.mLvUpLimit = DBTextResource.ParseUS_s(GetReaderString(table_reader, "lv_up_limit"), 0); info.mRecommendAttrs = ParseRecommendAttrs(GetReaderString(table_reader, "recommend_attrs")); info.mSingleEnter = DBTextResource.ParseI(GetReaderString(table_reader, "single_enter")) == 1 ? true : false; string mbCountStr = GetReaderString(table_reader, "mb_count"); ushort mbCount = 0; /* 进入人数四种要求: * 0:可单人,也可以任意组队(不用配) * 1:必须单人(可以没有队伍,也可以在只有他一个人的队伍中) * N(N>=2):必须N人以上组队 * {M,N}:大于等于M且小于等于N */ if (string.IsNullOrEmpty(mbCountStr) == true) { info.mMinMemberCount = 0; info.mMaxMemberCount = GameConstHelper.GetShort("GAME_TEAM_MEMBER_LIMIT"); } else if (ushort.TryParse(mbCountStr, out mbCount) == true) { info.mMinMemberCount = mbCount; if (info.mMinMemberCount == 0) { info.mMaxMemberCount = GameConstHelper.GetShort("GAME_TEAM_MEMBER_LIMIT"); } else if (info.mMinMemberCount == 1) { info.mMinMemberCount = 0; info.mMaxMemberCount = 1; } else { info.mMaxMemberCount = GameConstHelper.GetShort("GAME_TEAM_MEMBER_LIMIT"); } } else { List <uint> mbCountList = DBTextResource.ParseArrayUint(mbCountStr, ","); if (mbCountList.Count >= 2) { info.mMinMemberCount = (ushort)mbCountList[0]; info.mMaxMemberCount = (ushort)mbCountList[1]; } } info.mSweepCosts = DBTextResource.ParseDictionaryUintUint(GetReaderString(table_reader, "sweep_costs")); info.mSweepLimit = DBTextResource.ParseVector2(GetReaderString(table_reader, "sweep_limit")); info.mName = GetReaderString(table_reader, "name"); //System.Reflection.FieldInfo fieldInfo = null; //string warTypeStr = GetReaderString(table_reader, "war_type"); //if (mGameConstUintValueCache.ContainsKey(warTypeStr) == true) //{ // info.mWarType = mGameConstUintValueCache[warTypeStr]; //} //else //{ // fieldInfo = gameConstType.GetField(warTypeStr); // if (fieldInfo != null) // { // info.mWarType = Convert.ToUInt32(fieldInfo.GetValue(null)); // mGameConstUintValueCache[warTypeStr] = info.mWarType; // } // else // { // GameDebug.LogError("Can not find war type " + warTypeStr + " in db instance!!!"); // } //} //string warsubTypeStr = GetReaderString(table_reader, "war_subtype"); //if (string.IsNullOrEmpty(warsubTypeStr) == false) //{ // if (mGameConstUintValueCache.ContainsKey(warsubTypeStr) == true) // { // info.mWarSubType = mGameConstUintValueCache[warsubTypeStr]; // } // else // { // fieldInfo = gameConstType.GetField(warsubTypeStr); // if (fieldInfo != null) // { // info.mWarSubType = Convert.ToUInt32(fieldInfo.GetValue(null)); // mGameConstUintValueCache[warsubTypeStr] = info.mWarSubType; // } // else // { // GameDebug.LogError("Can not find sub war type " + warsubTypeStr + " in db instance!!!"); // } // } //} uint warType = 0; uint warSubType = 0; string warTypeStr = GetReaderString(table_reader, "war_type"); string warSubTypeStr = GetReaderString(table_reader, "war_subtype"); ConvertWarType(warTypeStr, warSubTypeStr, out warType, out warSubType); info.mWarType = warType; info.mWarSubType = warSubType; info.mDesc = GetReaderString(table_reader, "desc"); info.mStages.Clear(); string stagesStr = GetReaderString(table_reader, "stages"); List <string> stages = DBTextResource.ParseArrayString(stagesStr); for (int j = 0; j < stages.Count; j++) { if (!String.IsNullOrEmpty(stages[j])) { info.mStages.Add(DBTextResource.ParseUI(stages[j])); } } info.mPKType = DBTextResource.ParseI(GetReaderString(table_reader, "pk_type")); info.mReviveTimes = DBTextResource.ParseUS(GetReaderString(table_reader, "revive_times")); info.mReadyCountDown = DBTextResource.ParseUS(GetReaderString(table_reader, "ready_count_down")); info.mResultCountDown = DBTextResource.ParseUI(GetReaderString(table_reader, "result_count_down")); info.mIsReloadSceneWhenTheSame = DBTextResource.ParseI(GetReaderString(table_reader, "is_reload_scene_when_the_same")) == 0 ? false : true; info.mMinPos = DBTextResource.ParseVector2(GetReaderString(table_reader, "mini_map_pos_x")); info.mMaxPos = DBTextResource.ParseVector2(GetReaderString(table_reader, "mini_map_pos_y")); info.mMiniMapWidth = info.mMaxPos.x - info.mMinPos.x; info.mMiniMapHeight = info.mMaxPos.y - info.mMinPos.y; info.mMiniMapName = GetReaderString(table_reader, "mini_map"); info.mIsCanOpenMiniMap = DBTextResource.ParseI(GetReaderString(table_reader, "is_open_mini_map")) == 0 ? false : true; string isShowMarkStr = GetReaderString(table_reader, "is_show_mark"); if (isShowMarkStr == string.Empty || isShowMarkStr == "0") { info.mIsShowMark = false; } else { info.mIsShowMark = true; } string isAutoFightStr = GetReaderString(table_reader, "is_auto_fight"); if (isAutoFightStr == string.Empty || isAutoFightStr == "0") { info.mIsAutoFight = false; } else { info.mIsAutoFight = true; } string canNotRideStr = GetReaderString(table_reader, "can_not_ride"); if (canNotRideStr == string.Empty || canNotRideStr == "0") { info.mCanNotRide = false; } else { info.mCanNotRide = true; } info.mRewardIds = DBTextResource.ParseArrayUint(GetReaderString(table_reader, "reward_1"), ","); info.mShowRewardIds = DBTextResource.ParseArrayUint(GetReaderString(table_reader, "show_rewards"), ","); info.mNeedTaskId = DBTextResource.ParseUI_s(GetReaderString(table_reader, "need_task_id"), 0); info.mPlanesInstanceId = DBTextResource.ParseUI_s(GetReaderString(table_reader, "planes_dg_id"), 0); info.mStartTimeline = DBTextResource.ParseUI_s(GetReaderString(table_reader, "start_timeline"), 0); info.mGuardedNpcId = DBTextResource.ParseUI_s(GetReaderString(table_reader, "npc_id"), 0); string showBossAssStr = GetReaderString(table_reader, "show_boss_assistant"); if (showBossAssStr == string.Empty || showBossAssStr == "0") { info.mShowBossAssistant = false; } else { info.mShowBossAssistant = true; } info.mForbidJumpOutAnimationOut = DBTextResource.ParseUI_s(GetReaderString(table_reader, "forbid_jump_out_animation_out"), 0) == 1; info.mForbidWaterWaveEffect = DBTextResource.ParseUI_s(GetReaderString(table_reader, "forbid_water_wave_effect"), 0) == 1; info.mIsCanSendPosition = DBTextResource.ParseUI_s(GetReaderString(table_reader, "is_can_send_position"), 0) == 1; info.mMergeLevel = DBTextResource.ParseUI_s(GetReaderString(table_reader, "merge_level"), 0); info.mMergeConsume = DBTextResource.ParseDictionaryUintUint(GetReaderString(table_reader, "merge_consume")); #if UNITY_EDITOR if (mInstanceInfos.ContainsKey(info.mId)) { GameDebug.LogError(string.Format("[{0}]表重复添加的域id[{1}]", mTableName, info.mId)); table_reader.Close(); table_reader.Dispose(); return(info); } #endif mInstanceInfos.Add(info.mId, info); table_reader.Close(); table_reader.Dispose(); return(info); }
public void OnPostDeviceInitFinished(string url, string error, string reply, System.Object userData) { int result = 0; Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable; if (hashtable != null) { result = DBTextResource.ParseI(hashtable["result"].ToString()); } bool ret = false; string errorMsg = ""; Hashtable argsHashtable = hashtable["args"] as Hashtable; if (result == 1) { if (argsHashtable != null) { string deviceMark = argsHashtable["device_mark"].ToString(); if (GlobalConfig.Instance.DeviceMark.Equals(deviceMark) == false) { GlobalConfig.Instance.DeviceMark = deviceMark; GlobalSettings.GetInstance(); UserPlayerPrefs.Instance.SetString("DeviceMark", deviceMark); UserPlayerPrefs.Instance.Save(); } ret = true; } } else { if (argsHashtable != null) { errorMsg = argsHashtable["error_msg"].ToString(); } } if (ret == true) { // DeviceInit成功 ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.DeviceInitEnd, "", false); ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.boot_app); } else { // DeviceInit失败 if (string.IsNullOrEmpty(errorMsg) == true) { if (string.IsNullOrEmpty(error) == false) { ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.DeviceInitFail, error, false); } else { ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.DeviceInitFail, "Unknown error", false); } } else { ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.DeviceInitFail, errorMsg, false); } } // action保存了NewInitSceneLoader中的函数,调用之后需要赋空 if (mPostDeviceInitFinishedCallback != null) { mPostDeviceInitFinishedCallback.Invoke(ret); mPostDeviceInitFinishedCallback = null; } }