Example #1
0
        public CharacterCreation()
        {
            this.player = new Player();
            keyInfo = new ConsoleKeyInfo();

            creationStep = CreationStep.Name;

            classItemList = new Dictionary<string, MenuItem>();
            classItems = new string[] { "F", "R", "W" };
            classItemList.Add(classItems[classIndex], new MenuItem(classItems[classIndex++], "#A0F|ighter"));
            classItemList.Add(classItems[classIndex], new MenuItem(classItems[classIndex++], "#B0R|ogue"));
            classItemList.Add(classItems[classIndex], new MenuItem(classItems[classIndex++], "#C0W|izard"));

            ClassIndex = 0;
            selectedItem = classItemList[classItems[ClassIndex]];

            rand = new Random();
            strength = rand.Next(8, 21);
            dexterity = rand.Next(8, 21);
            constitution = rand.Next(8, 21);
            intelligence = rand.Next(8, 21);
            wisdom = rand.Next(8, 21);
            charisma = rand.Next(8, 21);
        }
Example #2
0
        private void RenderClassMenu(MenuItem selectedMenuItem)
        {
            IO.Print(String.Format("Your name is #F0{0}|.\n", player.Name));
            IO.Print("Your is #D0class| is: \n\n");

            foreach (KeyValuePair<string, MenuItem> kvp in classItemList)
            {
                IO.Print(selectedMenuItem == kvp.Value
                             ? String.Format("\t[{1}] [{0}\t]\n", kvp.Value.Text, kvp.Value.Key)
                             : String.Format("\t[{1}]  {0}\n", kvp.Value.Text, kvp.Value.Key));
            }
        }
Example #3
0
        public override StateMachine.StateAction During(GameTime gameTime)
        {
            switch (creationStep)
            {
                case CreationStep.Name:
                    string name = "";
                    while (String.IsNullOrEmpty(name))
                    {
                        name = Console.ReadLine();
                        if (String.IsNullOrEmpty(name))
                            continue;
                        player.Name = name;
                        creationStep = CreationStep.Class;
                    }
                    break;
                case CreationStep.Class:
                    while (player.Class == Player.PlayerClass.None)
                    {
                        keyInfo = Console.ReadKey(true);

                        if (keyInfo.Key == ConsoleKey.Spacebar)
                            return StateMachine.StateAction.Continue;

                        if (classItemList.ContainsKey(keyInfo.Key.ToString().ToUpper()))
                            while (!classItems[ClassIndex].Equals(keyInfo.Key.ToString()))
                                ClassIndex++;

                        if (keyInfo.Key == ConsoleKey.UpArrow || keyInfo.Key == ConsoleKey.LeftArrow)
                            ClassIndex--;
                        if (keyInfo.Key == ConsoleKey.DownArrow || keyInfo.Key == ConsoleKey.RightArrow)
                            ClassIndex++;

                        selectedItem = classItemList[classItems[ClassIndex]];

                        if (keyInfo.Key == ConsoleKey.Enter)
                        {
                            selectedItem = classItemList[classItems[ClassIndex]];
                            player.Class = (Player.PlayerClass)(ClassIndex + 1);

                            creationStep = CreationStep.Stats;
                            //return StateMachine.StateAction.Continue;
                        }

                        return StateMachine.StateAction.Remain;
                    }
                    break;
                case CreationStep.Stats:
                    while (player.Strength == 0)
                    {
                        keyInfo = Console.ReadKey(true);

                        if (keyInfo.Key == ConsoleKey.Spacebar)
                            return StateMachine.StateAction.Continue;

                        if (keyInfo.Key == ConsoleKey.R)
                        {
                            strength = rand.Next(8, 21);
                            dexterity = rand.Next(8, 21);
                            constitution = rand.Next(8, 21);
                            intelligence = rand.Next(8, 21);
                            wisdom = rand.Next(8, 21);
                            charisma = rand.Next(8, 21);
                        }

                        if (keyInfo.Key == ConsoleKey.Enter)
                        {
                            player.Strength = strength;
                            player.Dexterity = dexterity;
                            player.Constitution = constitution;
                            player.Intelligence = intelligence;
                            player.Wisdom = wisdom;
                            player.Charisma = charisma;
                            return StateMachine.StateAction.Continue;
                        }

                        if (keyInfo.Key == ConsoleKey.Enter)
                        {
                            //return StateMachine.StateAction.Continue;
                        }

                        return StateMachine.StateAction.Remain;
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (keyInfo.Key == ConsoleKey.X)
                return StateMachine.StateAction.Continue;
            return StateMachine.StateAction.Remain;
        }