public void LoadScene(Scenes scene) { switch (scene) { case Scenes.PlayerCountSelection: { PlayerCountSelection mainMenu = new PlayerCountSelection(0, 0, 45, 35, '#'); playersCount = mainMenu.Start() + 2; LoadScene(Scenes.DiceSelection); break; } case Scenes.DiceSelection: { DiceSelection diceSelection = new DiceSelection(0, 0, 45, 35, '#'); diceSides = diceSelection.Start(); LoadScene(Scenes.DiceCountSelection); break; } case Scenes.DiceCountSelection: { DiceCountSelection diceCountSelection = new DiceCountSelection(0, 0, 45, 35, '#'); diceCount = diceCountSelection.Start(); LoadScene(Scenes.Play); break; } case Scenes.Play: { Dice typeOfDie = new Dice(diceSides); Battle battle = new Battle(playersCount, typeOfDie, diceCount); winnersCount = battle.Roll(); if (winnersCount > 1) { playersCount = winnersCount; LoadScene(Scenes.DiceSelection); } else { LoadScene(Scenes.PlayerCountSelection); } break; } default: { Console.WriteLine("Unknow Scene"); break; } } }
static void Main(string[] args) { var rand = new Random(); int i = 1; int j = 1; int count = 1; int pc; int times = 0; //List<int> store = new List<int>(20); string res = "y"; while (res == "y" || res == "Y") { Console.WriteLine("Hello Welcome to Dice Game!"); Console.WriteLine("Please set the number of dice "); string numt = Console.ReadLine(); int numbers = int.Parse(numt); Console.WriteLine("Please set the faces of dice "); string facet = Console.ReadLine(); int faces = int.Parse(numt); DiceSelection acc = new DiceSelection(); Console.WriteLine("How many times do you want to throw? input a number if you want, a n if you not setting a number"); string temp = Console.ReadLine(); if (temp != "n" & temp != "N") { times = int.Parse(temp); List <int> store = new List <int>(times); pc = acc.Calculating(numbers, faces); //pc = rand.Next(1, 7); store.Add(pc); Console.WriteLine($"This round result is {pc}, continue?"); string temp2 = Console.ReadLine(); while ((temp2 == "y" || temp2 == "Y") & j < times) { int pc2 = acc.Calculating(numbers, faces); //int pc2 = rand.Next(1, 7); j++; store.Add(pc2); Console.WriteLine($"This round result is {pc2}, continue?"); temp2 = Console.ReadLine(); count = j; } int sum = 0; decimal ave = 0; foreach (var item in store) { sum += item; ave = Math.Round((decimal)sum / count, 4); Console.Write($"{item} "); } Console.WriteLine(); Console.WriteLine($"The total is {sum}"); Console.WriteLine($"The average is {ave}"); Console.WriteLine("Do you want to continue? y if you want"); res = Console.ReadLine(); } else { List <int> store2 = new List <int>(i); int pc3 = acc.Calculating(numbers, faces); //int pc3 = rand.Next(1, 7); i++; store2.Add(pc3); Console.WriteLine($"This round result is {pc3}, continue?"); string temp3 = Console.ReadLine(); while (temp3 == "y" || temp3 == "Y") { int pc4 = acc.Calculating(numbers, faces); //int pc4 = rand.Next(1, 7); i++; store2.Add(pc4); Console.WriteLine($"this round result is {pc4}, continue?"); temp3 = Console.ReadLine(); } int sum2 = 0; decimal ave2 = 0; foreach (var item in store2) { sum2 += item; ave2 = Math.Round((decimal)sum2 / (i - 1), 4); Console.Write($"{item} "); } Console.WriteLine(); Console.WriteLine($"The total is {sum2}"); Console.WriteLine($"The average is {ave2}"); Console.WriteLine("Do you want to continue? y if you want"); res = Console.ReadLine(); } } }