private void RefreshSaveData() { CampsiteData data = PlayerDataMgr.singleton.DB.campsiteData; if (data == null) { data = new CampsiteData(); } data.id = this.id; data.totalRewardVal = this.totalRewardVal; data.lastRecordTime = this.lastRecordTime; data.hasOfflineReward = this.hasOfflineReward; CampsitePointData[] pointsBuffer = data.points; if (data.points == null || data.points.Length != this.points.Length) { data.points = new CampsitePointData[this.points.Length]; } for (int i = 0; i < this.points.Length; i++) { CampsitePointData buffer = pointsBuffer != null && i < pointsBuffer.Length ? pointsBuffer[i] : new CampsitePointData(); this.points[i].FillSaveData(buffer); data.points[i] = buffer; } PlayerDataMgr.singleton.DB.campsiteData = data; PlayerDataMgr.singleton.NotifySaveData(); }
private bool LoadSaveData() { CampsiteData data = PlayerDataMgr.singleton.DB.campsiteData;//从DB取值 if (data != null) { var res = TableMgr.singleton.CampSetTable.GetItemByID(data.id); if (res == null) { return(false); } if (res.CampBuildingArr.Length != data.points.Length) { return(false); } int lastAutoLv = 0; this.id = data.id; this.sceneName = res.sceneName; this.totalRewardVal = data.totalRewardVal; this.lastRecordTime = data.lastRecordTime; this.hasOfflineReward = data.hasOfflineReward; this.points = new CampsitePointMgr[data.points.Length]; for (int i = 0; i < points.Length; i++) { var pData = data.points[i]; CampsitePointMgr p = new CampsitePointMgr(); p.Init(id, i, res.CampBuildingArr[i], res.AutoLevelArr[i], lastAutoLv); p.LoadSaveData(pData); p.SetOfflineState(hasOfflineReward); this.points[i] = p; lastAutoLv = res.AutoLevelArr[i]; } return(true); } else { return(false); } }