コード例 #1
0
ファイル: Game.cs プロジェクト: geokufer/steppatterns
        public void CreatePlayer(string name)
        {
            Player.Name = name;
            UnitMaternity unit;

            switch (name)
            {
            case "Archer":
                unit = new UnitMaternity(new UnitArcherBuilder());
                break;

            case "Halberdier":
                unit = new UnitMaternity(new UnitHalberdierBuilder());
                break;

            case "Knight":
                unit = new UnitMaternity(new UnitKnightBuilder());
                break;

            case "Mage":
                unit = new UnitMaternity(new UnitMageBuilder());
                break;

            default:
                unit = new UnitMaternity(new UnitMageBuilder());
                break;
            }
            unit.UnitCreate();
            Player.Unit = unit.GetUnit();
        }
コード例 #2
0
ファイル: Bot.cs プロジェクト: geokufer/steppatterns
        public void SetBotWariorClass(string NameOfClass = null)
        {
            UnitMaternity unit;

            int choice = 0;

            if (NameOfClass != null)
            {
                switch (NameOfClass)
                {
                case "Archer":
                    choice = 1;
                    break;

                case "Halberdier":
                    choice = 2;
                    break;

                case "Knight":
                    choice = 3;
                    break;

                case "Mage":
                    choice = 4;
                    break;

                default:
                    choice = 1;
                    break;
                }
            }
            else
            {
                choice = GetRandomNumber();
            }

            switch (choice)
            {
            case 1:
                unit = new UnitMaternity(new UnitArcherBuilder());
                break;

            case 2:
                unit = new UnitMaternity(new UnitHalberdierBuilder());
                break;

            case 3:
                unit = new UnitMaternity(new UnitKnightBuilder());
                break;

            case 4:
                unit = new UnitMaternity(new UnitMageBuilder());
                break;

            default:
                unit = new UnitMaternity(new UnitKnightBuilder());
                break;
            }
            unit.UnitCreate();
            Bot.Unit = unit.GetUnit();
            Bot.Name = Bot.Unit.Name;
        }