Ignore:
Timestamp:
2011-12-27 19:52:02 (8 years ago)
Author:
hniemi
Message:

Tiedostoformaattia muutettu, ja korjatut bugi, että palikoita voi oikeasti työntää...

Kentät myös siirretty hakemistoihin ja hakemisto lisätty projektiin

Location:
2010/23/hniemi/BlockPusher/Blockpusher/Blockpusher
Files:
2 edited

Legend:

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

    • Property svn:ignore set to
      bin
      obj
  • 2010/23/hniemi/BlockPusher/Blockpusher/Blockpusher/BlockLevel.cs

    r2639 r2640  
    1212public class BlockLevel 
    1313{ 
     14    private static readonly string tagPar = "par: "; 
     15    private static readonly string tagName = "name: "; 
     16    private static readonly string tagAuthor = "author: "; 
     17    private static readonly int levelStartRow = 3; 
     18 
     19 
    1420    private Block[,] playfield; 
    1521    private Blockpusher game; 
     
    2026    private int playerY; 
    2127 
    22     private int parMoves; 
    23  
    2428    public delegate void GameEvent(); 
    2529    public event GameEvent Victory; 
     
    3943    public string Name { get; set; } 
    4044 
     45    /// <summary> 
     46    /// Author of level 
     47    /// </summary> 
     48    public string Author { get;set; } 
     49 
     50    /// <summary> 
     51    /// Movecount 
     52    /// </summary> 
    4153    public int Moves { get; set; } 
     54 
     55    /// <summary> 
     56    /// How many moves to par score 
     57    /// </summary> 
     58    public int ParMoves { get; set; } 
    4259 
    4360    /// <summary> 
     
    146163            if (sourType == BlockType.Player) { playfield[endx, endy].Type = BlockType.Player; } 
    147164            if (sourType == BlockType.SatisfiedGoalZone) { playfield[endx, endy].Type = BlockType.Movable; } 
     165            if (sourType == BlockType.Movable) { playfield[endx, endy].Type = BlockType.Movable; } 
    148166        } 
    149167    } 
     
    212230    public void CreateField(IList<string> level) 
    213231    { 
    214         int playfieldWidth = level[0].Length; 
    215         int playfieldHeight = level.Count; 
     232        int playfieldWidth = level[levelStartRow].Length; 
     233        int playfieldHeight = level.Count - levelStartRow; 
     234 
     235        Name = level[0].Substring(tagName.Length); 
     236        Author = level[1].Substring(tagAuthor.Length); 
     237        ParMoves = int.Parse(level[2].Substring(tagPar.Length)); 
     238         
    216239 
    217240        playfield = new Block[playfieldWidth, playfieldHeight]; 
     
    225248                block.Y = -(j * (Blockpusher.BlockSize + 1) + game.Level.Bottom + (Blockpusher.BlockSize / 2)); 
    226249 
    227                 block.Type = FindBlockType(level[j][i]); 
     250                block.Type = FindBlockType(level[j+levelStartRow][i]); 
    228251                if (block.Type == BlockType.Player) 
    229252                { 
     
    267290        List<string> list = new List<string>(); 
    268291 
     292        list.Add(tagName + Name); 
     293        list.Add(tagAuthor + Author); 
     294        list.Add(tagPar + ParMoves); 
     295 
    269296        for (int i = 0; i < playfield.GetLength(1); i++) 
    270297        { 
Note: See TracChangeset for help on using the changeset viewer.