Changeset 2641


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

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

Location:
2010/23/hniemi/BlockPusher
Files:
6 edited

Legend:

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

    r2640 r2641  
    1515    private static readonly string tagName = "name: "; 
    1616    private static readonly string tagAuthor = "author: "; 
    17     private static readonly int levelStartRow = 3; 
     17    private static readonly string tagScore = "highscore: "; 
     18    private static readonly int levelStartRow = 4; 
    1819 
    1920 
     
    5758    /// </summary> 
    5859    public int ParMoves { get; set; } 
     60 
     61    /// <summary> 
     62    /// Highscore 
     63    /// </summary> 
     64    public int HighScore { get; set; } 
    5965 
    6066    /// <summary> 
     
    236242        Author = level[1].Substring(tagAuthor.Length); 
    237243        ParMoves = int.Parse(level[2].Substring(tagPar.Length)); 
    238          
     244        HighScore = int.Parse(level[3].Substring(tagScore.Length)); 
    239245 
    240246        playfield = new Block[playfieldWidth, playfieldHeight]; 
     
    293299        list.Add(tagAuthor + Author); 
    294300        list.Add(tagPar + ParMoves); 
     301        list.Add(tagScore + HighScore); 
    295302 
    296303        for (int i = 0; i < playfield.GetLength(1); i++) 
  • 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); 
  • 2010/23/hniemi/BlockPusher/Blockpusher/Blockpusher/Data/Levels/Level1.txt

    r2640 r2641  
    22author: Hekku2 
    33par: 12 
     4highscore: 99 
    45xxxxxxxxx 
    56x  x  xmx 
  • 2010/23/hniemi/BlockPusher/Blockpusher/Blockpusher/Data/Levels/Level2.txt

    r2640 r2641  
    22author: Hekku2 
    33par: 10 
     4highscore: 99 
    45xxxxxxxxx 
    56x    xxxx 
  • 2010/23/hniemi/BlockPusher/Blockpusher/Blockpusher/Data/Levels/Level3.txt

    r2640 r2641  
    22author: Hekku2 
    33par: 8 
     4highscore: 99 
    45xxxxxxxxx 
    56xmb  xxxx 
Note: See TracChangeset for help on using the changeset viewer.