Exemple #1
0
        }//end Main Menu

        public void SettingsMenu()
        {
            //MenuItem item1 = new MenuItem("Stuff", "S");
            //MenuItem item2 = new MenuItem("Exit", "X");
            bool exit = false;

            List <MenuItem> items = new List <MenuItem>();

            //items.Add(item1);
            //items.Add(item2);
            PresentationHelpers.CenteredMenu(items, "Settings");

            do
            {
                string userInput = System.Console.ReadLine().ToUpper();
                switch (userInput)
                {
                case "S":
                    System.Console.WriteLine("Stuff happens");
                    break;

                case "X":
                    System.Console.WriteLine("Bye");
                    exit = true;
                    break;

                default:
                    PresentationHelpers.InvalidSelectionMessage();
                    break;
                }
            } while (!exit);
        }
Exemple #2
0
        }//AppRunLoop

        //Moved MainMenu to its own method
        public void MainMenu()
        {
            //Creating some instances of the custom class MenuItem for presentation helper scaffolding
            //MenuItem itemOne = new MenuItem("Start a game", "P");
            //MenuItem itemTwo = new MenuItem("Settings", "S");
            //MenuItem itemThree = new MenuItem("Exit", "X");
            bool choiceMade = false;

            //Since the CenteredMenu method takes a List of MenuItems we add our chosen items to a list
            List <MenuItem> menuItems = new List <MenuItem>();

            //menuItems.Add(itemOne);
            //menuItems.Add(itemThree);
            //menuItems.Add(itemTwo);

            //Here we are calling the CenteredMenu() which takes as explained above
            //Takes a list of MenuItems and a string to use as the menu title
            PresentationHelpers.CenteredMenu(menuItems, "Main Menu");

            do
            {
                string userInput = System.Console.ReadLine().ToUpper();
                switch (userInput)
                {
                //case "P":
                //    GameState = GameState.MapSetupMenu;
                //    choiceMade = true;
                //    break;
                //case "S":
                //    GameState = GameState.OptionsMenu;
                //    choiceMade = true;
                //    break;
                case "X":
                    System.Console.WriteLine("Thanks for playing!");
                    GameRunning = false;
                    choiceMade  = true;
                    break;

                default:
                    PresentationHelpers.InvalidSelectionMessage();
                    break;
                }
            } while (!choiceMade);
        }//end Main Menu
Exemple #3
0
        }//end MapSetup

        public void SetupMapX(Map map)
        {
            bool setupComplete = false;

            do
            {
                Console.WriteLine("Input the Map Size X");
                string userInput = Console.ReadLine();

                try
                {
                    map.MapX = int.Parse(userInput);
                    Console.WriteLine(map.MapX);
                    setupComplete = true;
                }
                catch (FormatException)
                {
                    PresentationHelpers.InvalidSelectionMessage();
                }
            } while (!setupComplete);
        }
Exemple #4
0
        public void SetUpUnitLimit(Map map)
        {
            bool setupComplete = false;

            do
            {
                Console.WriteLine("Set Unit Limit\n(the limit on map must be less than half of the total number of spaces available)");
                string userInput = Console.ReadLine();

                try
                {
                    map.MapUnitLimit = int.Parse(userInput);
                    Console.WriteLine(map.MapUnitLimit);
                    setupComplete = true;
                }
                catch (FormatException)
                {
                    PresentationHelpers.InvalidSelectionMessage();
                }
            } while (!setupComplete);
        }
Exemple #5
0
        //PresentationHelpers helper = new PresentationHelpers();

        public void MapSetup(GameLoop game, out GameLoop setupOutGame, out Map setupOutMap)
        {
            Map      map           = new Map(0, 0, 0);
            TileType grassland     = new TileType("Grassland", "Gra", 1);
            TileType nothing       = new TileType("Nothing", "Non", 10);
            bool     setupComplete = false;

            do
            {
                Console.Clear();
                PresentationHelpers.TitleMessage("MAP SETUP");
                DisplayMapSettings(map);
                Console.WriteLine("Please Select an option:\n(C). Set Columns\t(R). Set Rows\t(U). Set Unit Limit\t(X). Done\t(P)Load Preset\t(D). Display Map");
                try
                {
                    PresentationHelpers.DisplayMap(map);
                }
                catch (Exception)
                {
                    //swallow the exceptions. They'd just be NullReference
                    //and IndexOutOfRange anyway.
                }
                var userInput = Console.ReadLine().ToUpper();
                switch (userInput)
                {
                case "C":
                    SetupMapX(map);
                    break;

                case "R":
                    SetupMapY(map);
                    break;

                case "U":
                    SetUpUnitLimit(map);
                    break;

                case "D":
                    map.GenerateMapArray(grassland);
                    //map.MapNodes[0, 0].TileType = nothing;
                    //PresentationHelpers.DisplayMap(map);
                    //Console.ReadLine();
                    break;

                case "P":
                    //I'm hardcoding it now, but we could easily create a method
                    //like SelectPreset() that offers a list of all the
                    //stuff in our MapPresets class.
                    map = MapPresets.DungeonPreset();
                    //PresentationHelpers.DisplayMap(map);
                    //Console.ReadLine();
                    break;

                case "X":
                    //game.GameState = GameState.InGameField;
                    setupComplete = true;
                    break;

                default:
                    PresentationHelpers.InvalidSelectionMessage();
                    break;
                }
            } while (!setupComplete);
            setupOutGame = game;
            setupOutMap  = map;
        }//end MapSetup