public void UpdatePosition(Board board, Directions Direction) { BaseBlock block = this.GetNeighbour(Direction); if (block == null || block.blockCanBeConsumed) { this.MoveTo(Direction); } if (block != null && block.blockCanBeConsumed) { if (block is HeartBlock) { board.HeartsTaken++; Sounds.Instance.PlayEffect(SoundType.Heart); } if (block is ExitBlock) { Sounds.Instance.PlayEffect(SoundType.LevelFinish); } if (!(block is HeartBlock)) { Sounds.Instance.PlayEffect(SoundType.SnowShuffeld); } board.RemoveBlock(block); } if (block != null && block.blockCanBePushed && ((Direction == Directions.East && block.GetNeighbour(Directions.East) == null) ||(Direction == Directions.West && block.GetNeighbour(Directions.West) == null ))) { this.MoveTo(Direction); block.MoveTo(Direction); } }
private Board GetBoardFromXml(XmlNode levelNode) { Board board = new Board(); board.LevelName = levelNode.Attributes["Name"].Value; int rowNumber = 0; foreach (XmlNode rowNode in levelNode.SelectNodes("row")) { string rowData = rowNode.Attributes["data"].Value; int colNumber = 0; foreach (char cellData in rowData.ToCharArray()) { switch ( cellData ) { case '$': board.AddBlock( new HeartBlock() { Y = rowNumber, X = colNumber } ); break; case '@': board.AddBlock( new BallBlock() { Y = rowNumber, X = colNumber } ); break; case '.': board.AddBlock( new SnowBlock() { Y = rowNumber, X = colNumber } ); break; case '*': board.AddBlock( new PlayerBlock() { Y = rowNumber, X = colNumber } ); break; case '!': board.AddBlock( new ExitBlock() { Y = rowNumber, X = colNumber } ); break; case 'B': board.AddBlock( new BombBlock() { Y = rowNumber, X = colNumber } ); break; case '%': board.AddBlock( new WallBlock() { Y = rowNumber, X = colNumber } ); break; } colNumber++; } rowNumber++; } return board; }
private void LoadBoard() { Levels.Instance.Reset(); board = Levels.Instance.TheLevels.ElementAt(CurrentLevelNumber); }