Ignore:
Timestamp:
2011-12-27 20:27:30 (7 years ago)
Author:
hniemi
Message:

Nyt pelitilanteen jatkaminen säilyttää myös liikutusten määrän ja kestää pelin sammuttamisen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2010/23/hniemi/BlockPusher/Blockpusher/Blockpusher/Blockpusher.cs

    r2640 r2641  
    4242    public override void Begin() 
    4343    { 
     44        gameSaved = SaveExist(); 
    4445        Menu(); 
    4546        LoadLevels(); 
     47    } 
     48 
     49    /// <summary> 
     50    /// Checks if save exists 
     51    /// </summary> 
     52    /// <returns>true, if savefile exists</returns> 
     53    public bool SaveExist()  
     54    { 
     55        return DataStorage.Exists("CurrentSave.txt"); 
    4656    } 
    4757 
     
    215225        currentLevel.Victory += VictorySplash; 
    216226 
    217         currentLevel.CreateField(ReadFile("Data/CurrentSave.txt")); 
     227        List<string> lines = ReadFile("Data/CurrentSave.txt"); 
     228        File.Delete("Data/CurrentSave.txt"); 
     229        gameSaved = false; 
     230        //DataStorage.Delete("CurrentSave.txt"); 
     231 
     232        currentLevel.Moves = int.Parse(lines[lines.Count - 1]); 
     233        lines.RemoveAt(lines.Count - 1); 
     234        currentLevelIndex = int.Parse(lines[lines.Count - 1]); 
     235        lines.RemoveAt(lines.Count - 1); 
     236 
     237        currentLevel.CreateField(lines); 
    218238        currentLevel.AddToGame(); 
    219239        SetControls(); 
     
    227247        gameSaved = true; 
    228248        savedLevel = currentLevel.CurrentState(); 
     249        savedLevel.Add(currentLevelIndex + ""); 
     250        savedLevel.Add(currentLevel.Moves + ""); 
    229251 
    230252        File.WriteAllLines("Data/CurrentSave.txt", savedLevel); 
Note: See TracChangeset for help on using the changeset viewer.