// 讀檔. public bool Load() { if (PlayerPrefs.HasKey(GameDefine.szSaveAchievementCount) == false) { return(false); } for (int iPos = 0, iMax = PlayerPrefs.GetInt(GameDefine.szSaveAchievementCount); iPos < iMax; ++iPos) { string szSave = GameDefine.szSaveAchievement + iPos; if (PlayerPrefs.HasKey(szSave) == false) { continue; } SaveAchievement Temp = Json.ToObject <SaveAchievement>(PlayerPrefs.GetString(szSave)); if (Temp == null) { continue; } Data.Add(Temp.Key, Temp.Value); } //for return(true); }
public int Save(SaveAchievement savableObj) { AchievementDal dal = new AchievementDal() { Id = savableObj.Id, Name = savableObj.Name }; if (savableObj.Id == default(int)) { return(_rep.Insert(dal)); } _rep.Update(dal); return(0); }
public ResponseData <int> SaveAchievement(SaveAchievement saveAchievement) { ResponseData <int> resp = new ResponseData <int>(); AchievementFacade facade = new AchievementFacade(); try { resp.Data = facade.Save(saveAchievement); } catch (Exception ex) { ExceptionHandlerFactory.Factory.GetResponseExceptionHandler(resp).Handle(ex); } return(resp); }
// 存檔. public void Save() { int iCount = 0; foreach (KeyValuePair <int, int> Itor in Data) { SaveAchievement Temp = new SaveAchievement(); Temp.Key = Itor.Key; Temp.Value = Itor.Value; PlayerPrefs.SetString(GameDefine.szSaveAchievement + iCount, Json.ToString(Temp)); ++iCount; } //for PlayerPrefs.SetInt(GameDefine.szSaveAchievementCount, iCount); }