Exemple #1
0
 private void DoSave(BinaryWriter writer)
 {
     try
     {
         if (this.SaveData.SinceLastSaved.HasValue)
         {
             this.tempSaveData.PlayTime += DateTime.Now.Ticks - this.SaveData.SinceLastSaved.Value;
             this.SaveData.PlayTime      = this.tempSaveData.PlayTime;
         }
         this.SaveData.SinceLastSaved = new long?(DateTime.Now.Ticks);
         SaveFileOperations.Write(new CrcWriter(writer), this.tempSaveData);
     }
     catch (Exception ex)
     {
         Logger.Log("Saving", LogSeverity.Error, ((object)ex).ToString());
     }
 }
Exemple #2
0
        private void ChooseSaveSlot(SaveSlotInfo slot, SaveManagementLevel.SMOperation operation)
        {
            switch (operation)
            {
            case SaveManagementLevel.SMOperation.Change:
                this.GameState.SaveSlot = slot.Index;
                this.GameState.LoadSaveFile((Action)(() =>
                {
                    this.GameState.Save();
                    this.GameState.DoSave();
                    this.GameState.SaveToCloud(true);
                    this.GameState.Restart();
                }));
                break;

            case SaveManagementLevel.SMOperation.CopySource:
                this.CopySourceSlot = slot;
                this.RefreshSlotsFor(this.CopyDestLevel, SaveManagementLevel.SMOperation.CopyDestination, (Func <SaveSlotInfo, bool>)(s => this.CopySourceSlot != s));
                this.Menu.ChangeMenuLevel(this.CopyDestLevel, false);
                break;

            case SaveManagementLevel.SMOperation.CopyDestination:
                new PCSaveDevice("FEZ").Save("SaveSlot" + (object)slot.Index, (SaveAction)(writer => SaveFileOperations.Write(new CrcWriter(writer), this.CopySourceSlot.SaveData)));
                this.GameState.SaveToCloud(true);
                this.ReloadSlots();
                this.Menu.ChangeMenuLevel((MenuLevel)this, false);
                break;

            case SaveManagementLevel.SMOperation.Clear:
                new PCSaveDevice("FEZ").Delete("SaveSlot" + (object)slot.Index);
                if (this.GameState.SaveSlot == slot.Index)
                {
                    this.GameState.LoadSaveFile((Action)(() =>
                    {
                        this.GameState.Save();
                        this.GameState.DoSave();
                        this.GameState.SaveToCloud(true);
                        this.GameState.Restart();
                    }));
                    break;
                }
                else
                {
                    this.ReloadSlots();
                    this.Menu.ChangeMenuLevel((MenuLevel)this, false);
                    break;
                }
            }
        }
Exemple #3
0
 private void LoadSaveFile(BinaryReader reader)
 {
     this.SaveData = SaveFileOperations.Read(new CrcReader(reader));
 }
Exemple #4
0
 private void ReloadSlots()
 {
     for (int index = 0; index < 3; ++index)
     {
         SaveSlotInfo saveSlotInfo = this.Slots[index] = new SaveSlotInfo()
         {
             Index = index
         };
         PCSaveDevice pcSaveDevice = new PCSaveDevice("FEZ");
         string       fileName     = "SaveSlot" + (object)index;
         if (!pcSaveDevice.FileExists(fileName))
         {
             saveSlotInfo.Empty = true;
         }
         else
         {
             SaveData saveData = (SaveData)null;
             if (!pcSaveDevice.Load(fileName, (LoadAction)(stream => saveData = SaveFileOperations.Read(new CrcReader(stream)))) || saveData == null)
             {
                 saveSlotInfo.Empty = true;
             }
             else
             {
                 saveSlotInfo.Percentage = (float)(((double)(saveData.CubeShards + saveData.SecretCubes + saveData.PiecesOfHeart) + (double)saveData.CollectedParts / 8.0) / 32.0);
                 saveSlotInfo.PlayTime   = new TimeSpan(saveData.PlayTime);
                 saveSlotInfo.SaveData   = saveData;
             }
         }
     }
 }