コード例 #1
0
 private static void RecordGenerateSolider(Models.Solider.Base person, bool isSuccessGenerateVillager)
 {
     if (isSuccessGenerateVillager)
     {
         _soliders.Add(person);
     }
 }
コード例 #2
0
        private static Models.Solider.Base ChooseSolider()
        {
            Console.WriteLine("Choose Solider type: Halberd(30), Archer(30), Infantry(35), Cavalry(50)? ");
            var userInput = Console.ReadLine().ToLower();

            Models.Solider.Base person = null;
            switch (userInput)
            {
            case "halberd":
                person = new HalberdSolider();
                break;

            case "archer":
                person = new ArcherSolider();
                break;

            case "infantry":
                person = new InfantrySolider();
                break;

            case "cavalry":
                person = new CavalrySolider();
                break;
            }

            return(person);
        }
コード例 #3
0
        private bool DoGenerateSoldier()
        {
            Models.Solider.Base person = ChooseSolider();
            if (person == null)
            {
                return(false);
            }
            else
            {
                var soliderGnerate            = new PersonGenerate(person);
                var isSuccessGenerateVillager = soliderGnerate.Generate(_resources);
                RecordGenerateSolider(person, isSuccessGenerateVillager);
                var isAttack = GetIsAttack(isSuccessGenerateVillager);

                return(isAttack);
            }
        }