//this is the create method, the reason i call it create tile instead of create() is because it was easier for me to understand when using it private Tile CreateTile(TileType tiletype) { int randomX = roll.Next(0, WidthOfGameMap); int randomY = roll.Next(0, HeightOfGameMap); while (gameMap[randomX, randomY] is Obstacle || gameMap[randomX, randomY] is character || gameMap[randomX, randomY] is ItemClass) { randomX = roll.Next(0, WidthOfGameMap); randomY = roll.Next(0, HeightOfGameMap); } if (tiletype == TileType.Hero) { playerCharacter = new HeroClass(randomX, randomY, 100);//player hp assigned here! return(playerCharacter); } else if (tiletype == TileType.Enemy) { int temp = roll.Next(1, 3); if (temp == 1) { return(new GoblinClass(randomX, randomY)); } else { return(new MageClass(randomX, randomY)); } } //this spawns the gold with the game else { return(new GoldClass(randomX, randomY)); } }
private Tile CreateTile(TileType tiletype) { int randomisePositionX = roll.Next(0, WidthOfGameMap); int randomisePositionY = roll.Next(0, HeightOfGameMap); while (gameMap[randomisePositionX, randomisePositionY] is Obstacle || gameMap[randomisePositionX, randomisePositionY] is character) { randomisePositionX = roll.Next(0, WidthOfGameMap); randomisePositionY = roll.Next(0, HeightOfGameMap); } if (tiletype == TileType.Hero) { playerCharacter = new HeroClass(randomisePositionX, randomisePositionY, 20);//player hp assigned here! return(playerCharacter); } else { return(new GoblinClass(randomisePositionX, randomisePositionY)); } }