public void Start() { Console.WriteLine("Welcome to my shadow game {0}", Console.ForegroundColor); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(" /^\\/^\\"); Console.WriteLine(" _|__| O|"); Console.WriteLine("\\/ /~ \\_/ \\"); Console.WriteLine(" \\____|__________/ \\"); Console.WriteLine(" \\_______ \\"); Console.WriteLine(" `\\ \\ \\"); Console.WriteLine(" | | \\"); Console.WriteLine(" / / \\"); Console.WriteLine(" / / \\\\"); Console.WriteLine(" / / \\ \\"); Console.WriteLine(" / / \\ \\"); Console.WriteLine(" / / _----_ \\ \\"); Console.WriteLine(" / / _-~ ~-_ | |"); Console.WriteLine(" ( ( _-~ _--_ ~-_ _/ |"); Console.WriteLine(" \\ ~-____-~ _-~ ~-_ ~-_-~ /"); Console.WriteLine(" ~-_ _-~ ~-_ _-~"); Console.WriteLine(" ~--______-~ ~-___-~"); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); Console.Clear(); Help(); Console.ReadKey(); Console.Clear(); //SelectCharacter(); Console.ReadKey(); Console.Clear(); //SelectCharacter(); //Load Map OtherWise Generate a new map if (!LoadMap()) { MapTile[,] TempMap = new MapTile[mapLength, mapWidth]; for (int i = 0; i < mapLength; i++) { for (int j = 0; j < mapWidth; j++) { if (i == player.PlayerY && j == player.PlayerY) { TempMap[i, j] = player; } else { TempMap[i, j] = GenTile(); } } } map = TempMap; } //Intial Draw //=========================================== //bool test = false; //float a = 0.05f; //int b = Convert.ToInt32(test); //Character testCharacter = playerPartner; //Wizard testWizard = null; //if(testCharacter is Wizard) //{ // // testWizard = (Wizard)testCharacter; // //} //if(testWizard != null) //{ // testWizard.TestFunc(); //} //((Wizard)testCharacter).TestFunc(); or Wizard testWizard = (Wizard)testCharacter; }
public bool LoadMap() { //Check If File Exists if (File.Exists("SaveData.txt")) { //Create Reader to path StreamReader reader = File.OpenText("SaveData.txt"); //Read Map Width and length mapLength = Convert.ToInt32(reader.ReadLine()); mapWidth = Convert.ToInt32(reader.ReadLine()); //Temporary map to load into MapTile[,] TempMap = new MapTile[mapLength, mapWidth]; //Skip White Space reader.ReadLine(); //Iterate Through Map Reading Each Character for (int i = 0; i < mapLength - 1; i++) { //save this row as string string LoadedRow; LoadedRow = reader.ReadLine(); //Convert Loaded Row Into a Character array // || // \/ // Problem char[] LoadedTiles = LoadedRow.ToCharArray(); if (i >= 0 && i < LoadedTiles.Length) { Console.WriteLine(LoadedTiles[i]); } //Go through the row Checking the character and loading in the Corrisponding Tile for (int j = 0; j < mapWidth - 1; j++) { //Set maps player to this new Temporary Player if (LoadedTiles[j] == 'P') { Player tempPlayer = new Player(); tempPlayer.PlayerY = j; tempPlayer.PlayerX = i; player = tempPlayer; TempMap[i, j] = player; } else if (LoadedTiles[j] == '-') { TempMap[i, j] = new MapTile(); } else if (LoadedTiles[j] == 'M') { TempMap[i, j] = new Monster(); } else if (LoadedTiles[j] == 'S') { TempMap[i, j] = new Shop(); } else { TempMap[i, j] = new MapTile(); } } } Console.WriteLine("Save loaded!"); //Close Reader reader.Close(); //Set Map to the map we just loaded map = TempMap; return(true); } //No Save File was Found else { Console.WriteLine("No save Found"); Console.ReadKey(); return(false); } }