private static void Main(string[] args)
        {
            Type t = Type.GetType("Mono.Runtime");
            if (t != null)
                isMono = true;
            else
                isMono = false;
            if (!isMono)
            {
                Console.WriteLine("You are not using Mono, assuming you are using Microsoft.NET...");
            }
            else {
                Console.WriteLine("You are using Mono.");
            }
            if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
            }
            //Pre-emptivley grab time for the writing of log file
            LogTime = string.Format(@"Log {0}.log", DateTime.Now.ToString("MM-dd-yyyy h.mm"));
            //Assign values to thread objects
            LogThreadStart = new ThreadStart(LogThread);
            LogThreadObj = new Thread(LogThreadStart);
            TitleThreadStart = new ThreadStart(TitleThread);
            TitleThreadObj = new Thread(TitleThreadStart);
            EntGenTreadStart = new ThreadStart(EntGenThread);
            EntGenThreadObj = new Thread(EntGenTreadStart);
            //Checks for logging directory
            if (!Directory.Exists(LogDir))
            {
                Directory.CreateDirectory(LogDir);
            }
            //Starts logging thread to ensure that data exists for debugging
            LogThreadObj.Start();
            Log("Logging thread started!");
            if (!isMono)
            {
                Log("Not running on Mono, assuming settings used for Microsoft.NET");
            }
            else {
                Log("Running on Mono, disabling Windows-only methods");
            }
            //Checks for the data storage directory, if it does not exist, it is created
            Log("Checking for data directory");
            if (!Directory.Exists(DataDirPath))
            {
                Log("Data directory not found, creating it now...");
                Directory.CreateDirectory(DataDirPath);
            }
            Inventory[ItemType.Weapon] = new List<ItemStats>();
            Inventory[ItemType.AbilityWeapon] = new List<ItemStats>();
            Inventory[ItemType.MedItem] = new List<ItemStats>();
            //Title sequence
            Log("Running title sequence");
            TitleThreadObj.Start();
            while (!TitleKP)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("GenRPG");
                Console.ForegroundColor = ConsoleColor.Red;
                if (Stable)
                {
                    Console.Write("STABLE");
                }
                else if (Debug)
                {
                    Console.Write("DEBUG MODE ENABLED");
                }
                else
                {
                    Console.Write("UNSTABLE");
                }
                Console.ForegroundColor = ConsoleColor.Green;
                if (isMono)
                {
                    Console.Write("Mono");
                }
                else {
                    Console.Write(".NET Framework");
                }
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("RGenSTUDIOS");
                Thread.Sleep(12);
            }
#if !LAUNCHERBUILD
            if (FlushData)
            {
                Console.Clear();
                //Deletes the temporary data directory
                Directory.Delete(DataDirPath, true);
                Console.WriteLine("Data files flushed!");
                Console.ReadKey();
                goto Exit;
            }
#endif
            InitializeWeaponsDirectory();
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("GENRPG");
            Console.WriteLine("VERSION {0}", typeof(Program).Assembly.GetName().Version);
            if (Debug)
            {
                Console.WriteLine("WeaponsList.conf Revision: {0}", GRevDateWeapons);
                Console.WriteLine("WeaponsList.conf new (this session only)?: {0}", NewWeaponConf.ToString());
                Console.WriteLine("ClassList.conf Revision: {0}", GRevDateClass);
                Console.WriteLine("ClassList.conf new (this session only)?: {0}", NewClassConf.ToString());
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey(true);
            Console.Clear();
            //Ask for the name of the charater being created
            Console.WriteLine("Enter your character's name:");
        DeclineName:
            StrIn = Console.ReadLine();
            //Confirms the name, the player can chage their mind and re-enter the name
            Console.WriteLine("Your character's name will be: {0}? (y,n)", StrIn);
        InvalidKey_nameentry:
            switch (Console.ReadKey(true).KeyChar)
            {
                case 'y':
                    {
                        Log("Character name confirmed");
                        Console.WriteLine("Character name is {0}", StrIn);
                        CharName = StrIn;
                        break;
                    }
                case 'n':
                    {
                        Log("Character name declined, asking again");
                        Console.WriteLine("Name declined by user, enter a new name:");
                        goto DeclineName;
                    }
                case 'd':
                    {
                        Log("Character name set to default");
                        Console.WriteLine("Character name is Flo from Progressive");
                        CharName = "Flo from Progressive";
                        break;
                    }
                default:
                    {
                        goto InvalidKey_nameentry;
                    }
            }
            Thread.Sleep(1200);
            Console.Clear();
            //Asks the player to enter the desired gender for the in-game character
            Console.WriteLine("What is your character's gender? (m (Male), f (Female), r (Random))");
        InvalidKey_genderentry:
            switch (Console.ReadKey(true).KeyChar)
            {
                case 'm':
                    {
                        CharGender = Gender.Male;
                        Log("Character gender set to male");
                        Console.WriteLine("Character gender set to male!");
                        Thread.Sleep(1000);
                        break;
                    }
                case 'f':
                    {
                        CharGender = Gender.Female;
                        Log("Character gender set to female!");
                        Console.WriteLine("Character gender set to female!");
                        Thread.Sleep(1000);
                        break;
                    }
                case 'r':
                    {
                    IncorrectRand:
                        switch (GenRand.Next(0, 3))
                        {
                            case 1:
                                CharGender = Gender.Male;
                                Log("Character gender set to male");
                                Console.WriteLine("Character gender set to male!");
                                Thread.Sleep(1000);
                                break;

                            case 2:
                                CharGender = Gender.Female;
                                Log("Character gender set to female!");
                                Console.WriteLine("Character gender set to female!");
                                Thread.Sleep(1000);
                                break;

                            default:
                                goto IncorrectRand;
                        }
                        break;
                    }
                default:
                    {
                        goto InvalidKey_genderentry;
                    }
            }
        //Asks the player what they they would like to play
        RechooseClass:
            Console.Clear();
            Console.WriteLine("Assign your character a class (press the key correspoding to an option below):");
            Console.WriteLine("1. Mage");
            Console.WriteLine("2. Gunner");
            Console.WriteLine("3. Fighter");
            Console.WriteLine("4. Swordsman");
            Console.WriteLine("5. Marksman");
            Console.WriteLine("6. Paladin");
            Console.WriteLine("7. Healer");
            Console.WriteLine("8. Assassin");
            Console.WriteLine("9. Robot");
        WrongKeyClass:
            switch (Console.ReadKey(true).KeyChar)
            {
                case '1':
                    {
                        Console.WriteLine("An intelligent wizard that uses powerful magic as a weapon. \nYour weapon is a crystal staff laced with powerful magic.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Mage;
                                CharStats = GetClassStats(Class.Mage);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[0])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }
                        break;
                    }
                case '2':
                    {
                        Console.WriteLine("A strong-willed hero that uses guns to obliterate enemies. \nYour weapon is a 20 mm caliber pistol with the power of infinte ammo.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Gunner;
                                CharStats = GetClassStats(Class.Gunner);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[1])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }

                        break;
                    }
                case '3':
                    {
                        Console.WriteLine("An uncontrollable boxer that uses his fists as a powerful source of damage. \nYour weapons are steel gloves, the strongest you've ever had.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Fighter;
                                CharStats = GetClassStats(Class.Fighter);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[2])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }

                        break;
                    }
                case '4':
                    {
                        Console.WriteLine("A muscular person that wields a sharp sword to slash at enemies. \nYour weapon is a strong metal sword crafted with the thoughts of murder in mind.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Swordsman;
                                CharStats = GetClassStats(Class.Swordsman);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[3])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }

                        break;
                    }
                case '5':
                    {
                        Console.WriteLine("A skilled marksman that has exact aim (kind of) and a powerful weapon. \nYour weapon is a hand-crafted birchwood bow with sharp, metal arrows.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Marksman;
                                CharStats = GetClassStats(Class.Marksman);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[4])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }

                        break;
                    }
                case '6':
                    {
                        Console.WriteLine("A defensive tanky class that uses a rusty sword and mighty shield. \nYour weapon is a dull sword, but your shield is the best part of your kit. It blocks most incoming damage with its powerful metal base.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Paladin;
                                CharStats = GetClassStats(Class.Paladin);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[10])));
                                Inventory[ItemType.AbilityWeapon].Add(new ItemStats((WeaponsDir[5])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }

                        break;
                    }
                case '7':
                    {
                        Console.WriteLine("A doctor that has a Ph. D in heal. \nYour weapon is a infected needle. You also have a Medkit to heal yourself with.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Healer;
                                CharStats = GetClassStats(Class.Healer);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[6])));
                                Inventory[ItemType.AbilityWeapon].Add(new ItemStats((WeaponsDir[7])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }

                        break;
                    }
                case '8':
                    {
                        Console.WriteLine("A stealthy class that uses shivs and knives to surprise-attack people. \nYour weapon is a shiv that is crafted to have a high critical strike chance.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Assassin;
                                CharStats = GetClassStats(Class.Assassin);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[8])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }

                        break;
                    }
                case '9':
                    {
                        Console.WriteLine("An 'intelligent' (artificial, of course) man-made device that blasts enemies \nwith powerful lasers. \nYour weapon is an extention containing information about how to use a powerful \nplasma laser.");
                        Console.WriteLine("Do you want to choose this class? (y,n)");
                    WrongKeyConf:
                        switch (Console.ReadKey(true).KeyChar)
                        {
                            case 'y':
                                CharClass = Class.Robot;
                                CharStats = GetClassStats(Class.Robot);
                                Inventory[ItemType.Weapon].Add(new ItemStats((WeaponsDir[9])));
                                break;

                            case 'n':
                                goto RechooseClass;
                            default:
                                goto WrongKeyConf;
                        }

                        break;
                    }
                default:
                    goto WrongKeyClass;
            }
            CharHP = CharStats.Health;
            CharStamina = CharStats.Stamina;
            //Preface
            EntGenThreadObj.Start();
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("Instructions:");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Use WASD to move");
            Console.WriteLine("Enter C to use the command console");
            Console.WriteLine("Enter i to use inventory");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Press any key to start!");
            Console.ForegroundColor = ConsoleColor.White;
            Console.ReadKey(true);
            //Below: original story, as the text is not properly formatted, etc., it is being (at least temporarily) retired
            /*
            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();
            Console.WriteLine("CHAPTER I: IN A LARD OF GREEN");
            Console.WriteLine("Preface:");
            Console.WriteLine("This chapter is located in the land of Ironcrest, a land that you have lived in all your life. Being an orphan (your parents were killed by the shadows of Zerion, a soul-eating demon who uses shadows as an army. His army of shadows controls 90% of the known planet, and these shadows are occupying your homeland. You have built a plucidium wall around your house, the only known material that can repel shadows), you must go on a quest to get revenge on Zerion for killing the only two people on the planet that you have ever loved. You've been trained by Master Milo, who taught you how to counter the arts of the shadow race. Master Milo was brutally murdered by Zerion, and it is up to you to defeat him, since you are the last known being in the universe that can counter shadows.\nYou, {0},\nmust journey to the depths of Gargon, a fiery wasteland that's full of shadows \nof all sizes, shapes, and brutality, where Zerion is wating for you...", CharName);
            Console.ReadKey(true);
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            */
            Console.Clear();
            Console.SetCursorPosition(0, 2);
            int WCount;
            WCount = Console.BufferWidth;
            while (WCount >= 0)
            {
                Console.Write('-');
                WCount--;
            }
            Console.SetCursorPosition(0, (FetchCoord(1).y - 1));
            WCount = Console.BufferWidth;
            while (WCount >= 0)
            {
                Console.Write('-');
                WCount--;
            }
            Console.SetCursorPosition(0, 1);
            Console.Write("{0}  LVL:{1}  Class:{2}", CharName, CharLevel, CharStats.ClassName);
            Console.SetCursorPosition(0, (FetchCoord(1).y));
            Console.Write("HP:{0}/{1}  Stamina:{2}/{3}", CharHP, CharStats.Health, CharStamina, CharStats.Stamina);
            while (!ExitGame)
            {
            SizeChange:
                if (PlaneList.ContainsKey(PMCoord))
                {
                    RWMap(PlaneList[PMCoord].HealthPacksUsed, PlaneList[PMCoord].isTown);
                }
                else {
                    NewMap();
                }
                if (SizeChange)
                {
                    PlayerCoords = new Coord((int)FetchCoord(1).x / 2, (int)FetchCoord(1).y / 2);
                    OldPlayerCoords = new Coord((int)(FetchCoord(1).x / 2) + 1, (int)(FetchCoord(1).y / 2) + 1);
                }
                if (PlaneList[PMCoord].isTown || (PMCoord.x == 0) & (PMCoord.y == 0))
                {
                EndActionTown:
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.SetCursorPosition(0, 1);
                    WCount = Console.BufferWidth;
                    while (WCount >= 0)
                    {
                        Console.Write('-');
                        WCount--;
                    }
                    Console.SetCursorPosition(0, (FetchCoord(1).y - 1));
                    WCount = Console.BufferWidth;
                    while (WCount >= 0)
                    {
                        Console.Write('-');
                        WCount--;
                    }
                    Console.SetCursorPosition(0, 0);
                    Console.Write("{0}  LVL:{1}  Class:{2}", CharName, CharLevel, CharStats.ClassName);
                    Console.SetCursorPosition(0, (FetchCoord(1).y));
                    Console.Write("HP:{0}/{1}  Stamina:{2}/{3}", CharHP, CharStats.Health, CharStamina, CharStats.Stamina);
                    Console.SetCursorPosition(0, 2);
                    Console.WriteLine("You have reached a place of civilization, not yet touched by darkness...");
                    Console.WriteLine("What would you like to do here?");
                    Console.WriteLine("1. Rest in an inn...");
                    Console.WriteLine("2. Leave the town");
                WrongKeyTown:
                    switch (Console.ReadKey(true).Key)
                    {
                        case ConsoleKey.D1:
                            CharHP = CharStats.Health;
                            CharStamina = CharStats.Stamina;
                            Console.WriteLine("You feel well rested, your health and stamina have been restored to full");
                            Console.ReadKey(true);
                            goto EndActionTown;
                        case ConsoleKey.D2:
                            Console.Clear();
                            Console.WriteLine("Press the arrow key corresponding to the driection you want to go...");
                            switch (Console.ReadKey(true).Key)
                            {
                                case ConsoleKey.UpArrow:
                                    PMCoord.y++;
                                    break;

                                case ConsoleKey.DownArrow:
                                    PMCoord.y--;
                                    break;

                                case ConsoleKey.LeftArrow:
                                    PMCoord.x++;
                                    break;

                                case ConsoleKey.RightArrow:
                                    PMCoord.x--;
                                    break;

                                case ConsoleKey.W:
                                    PMCoord.y++;
                                    break;

                                case ConsoleKey.S:
                                    PMCoord.y--;
                                    break;

                                case ConsoleKey.D:
                                    PMCoord.x++;
                                    break;

                                case ConsoleKey.A:
                                    PMCoord.x--;
                                    break;
                            }
                            Console.Clear();
                            break;

                        case ConsoleKey.Escape:
                            ExitGame = true;
                            goto Exit;
                        default:
                            goto WrongKeyTown;
                    }
                    LoadingMap = true;
                }
                else {
                    do
                    {
                    StartMov:
                        Console.Clear();
                        if (PlaneList[PMCoord].Size.x != Console.BufferWidth || PlaneList[PMCoord].Size.y != Console.BufferHeight)
                        {
                            PlaneList.Remove(PMCoord);
                            Console.SetCursorPosition(0, 0);
                            Console.WriteLine("Window size changed, generating new map");
                            Log("Window size changed, generating new map");
                            Thread.Sleep(1000);
                            SizeChange = true;
                            goto SizeChange;
                        }
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.SetCursorPosition(0, 1);
                        WCount = Console.BufferWidth;
                        while (WCount >= 0)
                        {
                            Console.Write('-');
                            WCount--;
                        }
                        Console.SetCursorPosition(0, (FetchCoord(1).y - 1));
                        WCount = Console.BufferWidth;
                        while (WCount >= 0)
                        {
                            Console.Write('-');
                            WCount--;
                        }
                        Console.SetCursorPosition(0, 0);
                        Console.Write("{0}  LVL:{1}  Class:{2}     LOCATION:{3},{4}", CharName, CharLevel, CharStats.ClassName, PMCoord.x, PMCoord.y);
                        Console.SetCursorPosition(0, (FetchCoord(1).y));
                        Console.Write("HP:{0}/{1}  Stamina:{2}/{3}", CharHP, CharStats.Health, CharStamina, CharStats.Stamina);
                        if (BATTLE == true)
                        {
                            Log("The player has entered a battle");
                            bool Special = false;
                            if (Inventory[ItemType.AbilityWeapon].Count > 0)
                            {
                                Special = true;
                            }
                            int RD = 0;
                            bool Flee = false;
                            int Cooldown = 0;
                            while (((CharHP > 0) && (EnemyHP > 0)) && (!Flee))
                            {
                            SpecUsed:
                                Console.Clear();
                                Console.SetCursorPosition(0, 1);
                                WCount = Console.BufferWidth;
                                while (WCount >= 0)
                                {
                                    Console.Write('-');
                                    WCount--;
                                }
                                Console.SetCursorPosition(0, FetchCoord(1).y - 1);
                                WCount = Console.BufferWidth;
                                while (WCount >= 0)
                                {
                                    Console.Write('-');
                                    WCount--;
                                }
                                Console.SetCursorPosition(0, 0);
                                Console.Write("{0}    HP:{1}/{2}  Stamina:{3}/{4}", CharName, CharHP, CharStats.Health, CharStamina, CharStats.Stamina);
                                Console.SetCursorPosition(0, FetchCoord(1).y);
                                Console.Write("ENEMY    HP:{0}/{1}  Stamina{2}/{3}", EnemyHP, EnemyStats.Health, EnemyStamina, EnemyStats.Stamina);
                                Console.SetCursorPosition(0, 2);
                                Console.WriteLine("You are met with a fearsome foe...");
                                Console.WriteLine("What will you do?");
                                Console.WriteLine("1. ATTACK!");
                                foreach (ItemStats Weapon in Inventory[ItemType.Weapon])
                                {
                                    if ((Weapon.WeaponStat.ID == 6) | (Weapon.WeaponStat.ID == 8))
                                    {
                                        Special = true;
                                    }
                                }
                                Console.SetCursorPosition(0, 5);
                                if (Special == true)
                                {
                                    Console.Write("2. Use Special Abitity({0})", Cooldown);
                                    Console.SetCursorPosition(0, 6);
                                    Console.Write("3. Flee");
                                }
                                else {
                                    Console.Write("2. Flee");
                                }
                            WrongKeyBattle:
                                switch (Console.ReadKey(true).Key)
                                {
                                    case ConsoleKey.D1:
                                        int InvNum = 0;
                                        int count = 0;
                                        Console.Clear();
                                        Console.SetCursorPosition(0, 1);
                                        WCount = Console.BufferWidth;
                                        while (WCount >= 0)
                                        {
                                            Console.Write('-');
                                            WCount--;
                                        }
                                        Console.SetCursorPosition(0, FetchCoord(1).y - 1);
                                        WCount = Console.BufferWidth;
                                        while (WCount >= 0)
                                        {
                                            Console.Write('-');
                                            WCount--;
                                        }
                                        Console.SetCursorPosition(0, 0);
                                        Console.Write("{0}    HP:{1}/{2}  Stamina:{3}/{4}", CharName, CharHP, CharStats.Health, CharStamina, CharStats.Stamina);
                                        Console.SetCursorPosition(0, FetchCoord(1).y);
                                        Console.Write("ENEMY    HP:{0}/{1}  Stamina{2}/{3}", EnemyHP, EnemyStats.Health, EnemyStamina, EnemyStats.Stamina);
                                        Console.SetCursorPosition(0, 2);
                                        foreach (ItemStats Weapon in Inventory[ItemType.Weapon])
                                        {
                                            Console.WriteLine("{0}: {1}", (count + 1), Weapon.WeaponStat.ItemName);
                                            count++;
                                        }
                                    InvalidWeaponChoice:
                                        try
                                        {
                                            InvNum = Convert.ToInt32(Console.ReadLine()) - 1;
                                        }
                                        catch
                                        {
                                            Console.WriteLine("Invalid value (you probably didn't enter a number)");
                                            goto InvalidWeaponChoice;
                                        }
                                        if (InvNum > Inventory[ItemType.Weapon].Count)
                                        {
                                            Console.WriteLine("Invalid value (you entered a greater number than available weapons)");
                                            goto InvalidWeaponChoice;
                                        }
                                        try
                                        {
                                            if (CharStamina <= 0)
                                            {
                                                if (GenRand.Next(99) <= Inventory[ItemType.Weapon][InvNum].WeaponStat.CritChance)
                                                    EnemyHP -= GenRand.Next((int)((Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage) * 1.10), (int)(CharStats.Damage * 1.10)) / 10 / 4;
                                                EnemyHP -= GenRand.Next((int)(Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage), CharStats.Damage) / 10 / 4;
                                            }
                                            else {
                                                if (GenRand.Next(99) <= Inventory[ItemType.Weapon][InvNum].WeaponStat.CritChance)
                                                    EnemyHP -= GenRand.Next((int)((Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage) * 1.10), (int)(CharStats.Damage * 1.10)) / 10;
                                                EnemyHP -= GenRand.Next((int)(Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage), CharStats.Damage) / 10;
                                            }
                                            if (GenRand.Next(99) <= Inventory[ItemType.Weapon][InvNum].WeaponStat.CritChance)
                                                EnemyHP -= GenRand.Next((int)((Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage) * 1.10), (int)(CharStats.Damage * 1.10)) / 10;
                                            EnemyHP -= GenRand.Next((int)(Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage), CharStats.Damage) / 10;
                                        }
                                        catch
                                        {
                                            if (CharStamina <= 0)
                                            {
                                                if (GenRand.Next(99) <= Inventory[ItemType.Weapon][InvNum].WeaponStat.CritChance)
                                                    EnemyHP -= GenRand.Next((int)(CharStats.Damage * 1.10), (int)((Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage) * 1.10)) / 10 / 4;
                                                EnemyHP -= GenRand.Next(CharStats.Damage, (int)(Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage)) / 10 / 4;
                                            }
                                            else {
                                                if (GenRand.Next(99) <= Inventory[ItemType.Weapon][InvNum].WeaponStat.CritChance)
                                                    EnemyHP -= GenRand.Next((int)(CharStats.Damage * 1.10), (int)((Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage) * 1.10)) / 10;
                                                EnemyHP -= GenRand.Next(CharStats.Damage, (int)(Inventory[ItemType.Weapon][InvNum].WeaponStat.MDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.PDamage + Inventory[ItemType.Weapon][InvNum].WeaponStat.RDamage)) / 10;
                                            }
                                        }
                                        int StamLoss = GenRand.Next(0, 10);
                                        if (CharStamina - StamLoss <= 0)
                                        {
                                            CharStamina = 0;
                                        }
                                        else {
                                            CharStamina -= StamLoss;
                                        }
                                        break;

                                    case ConsoleKey.D2:
                                        if (Special && (Cooldown == 0))
                                        {
                                            int InvNumS = 0;
                                            int countS = 0;
                                            Console.Clear();
                                            Console.SetCursorPosition(0, 1);
                                            WCount = Console.BufferWidth;
                                            while (WCount >= 0)
                                            {
                                                Console.Write('-');
                                                WCount--;
                                            }
                                            Console.SetCursorPosition(0, FetchCoord(1).y - 1);
                                            WCount = Console.BufferWidth;
                                            while (WCount >= 0)
                                            {
                                                Console.Write('-');
                                                WCount--;
                                            }
                                            Console.SetCursorPosition(0, 0);
                                            Console.Write("{0}    HP:{1}/{2}  Stamina:{3}/{4}", CharName, CharHP, CharStats.Health, CharStamina, CharStats.Stamina);
                                            Console.SetCursorPosition(0, FetchCoord(1).y);
                                            Console.Write("ENEMY    HP:{0}/{1}  Stamina{2}/{3}", EnemyHP, EnemyStats.Health, EnemyStamina, EnemyStats.Stamina);
                                            Console.SetCursorPosition(0, 2);
                                            foreach (ItemStats Weapon in Inventory[ItemType.AbilityWeapon])
                                            {
                                                Console.WriteLine("{0}: {1}", (countS + 1), Weapon.WeaponStat.ItemName);
                                                countS++;
                                            }
                                        InvalidWeaponChoiceS:
                                            try
                                            {
                                                InvNum = Convert.ToInt32(Console.ReadLine()) - 1;
                                            }
                                            catch
                                            {
                                                Console.WriteLine("Invalid value (you probably didn't enter a number)");
                                                goto InvalidWeaponChoiceS;
                                            }
                                            if (InvNumS > Inventory[ItemType.AbilityWeapon].Count)
                                            {
                                                Console.WriteLine("Invalid value (you entered a greater number than available weapons)");
                                                goto InvalidWeaponChoice;
                                            }
                                            if (Inventory[ItemType.AbilityWeapon][InvNumS].WeaponStat.Type == WeaponType.Sheild)
                                            {
                                                RD = (int)Inventory[ItemType.AbilityWeapon][InvNumS].WeaponStat.BlockedDamage;
                                                Cooldown += (int)Inventory[ItemType.AbilityWeapon][InvNumS].WeaponStat.Cooldown;
                                            }
                                            goto SpecUsed;
                                        }
                                        else if (Special && (Cooldown != 0))
                                        {
                                            goto WrongKeyBattle;
                                        }
                                        else {
                                            Flee = true;
                                            continue;
                                        }
                                    case ConsoleKey.D3:
                                        Flee = true;
                                        continue;
                                    default:
                                        goto WrongKeyBattle;
                                }
                                if (RD != 0)
                                {
                                    CharHP -= GenRand.Next(EnemyStats.Damage - 25, EnemyStats.Damage + 25) / 10;
                                }
                                else {
                                    CharHP -= GenRand.Next(EnemyStats.Damage - 25, EnemyStats.Damage + 25) / (10 + RD);
                                    RD = 0;
                                }
                                if (Cooldown > 0)
                                {
                                    Cooldown--;
                                }
                            }
                            if (CharHP <= 0)
                            {
                                Console.Clear();
                                Console.WriteLine("YOU HAVE DIED...");
                                Console.WriteLine(":(");
                                Console.ReadKey(true);
                                BATTLE = false;
                                goto Exit;
                            }
                            if (Flee)
                            {
                                Console.Clear();
                                Console.WriteLine("You have fled the battle");
                                Console.WriteLine("Press any key to continue...");
                                Console.ReadKey(true);
                                BATTLE = false;
                                goto StartMov;
                            }
                            else if (EnemyHP <= 0)
                            {
                                Console.Clear();
                                Console.WriteLine("You have won the battle");
                                XP += GenRand.Next(30, 175);
                                if (XP >= CharLevel * 100)
                                {
                                    Console.WriteLine("You have leveled up!");
                                    XP = 0;
                                    CharLevel++;
                                    CharStats.Accuracy = (int)(CharStats.Accuracy * 1.10);
                                    CharStats.Agility = (int)(CharStats.Agility * 1.10);
                                    CharStats.Charisma = (int)(CharStats.Charisma * 1.10);
                                    CharStats.Damage = (int)(CharStats.Damage * 1.10);
                                    CharStats.Health = (int)(CharStats.Health * 1.10);
                                    CharStats.Intelligence = (int)(CharStats.Intelligence * 1.10);
                                    CharStats.MDefense = (int)(CharStats.MDefense * 1.10);
                                    CharStats.PDefense = (int)(CharStats.PDefense * 1.10);
                                    CharStats.RDefense = (int)(CharStats.RDefense * 1.10);
                                    CharStats.Stamina = (int)(CharStats.Stamina * 1.10);
                                }
                                Console.WriteLine("Press any key to continue...");
                                Console.ReadKey(true);
                                BATTLE = false;
                                goto StartMov;
                            }
                        }
                        if (LoadingMap == true)
                        {
                            while (!EntGenFin)
                            {
                                Thread.Sleep(100);
                            }
                            EntList = TempEntList;
                            EntGenFin = false;
                            LoadingMap = false;
                        }
                        foreach (SpecTile DrTile in PlaneList[PMCoord].SpecialTiles)
                        {
                            Console.ForegroundColor = DrTile.TileColor;
                            Console.SetCursorPosition(DrTile.Posistion.x, DrTile.Posistion.y);
                            Console.Write(DrTile.RepChar);
                        }
                        Console.ForegroundColor = ConsoleColor.Red;
                        for (var i = 0; i < EntList.Count; i++)
                        {
                            try
                            {
                                MoveToCoord(EntList[i].PrevEntCoord);
                                Console.Write(' ');
                                MoveToCoord(EntList[i].EntCoord);
                                Console.Write('#');
                                EntList[i].PrevEntCoord = EntList[i].EntCoord;
                            }
                            catch
                            {
                                i--;
                            }
                        }
                        Console.ForegroundColor = ConsoleColor.White;
                        MoveToCoord(OldPlayerCoords);
                        Console.Write(' ');
                        MoveToCoord(PlayerCoords);
                        Console.Write('@');
                        OldPlayerCoords = PlayerCoords;
                    WrongKey:
                        switch (Console.ReadKey(true).Key)
                        {
                            case ConsoleKey.W:
                                if (PlayerCoords.y != 2)
                                {
                                    PlayerCoords.y--;
                                }
                                else {
                                    PMCoord.y++;
                                    PlayerCoords = new Coord(PlayerCoords.x, FetchCoord(1).y - 2);
                                    LoadingMap = true;
                                }
                                break;

                            case ConsoleKey.S:
                                if (PlayerCoords.y != FetchCoord(1).y - 2)
                                {
                                    PlayerCoords.y++;
                                }
                                else {
                                    PMCoord.y--;
                                    PlayerCoords = new Coord(PlayerCoords.x, 2);
                                    LoadingMap = true;
                                }
                                break;

                            case ConsoleKey.D:
                                if (PlayerCoords.x != FetchCoord(1).x)
                                {
                                    PlayerCoords.x++;
                                }
                                else {
                                    PMCoord.x++;
                                    PlayerCoords = new Coord(0, PlayerCoords.y);
                                    LoadingMap = true;
                                }
                                break;

                            case ConsoleKey.A:
                                if (PlayerCoords.x != 0)
                                {
                                    PlayerCoords.x--;
                                }
                                else {
                                    PMCoord.x--;
                                    PlayerCoords = new Coord(FetchCoord(1).x, PlayerCoords.y);
                                    LoadingMap = true;
                                }
                                break;

                            case ConsoleKey.Escape:
                                ExitGame = true;
                                goto Exit;
                            default:
                                goto WrongKey;
                        }
                        for (var i = 0; i < EntList.Count; i++)
                        {
                            if ((EntList[i].EntCoord.x == PlayerCoords.x) && (EntList[i].EntCoord.y == PlayerCoords.y) && BATTLE != true)
                            {
                                BATTLE = true;
                                EnemyStats = EntList[i].EntStats;
                                EnemyHP = EnemyStats.Health;
                                EnemyStamina = EnemyStats.Stamina;
                                EntList[i].EntCoord = new Coord(GenRand.Next(0, FetchCoord(1).x), GenRand.Next(2, FetchCoord(1).y - 2));
                            }
                        }
                        foreach (EntInf Ent in EntList)
                        {
                        IVMoveEnt:
                            switch (GenRand.Next(0, 4))
                            {
                                case 0:
                                    if (Ent.EntCoord.y != 2)
                                        Ent.EntCoord.y--;
                                    else
                                        goto IVMoveEnt;
                                    break;

                                case 1:
                                    if (Ent.EntCoord.y != FetchCoord(1).y - 2)
                                        Ent.EntCoord.y++;
                                    else
                                        goto IVMoveEnt;
                                    break;

                                case 2:
                                    if (Ent.EntCoord.x != 0)
                                        Ent.EntCoord.x--;
                                    else
                                        goto IVMoveEnt;
                                    break;

                                case 3:
                                    if (Ent.EntCoord.x != FetchCoord(1).x)
                                        Ent.EntCoord.x++;
                                    else
                                        goto IVMoveEnt;
                                    break;

                                default:
                                    goto IVMoveEnt;
                            }
                        }
                        for (var i = 0; i < EntList.Count; i++)
                        {
                            if ((EntList[i].EntCoord.x == PlayerCoords.x) && (EntList[i].EntCoord.y == PlayerCoords.y) && BATTLE != true)
                            {
                                BATTLE = true;
                                EnemyStats = EntList[i].EntStats;
                                EnemyHP = EnemyStats.Health;
                                EnemyStamina = EnemyStats.Stamina;
                                EntList[i].EntCoord = new Coord(GenRand.Next(0, FetchCoord(1).x), GenRand.Next(2, FetchCoord(1).y - 2));
                            }
                        }
                        for (var i = 0; i < PlaneList[PMCoord].SpecialTiles.Count; i++)
                        {
                            if ((PlaneList[PMCoord].SpecialTiles[i].Posistion.x == PlayerCoords.x && PlaneList[PMCoord].SpecialTiles[i].Posistion.y == PlayerCoords.y) & (PlaneList[PMCoord].SpecialTiles[i].ID == 3))
                            {
                                if (((int)CharStats.Health / 3) + CharHP < CharStats.Health)
                                {
                                    CharHP += (int)CharStats.Health / 3;
                                }
                                else {
                                    CharHP = CharStats.Health;
                                }
                                if (((int)CharStats.Stamina / 3) + CharStamina < CharStats.Stamina)
                                {
                                    CharStamina += (int)CharStats.Stamina / 3;
                                }
                                else {
                                    CharStamina = CharStats.Stamina;
                                }
                                PlaneList[PMCoord].SpecialTiles.Remove(PlaneList[PMCoord].SpecialTiles[i]);
                                PlaneList[PMCoord].HealthPacksUsed++;
                            }
                        }
                    } while (LoadingMap == false);
                }
            }
        //End of program
        Exit:
            LogThreadObj.Abort();
            EntGenThreadObj.Abort();
            TitleThreadObj.Abort();
            return;
        }
 public EntInf(PlayerStats CPlStats)
 {
     EntCoord = new Coord(CompletelyRandom.Next(0, (FetchCoord(1).x)), CompletelyRandom.Next(2, (FetchCoord(1).y - 2)));
     EntStats = new PlayerStats("Enemy", CompletelyRandom.Next((CPlStats.Stamina - 50), (CPlStats.Stamina + 10)), CompletelyRandom.Next((CPlStats.Health - 50), (CPlStats.Health + 10)), CompletelyRandom.Next((CPlStats.Agility - 50), (CPlStats.Agility + 10)), CompletelyRandom.Next((CPlStats.Damage - 50), (CPlStats.Damage + 10)), CompletelyRandom.Next((CPlStats.Accuracy - 50), (CPlStats.Accuracy + 10)), CompletelyRandom.Next((CPlStats.PDefense - 50), (CPlStats.PDefense + 10)), CompletelyRandom.Next((CPlStats.RDefense - 50), (CPlStats.RDefense + 10)), CompletelyRandom.Next((CPlStats.MDefense - 50), (CPlStats.MDefense + 10)), CompletelyRandom.Next((CPlStats.Charisma - 50), (CPlStats.Charisma + 10)), CompletelyRandom.Next((CPlStats.Intelligence - 50), (CPlStats.Intelligence + 10)));
     PrevEntCoord = new Coord(0, 2);
 }