I've started writing a tile based game in XNA today using the tutorials here. I'm on the Part 6 - Side Topic - Auto Transitions at the moment. My transitions aren't working correctly as you can see below:

When moving around, several of the tiles don't transitions correctly and stay as the default square, you can see this happening with the 2 bottom right 'water' tiles, they're not transitioning with the 'dark grass' tiles.
Here's the class that does the transitioning:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WindowsGame1 { class TileMap { public List<MapRow> Rows = new List<MapRow>(); public int MapWidth = 32; public int MapHeight = 32; public TileMap() { for (int y = 0; y < MapHeight; y++) { MapRow thisRow = new MapRow(); for (int x = 0; x < MapWidth; x++) { thisRow.Columns.Add(new MapCell(64)); } Rows.Add(thisRow); } Rows[0].Columns[3].TileID = 96; Rows[0].Columns[4].TileID = 96; Rows[0].Columns[5].TileID = 32; Rows[0].Columns[6].TileID = 32; Rows[0].Columns[7].TileID = 32; Rows[1].Columns[3].TileID = 96; Rows[1].Columns[4].TileID = 32; Rows[1].Columns[5].TileID = 32; Rows[1].Columns[6].TileID = 32; Rows[1].Columns[7].TileID = 32; Rows[2].Columns[2].TileID = 96; Rows[2].Columns[3].TileID = 32; Rows[2].Columns[4].TileID = 32; Rows[2].Columns[5].TileID = 32; Rows[2].Columns[6].TileID = 32; Rows[2].Columns[7].TileID = 32; Rows[3].Columns[2].TileID = 96; Rows[3].Columns[3].TileID = 32; Rows[3].Columns[4].TileID = 32; Rows[3].Columns[5].TileID = 0; Rows[3].Columns[6].TileID = 0; Rows[3].Columns[7].TileID = 0; Rows[4].Columns[2].TileID = 96; Rows[4].Columns[3].TileID = 32; Rows[4].Columns[4].TileID = 32; Rows[4].Columns[5].TileID = 0; Rows[4].Columns[6].TileID = 0; Rows[4].Columns[7].TileID = 0; Rows[5].Columns[2].TileID = 96; Rows[5].Columns[3].TileID = 32; Rows[5].Columns[4].TileID = 32; Rows[5].Columns[5].TileID = 0; Rows[5].Columns[6].TileID = 0; Rows[5].Columns[7].TileID = 0; doAutoTransition(); } private void doAutoTransition() { for (int y = 0; y < MapHeight; y++) { for (int x = 0; x < MapWidth; x++) { int height = getBaseTile(y, x); int start = GetTileBaseHeight(height) + 1; for (int i = start; i < 4; i++) { int tileID = CalculateTransistionTileEdge(y, x, i); if (tileID > -1) { Rows[y].Columns[x].AddBaseTile(i * 32 + tileID); } tileID = CalculateTransistionTileCorner(y, x, i); if (tileID > -1) { Rows[y].Columns[x].AddBaseTile(i * 32 + 16 + tileID); } } } } } private int GetTileBaseHeight(int tileID) { return tileID / 32; } private int getBaseTile(int y, int x) { if (x < 0 || y < 0 || x >= MapWidth || y >= MapHeight) { return 0; } return Rows[y].Columns[x].TileID; } private int CalculateTransistionTileEdge(int y, int x, int iHeight) { int temp = 0; if (GetTileBaseHeight(getBaseTile(y, x - 1)) == iHeight) { //Left temp += 1; } if (GetTileBaseHeight(getBaseTile(y - 1, x)) == iHeight) { //Top temp += 2; } if (GetTileBaseHeight(getBaseTile(y, x + 1)) == iHeight) { //Right temp += 4; } if (GetTileBaseHeight(getBaseTile(y + 1, x)) == iHeight) { //bottom temp += 8; } if (temp > 0) { return temp; } return -1; } private int CalculateTransistionTileCorner(int y, int x, int iHeight) { int temp = 0; if (GetTileBaseHeight(getBaseTile(y - 1, x - 1)) == iHeight) { //Left top temp += 1; } if (GetTileBaseHeight(getBaseTile(y - 1, x + 1)) == iHeight) { //Top right temp += 2; } if (GetTileBaseHeight(getBaseTile(y + 1, x + 1)) == iHeight) { //Bottem Right temp += 4; } if (GetTileBaseHeight(getBaseTile(y + 1, x - 1)) == iHeight) { //Bottom left temp += 8; } if (temp > 0) { return temp; } return -1; } } class MapRow { public List<MapCell> Columns = new List<MapCell>(); } }