public void CreateCharacter(GameEntityManager manager)
 {
     namejump:
     Console.WriteLine("What is your name?");
     var n = Console.ReadLine();
     Console.WriteLine();
     var e = new GameEntity();
     if(n.Length > 2 && n.Length < 18)
         e = manager.CreateEntity(n, TypeTag.Player);
     else
     {
         Console.WriteLine("Names are 3-17 characters. Try again...");
         goto namejump;
     }
     manager.AddComponentToEntity(new StatComponent(StatName.Life, 100) { IsVital = true }, e);
     manager.AddComponentToEntity(new StatComponent(StatName.Mana, 100), e);
     manager.AddComponentToEntity(new ActionTimerComponent(), e);
     manager.AddComponentToEntity(new PlayerInputComponent(), e);
     Console.WriteLine("Choose a class:\n\tf = fighter\n\tr = rogue\n\tw = wizard");
     var choice = Console.ReadKey().KeyChar.ToString();
     Console.WriteLine();
     classjump:
     switch (choice)
     {
         case "f":
             manager.AddComponentToEntity(new ClassComponent(CharacterClassName.Fighter), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Mastery, 3), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Resilience, 4), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Haste, 2), e);
             break;
         case "r":
             manager.AddComponentToEntity(new ClassComponent(CharacterClassName.Rogue), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Mastery, 2), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Resilience, 3), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Haste, 4), e);
             break;
         case "w":
             manager.AddComponentToEntity(new ClassComponent(CharacterClassName.Wizard), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Mastery, 4), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Resilience, 2), e);
             manager.AddComponentToEntity(new StatComponent(StatName.Haste, 3), e);
             break;
         default:
             Console.WriteLine("Invalid Input. Try again...");
             choice = Console.ReadKey().KeyChar.ToString();
             goto classjump;
     }
     manager.AddComponentToEntity(new LevelComponent { LevelValue = 1, XpValue = 0, IsStatic = false }, e);
 }
示例#2
0
        public void CreateMonster(GameEntityManager em, CommandManager cm)
        {
            monsternamejump:
            Console.WriteLine("What is this Monster's name?");
            var n = Console.ReadLine();
            Console.WriteLine();
            var e = new GameEntity(0, "", TypeTag.Monster);
            if (n.Length > 2 && n.Length < 18)
                e = em.CreateEntity(n, TypeTag.Monster);
            else
            {
                Console.WriteLine("Names must be 3-17 characters. Try again...");
                goto monsternamejump;
            }
            em.AddComponentToEntity(new ActionTimerComponent(), e);
            em.AddComponentToEntity(new AIInputComponent(), e);
            Console.WriteLine();
            Console.WriteLine("Monster Level?");
            var l = int.Parse(Console.ReadLine());
            if (l > 0 && l < 24)
                em.AddComponentToEntity(new LevelComponent { IsStatic = true, LevelValue = l, XpValue = l * 5 }, e);
            Console.WriteLine();
            classjump:
            Console.WriteLine("Monster Class?");
            var c = Console.ReadLine();
            switch (c)
            {
                case "f":
                    em.AddComponentToEntity(new StatComponent(StatName.Life, (50 + l * 25)) { IsVital = true }, e);
                    em.AddComponentToEntity(new StatComponent(StatName.Mana, (10 + l * 10)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Mastery, (int)(2 + l * 1.5)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Resilience, (3 + l * 2)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Haste, (1 + l)), e);
                    break;
                case "r":
                    em.AddComponentToEntity(new StatComponent(StatName.Life, (30 + l * 15)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Mana, (30 + l * 15)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Resilience, (int)(2 + l * 1.5)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Haste, (3 + l * 2)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Mastery, (1 + l)), e);
                    break;
                case "w":
                    em.AddComponentToEntity(new StatComponent(StatName.Life, (10 + l * 10)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Mana, (50 + l * 25)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Haste, (int)(2 + l * 1.5)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Mastery, (3 + l * 2)), e);
                    em.AddComponentToEntity(new StatComponent(StatName.Resilience, (1 + l)), e);
                    break;
                default:
                    Console.WriteLine("Invalid Input. Try Again...");
                    goto classjump;
            }

            for(var i = 0; i < cm.CommandCollection.Commands.Count; i++)
            {
                Console.WriteLine(i + ") " + cm.CommandCollection.Commands[i].Name);
            }
            bool done = false;
            while (!done)
            {
                Console.WriteLine("Choose Commands for this monster...");
                var choice = Console.ReadLine();
                var command = cm.CommandCollection.Commands.SingleOrDefault(cmd => choice == cmd.Name);
                if (command != null)
                {
                    var input = e.Components.Where(cmp => cmp is AIInputComponent)
                                            .Cast<AIInputComponent>()
                                            .Single();

                    input.CommandCollection.Commands.Add(command);
                    Console.WriteLine("Done?");
                    if(Console.ReadLine() == "y")
                    {
                        done = true;
                    }
                }
                else Console.WriteLine("Invalid input, try again...");
            }
        }