jeudi 8 octobre 2015

How to get user input from an if statement and use it in a case in a separate method?

I want to make a switch case based on user input in my main method executable in another method I set up an if statement to get character input with console keys but am unsure of how to use that input the desired case.

My goal is to make a case that chooses between 4 in game classes based on the users initial pick at the start to determine what stat pool to apply when outputting info based on the class.

In short, someone chooses an in game class called bowmen which is also used as a class that pulls several strings and ints to make up the classes stats (like hit points, mana, strength, ect.). At another point of the game I want to make a consistent screen that displays the updating stats of the specific class chosen by the user earlier on.

Apologies if this is hard to understand, not sure the best way to explain it past showing it.

class Program
{
    static void Main(string[] args)
    {
       if (start.Key == ConsoleKey.N) 
        {
          while (pclass == 1)
            {  ***//This is the input i'm trying to get for the case in strategymenu***
               if **(spc.Key == ConsoleKey.S)**
                {
                }
             }
         }
     }
}

public class menus
{
    public static void StratgyMenu()
    {
      while (pstrat == 1)
        {
          int a;
          switch(a)
          { 
             **//This is the code I'm trying to make a case for which i'm not sure if I set up properly for the case to call it**                                                     
              **case 1: Program.Main(spc.Key == ConsoleKey.S);**
          }

Aucun commentaire:

Enregistrer un commentaire