static void Main(string[] args) { Hero yourHero; string[] heroTypes = { "Magic", "Melee", "Ranged" }; int selected = TheGoodStuff.Selection(heroTypes, "What type of hero would you like to be?", 1); switch (selected) { case 0: yourHero = magic(); break; case 1: yourHero = melee(); break; case 2: yourHero = ranged(); break; default: yourHero = null; break; } yourHero.PrintStats(); }
void Random() //scrambles the order of the array, could be improved because currently objects further down on the list tends to be placed further down on the list even after the scramble { T[] newArray = new T[array.Length]; //array that contains the same values with a new random index int[] takenNumbers = new int[array.Length]; //numbers that have already been randomized for (int i = 0; i < array.Length; i++) //set all values to -1 so 0 is not a teken number { takenNumbers[i] = -1; } for (int i = 0; i < array.Length; i++) //loops through the length of array to give all of them a new index { int newIndex = generator.Next(0, array.Length); if (TheGoodStuff.IsItInYet(newIndex, takenNumbers)) //has the new random int already been randomized { for (int a = 0; a < array.Length; a++) // find the first int that is not in taken numbers { if (!TheGoodStuff.IsItInYet(a, takenNumbers)) { newIndex = a; //set the new index to a valid number break; //to neccecary but for preformance } } } takenNumbers[i] = newIndex; //add the number to the taken ones newArray[newIndex] = array[i]; //pass the value to the new array with the new index } array = newArray; //update the array }
static Magic magic() { string name = TheGoodStuff.String(2, 16, false, "Name you hero"); return(new Magic(10, null, 70, 5, 25, name)); }
static Ranged ranged() { string name = TheGoodStuff.String(2, 16, false, "Name you hero"); return(new Ranged(10, null, 90, 6, 20, name)); }
static Melee melee() { string name = TheGoodStuff.String(2, 16, false, "Name you hero"); return(new Melee(10, null, 110, 7, 15, name)); }