example:
level1.txt level2.txt level3.txt
,,,,,,,,,,
,,,,,,,,,,
,,,,,,,,,,
,,,,,,P,,,
,,,,,,,,,,
,,,,,,,,,,
,,,,,~~~,,
,,,,,,,,,,
,,,,,,,,,,
~~~~~~~~~~
private Tile LoadTile(char tileType, int x, int y)
{
switch (tileType)
{
// Blank space
case ',':
//return new Tile(null, TileCollision.Passable);
// Don't need to do anything.
return null;
// Exit
case 'X':
case 'Y':
case 'Z':
string levelCode = this.mappings[tileType.ToString()];
this.LoadExit(x, y, tileType, levelCode);
return null;
// Gem
case 'G':
if (this.LevelType == Game.LevelType.ForestLevel)
{
this.LoadGem(x, y, GemType.GoldNugget);
}
else
{
this.LoadGem(x, y, GemType.Normal);
}
return null;
// Powerup gem
case 'P':
this.LoadGem(x, y, GemType.PowerUp);
return null;
// Poison gem
case 'Q':
this.LoadGem(x, y, GemType.Ablaze);
return null;
// Floating platform
case '-':
return this.LoadTile(TileType.Platform, x, y);
case 'U':
this.LoadPipe(x, y);
return null;
// Various enemies
case 'A':
this.LoadEnemy(x, y, EnemyType.MonsterA, 1f);
return null;
case 'B':
this.LoadEnemy(x, y, EnemyType.MonsterB, 1f);
return null;
case 'C':
this.LoadEnemy(x, y, EnemyType.MonsterC, 1f);
return null;
case 'D':
this.LoadEnemy(x, y, EnemyType.MonsterD, 1f);
return null;
// Mini enemies.
case 'a':
this.LoadEnemy(x, y, EnemyType.MonsterA, 0.5f);
return null;
case 'b':
this.LoadEnemy(x, y, EnemyType.MonsterB, 0.5f);
return null;
case 'c':
this.LoadEnemy(x, y, EnemyType.MonsterC, 0.5f);
return null;
case 'd':
this.LoadEnemy(x, y, EnemyType.MonsterD, 0.5f);
return null;
case 'K':
this.LoadBoss(x, y, BossSprite.BossType.KingBaddie);
return null;
case 'L':
this.LoadBoss(x, y, BossSprite.BossType.GhostBaddie);
return null;
case 'M':
this.LoadBoss(x, y, BossSprite.BossType.DeerBoss);
return null;
// Platform block
case '~':
return this.LoadTile(TileType.BlockB, x, y); //("BlockB", 2, TileCollision.Platform);
//// Passable block
//case ':':
// return this.LoadTile(TileType.BlockB, x, y); //LoadVarietyTile("BlockB", 2, TileCollision.Passable);
// Player 1 start point
case '1':
this.LoadStart(x, y, PlayerType.Esko, this.mainPlayerIndex);
return null;
case '2':
// Only add Glaci if the second player has already entered the game.
if (GameplayScreen.IsPlayerTwoActive)
{
this.LoadStart(x, y, PlayerType.Glaci, GameplayScreen.PlayerTwoControllerIndex.Value);
}
else
{
this.glaciePosition = new Vector2(x, y);
}
this.isMoreFreezeEverything = true;
return null;
case '3':
this.LoadStart(x, y, PlayerType.Fernie, this.mainPlayerIndex);
return null;
// Impassable block
case '#':
return this.LoadTile(TileType.BlockA, x, y); //LoadVarietyTile("BlockA", 7, TileCollision.Impassable);
// Unknown tile type character
default:
throw new NotSupportedException(string.Format("Unsupported tile type character '{0}' at position {1}, {2}.", tileType, x, y));
}
}
I’m more hung up on the getting of the .txt file, getting the strings into a switch, and then next level transition than the actual x and y and prefabs and other parts of the level build just making note.