public static CacheItemFlagInfo ToObject(string data) { CacheItemFlagInfo obj = new CacheItemFlagInfo(); obj = JsonMapper.ToObject <CacheItemFlagInfo>(data); return(obj); }
public void DeleteItemFlagInfo(long initId) { CacheItemFlagInfo info = GetCacheItemInfo(); if (info != null) { info.itemInfoDic.Remove(initId.ToString()); } SaveItemCache(); }
/// <summary> /// 有标记的存,没标记的删 /// </summary> /// <param name="itemFlag"></param> public void ChangeItemFlagInfo(long initId, int id, EItemFlagType flagType, bool flagValue) { CacheItemFlagInfo info = GetCacheItemInfo(); string strInitId = initId.ToString(); if (info != null) { if (info.itemInfoDic.ContainsKey(strInitId)) { if (flagType == EItemFlagType.JustGot) { info.itemInfoDic[strInitId].isJustGot = flagValue; } if (flagType == EItemFlagType.JustIdentified) { info.itemInfoDic[strInitId].isJuseIdentified = flagValue; } //没标记的删 if ((!info.itemInfoDic[strInitId].isJustGot) && (!info.itemInfoDic[strInitId].isJuseIdentified)) { info.itemInfoDic.Remove(strInitId); } } else { if (flagValue) { ItemFlagInfo flag = new ItemFlagInfo(); flag.itemInitId = initId; flag.itemId = id; if (flagType == EItemFlagType.JustGot) { flag.isJustGot = flagValue; flag.isJuseIdentified = false; } if (flagType == EItemFlagType.JustIdentified) { flag.isJustGot = false; flag.isJuseIdentified = flagValue; } info.itemInfoDic.Add(strInitId, flag); //Debug.LogError(flag.itemInitId); } else { Debug.LogWarning("meaningless operation!!"); } } } SaveItemCache(); }
private void Init() { FileManager file = new FileManager(CACHE_USER_INFO_FILE); string userJson = file.Read(); if (string.IsNullOrEmpty(userJson)) { m_userInfo = new CacheUserInfo(); } else { m_userInfo = CacheUserInfo.ToObject(userJson); } FileManager skillfile = new FileManager(CACHE_USER_SKILL_INFO_FILE); string userskillJson = skillfile.Read(); if (string.IsNullOrEmpty(userskillJson)) { m_userskillInfo = new CacheUseSkillInfo(); } else { m_userskillInfo = CacheUseSkillInfo.ToObject(userskillJson); } FileManager itemfile = new FileManager(CACHE_ITEM_FLAG_INFO_FILE); string itemFlagJson = itemfile.Read(); if (string.IsNullOrEmpty(itemFlagJson)) { m_itemFlagInfo = new CacheItemFlagInfo(); } else { m_itemFlagInfo = CacheItemFlagInfo.ToObject(itemFlagJson); } }