Reading Binary Tile Map Data on Windows Phone
The problem I ran into when trying to create a Tile Mapping engine was reading data on Windows Phone. Windows Phone will not allow the below namespace so I had to go another route.
using System.Runtime.Serialization.Formatters.Binary;
Windows Phone has a class called TileContainer which allows access to the Phone's Content area.
try
{
Stream path = TitleContainer.OpenStream("Content/Maps/" + map);
using (BinaryReader br = new BinaryReader(path))
{
for (int x = 0; x < MapWidth; x++)
{
for (int y = 0; y < MapHeight; y++)
{
mapCells[x, y] = new MapSquare(
br.ReadInt32(), // Background Layer
br.ReadInt32(), // Interactive Layer
br.ReadInt32(), // Foreground Layer
br.ReadString(), // CodeValue
br.ReadBoolean()); // Passable
}
}
}