コード例 #1
0
        static void Main(string[] args)
        {
            int         n    = int.Parse(Console.ReadLine());
            var         list = new List <HeroFactory>();
            HeroFactory hero = null;

            for (int i = 0; i < n; i++)
            {
                var nameHero = Console.ReadLine();

                var typeHero = Console.ReadLine();
                if (!ValidateHero(typeHero))
                {
                    Console.WriteLine("Invalid hero!");
                    i--;
                    continue;
                }

                hero = CreateHero(list, hero, nameHero, typeHero);
            }

            var bossPower = int.Parse(Console.ReadLine());
            int totPawor  = 0;

            foreach (var heroPower in list)
            {
                Console.WriteLine(heroPower.GetHero().CastAbility());
                totPawor += heroPower.GetHero().Power;
            }

            var result = totPawor >= bossPower ? "Victory!" : "Defeat...";

            Console.WriteLine(result);
        }
コード例 #2
0
 void CreateEnemyHeroes()
 {
     for (int i = 0; i < ENEMY_SIDE_COUNT; ++i)
     {
         m_EnemyHeroes.Add(HeroFactory.GetNewEnemyHero());
     }
 }
コード例 #3
0
ファイル: Engine.cs プロジェクト: u-ashikov/FourFlagsRPG
        private void CreateHero()
        {
            this.writer.Write(string.Format(EngineConstants.CreateHeroGreetingMessage, Environment.NewLine) + string.Format(EngineConstants.CreateHeroMesage, Environment.NewLine));

            string playerName = this.reader.ReadLine();

            playerName = this.InitHeroName(playerName);

            this.writer.Clear();
            char cki;
            int  heroId;

            this.writer.WriteLine(GameConstants.ChooseHero + Environment.NewLine);

            foreach (object heroType in this.heroTypes)
            {
                this.writer.WriteLine(string.Format(EngineConstants.HeroTypeToChooseMessage, Array.IndexOf(this.heroTypes, heroType) + 1, heroType));
            }

            cki = this.reader.ReadKey();

            while (!char.IsNumber(cki) || !Enum.IsDefined(typeof(Hero), int.Parse(cki.ToString())))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                this.writer.WriteLine(string.Format(EngineConstants.ChooseRaceWrongChoice, Environment.NewLine));
                Console.ForegroundColor = ConsoleColor.Yellow;

                cki = this.reader.ReadKey();
            }

            heroId = int.Parse(cki.ToString());

            this.hero = HeroFactory.CreateHero(heroId, playerName);
            this.ShowHeroStartingInfo();
        }
コード例 #4
0
    static void Main(string[] args)
    {
        VehicleFactory honda       = new HondaFactory();
        VehicleClient  hondaclient = new VehicleClient(honda, "Regular");

        Console.WriteLine("******* Honda **********");
        Console.WriteLine(hondaclient.GetBikeName());
        Console.WriteLine(hondaclient.GetScooterName());

        hondaclient = new VehicleClient(honda, "Sports");
        Console.WriteLine(hondaclient.GetBikeName());
        Console.WriteLine(hondaclient.GetScooterName());

        VehicleFactory hero       = new HeroFactory();
        VehicleClient  heroclient = new VehicleClient(hero, "Regular");

        Console.WriteLine("******* Hero **********");
        Console.WriteLine(heroclient.GetBikeName());
        Console.WriteLine(heroclient.GetScooterName());

        heroclient = new VehicleClient(hero, "Sports");
        Console.WriteLine(heroclient.GetBikeName());
        Console.WriteLine(heroclient.GetScooterName());

        Console.ReadKey();
    }
コード例 #5
0
        static void Main(string[] args)
        {
            var factory = new HeroFactory(
                new ElfBeast("protecting"),
                new ElfMage("cooking"),
                new ElfWarlord("cleaning"));

            var beast   = factory.createBeast();
            var mage    = factory.createMage();
            var warlord = factory.createWarlord();

            Console.WriteLine(beast.ToString());
            Console.WriteLine(mage.ToString());
            Console.WriteLine(warlord.ToString());

            factory = new HeroFactory(
                new OrcBeast("laser"),
                new OrcMage("axe"),
                new OrcWarlord("sword"));

            beast   = factory.createBeast();
            mage    = factory.createMage();
            warlord = factory.createWarlord();

            Console.WriteLine(beast.ToString());
            Console.WriteLine(mage.ToString());
            Console.WriteLine(warlord.ToString());
        }
コード例 #6
0
    public void OnCreate()
    {
        SimpleHero hero = HeroFactory.SetupPlacableHero(TemHeroType);

        hero.transform.position = HeroIcon.transform.position;

        hero.SelectAndDraw();
    }
コード例 #7
0
        static void Main(string[] args)
        {
            // i dont need to know which specific super hero i'm calling
            // i only know i need someone for an "intelligence situation"
            ISuperHero superHero = HeroFactory.InitializeFactories().GetHero(ESituationType.Intelligence);

            Console.WriteLine(superHero.HeroName);
            Console.WriteLine(superHero.GetDescription());
        }
コード例 #8
0
 void SpawnNewHero(Vector3 position)
 {
     hero = HeroFactory.InstantiateRandom();
     hero.transform.position = position;
     hero.onHitExit         += GoToNextFloor;
     hero.onDead            += OnHeroDead;
     heroController          = hero.gameObject.AddComponent <HeroController>();
     hero.gameObject.AddComponent <AudioListener>();
 }
コード例 #9
0
 public Player(Dungeon dungeon)
 {
     Dungeon          = dungeon;
     CurrentLocation  = Dungeon.EntranceLocation;
     PillarsFound     = 0;
     PotionsFound     = 0;
     MonstersBattled  = 0;
     TrapsEncountered = 0;
     Character        = HeroFactory.MakeHero();
 }
コード例 #10
0
    public void Test()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            DestroyImmediate(transform.GetChild(i).gameObject);
        }
        var hero = HeroFactory.InstantiateRandom();

        hero.transform.SetParent(transform, false);
    }
コード例 #11
0
    void RemoveUsedHeroes()
    {
        HeroFactory.UpdateAvailableHeros();

        Dictionary <int, HeroInfoBase> dict = HeroInfoBase.data;

        foreach (HeroData hero in m_OwnedHeroes)
        {
            dict.Remove(hero.HashCode);
        }
    }
コード例 #12
0
    public void AddNewHero()
    {
        if (m_OwnedHeroes.Count < 10)
        {
            m_OwnedHeroes.Add(HeroFactory.GetNewAllyHero());
            EventMessenger.NotifyEvent(SaveEvents.SAVE_GAME_STATE);
        }


        EventMessenger.NotifyEvent(HeroEvents.HERO_ADDED);
    }
コード例 #13
0
        public string Execute(string[] inputArgs)
        {
            string heroType = inputArgs[2];
            string heroName = inputArgs[3];

            HeroFactory heroFactory = new HeroFactory();
            var         hero        = heroFactory.Create(heroType, heroName);

            LoadUtilities.LoadHeroRepository().Add(hero);

            return($"Successful create new Hero {heroType} - {heroName}");
        }
コード例 #14
0
    public static void Main()
    {
        IInputReader  inputReader  = new ConsoleInputReader();
        IOutputWriter outputWriter = new ConsoleOutputWriter();
        IHeroFactory  factory      = new HeroFactory();
        IInventory    inventory    = new HeroInventory();
        IList <IHero> heroes       = new List <IHero>();
        IManager      manager      = new HeroManager(factory, inventory, heroes);
        Engine        engine       = new Engine(inputReader, outputWriter, manager);

        engine.Run();
    }
    public static void Main()
    {
        IInputReader       reader            = new ConsoleReader();
        IOutputWriter      writer            = new ConsoleWriter();
        IHeroFactory       heroFactory       = new HeroFactory();
        ICommonItemFactory commonItemFactory = new CommonItemFactory();
        IRecipeFactory     recipeFactory     = new RecipeFactory();
        IManager           manager           = new HeroManager();

        Engine engine = new Engine(reader, writer, manager, heroFactory, commonItemFactory, recipeFactory);

        engine.Run();
    }
コード例 #16
0
ファイル: Program.cs プロジェクト: IvaylovIvanov2/HeroesIII
    public static void Main()
    {
        IReader             reader             = new Reader();
        IWriter             writer             = new Writer();
        IUnitFactory        unitFactory        = new UnitFactory();
        IHeroFactory        heroFactory        = new HeroFactory();
        IItemFactory        itemFactory        = new ItemFactory();
        IGameController     gameController     = new GameController(unitFactory, heroFactory, itemFactory);
        ICommandInterpreter commandInterpreter = new CommandInterpreter(gameController);
        IEngine             engine             = new Engine(reader, writer, commandInterpreter);

        engine.Run();
    }
コード例 #17
0
 /// Network
 void OnPlaceHeroNetwork(LogicArg arg)
 {
     if (MState == State.WaitPlaceHero)
     {
         PlaceHeroMessage msg = (PlaceHeroMessage)arg.GetMessage("msg");
         foreach (RawHeroInfo hInfo in msg.heroInfo)
         {
             hInfo.block     = BattleField.GetReflectBlock(hInfo.block);
             hInfo.direction = BattleField.GetReflectDirection(hInfo.direction);
             HeroFactory.SetUpEnemyHero(hInfo);
         }
         m_stateMachine.State = State.Strategy;
     }
 }
コード例 #18
0
        static void Main(string[] args)
        {
            Console.WriteLine("Creating a new Monster -> Horse");
            var horse = MonsterFactory.CreateMonster(MonsterType.Horse);

            Console.WriteLine($"Horse kick damage: {horse.KickDamage}");
            Console.WriteLine($"Horse punch damage: {horse.PunchDamage}");  // <--- Exception

            Console.WriteLine("Creating a new Hero -> Guile");
            var guile = HeroFactory.CreateHero(HeroType.Guile);

            Console.WriteLine($"Guile kick damage: {guile.KickDamage}");
            Console.WriteLine($"Guile Tektektuguem damage: {guile.TektektuguemDamage}");  // <--- Exception
        }
コード例 #19
0
        public static void Main()
        {
            IReader reader = new ConsoleReader();
            IWriter writer = new ConsoleWriter();

            IHeroRepository     heroRepository     = new HeroRepository(new Dictionary <string, IHero>());
            IHeroFactory        heroFactory        = new HeroFactory();
            IItemFactory        itemFactory        = new ItemFactory();
            IRecipeFactory      recipeFactory      = new RecipeFactory();
            ICommandInterpreter commandInterpreter = new CommandInterpreter(heroRepository, heroFactory, itemFactory, recipeFactory);

            Engine engine = new Engine(reader, writer, commandInterpreter);

            engine.Run();
        }
コード例 #20
0
    public static void Main()
    {
        IInputReader  reader = new ConsoleReader();
        IOutputWriter writer = new ConsoleWriter();

        var heroFactory   = new HeroFactory();
        var itemFactory   = new ItemFactory();
        var recipeFactory = new RecipeFactory();

        IManager manager = new HeroManager(heroFactory, itemFactory, recipeFactory);

        Engine engine = new Engine(reader, writer, manager);

        engine.Run();
    }
コード例 #21
0
        public void Run()
        {
            HeroFactory     heroFactory          = new HeroFactory();
            List <BaseHero> raidGroup            = new List <BaseHero>();
            int             countOfNeededlHeroes = int.Parse(Console.ReadLine());

            while (raidGroup.Count < countOfNeededlHeroes)
            {
                string name = Console.ReadLine();
                string type = Console.ReadLine();

                try
                {
                    BaseHero newHero = heroFactory.CreateHero(name, type);
                    raidGroup.Add(newHero);
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }

            long bossPower      = long.Parse(Console.ReadLine());
            long raidGroupPower = default;

            if (raidGroup.Count > 0)
            {
                raidGroupPower = GetAllHeroesPowers(raidGroup);
            }

            if (raidGroup.Count > 0)
            {
                if (raidGroupPower >= bossPower)
                {
                    Console.WriteLine(VICTORY_MSG);
                }
                else
                {
                    Console.WriteLine(DEFEAT_MSG);
                }
            }
            else
            {
                Console.WriteLine(DEFEAT_MSG);
            }
        }
コード例 #22
0
    void AddUsedHeroes()
    {
        if (m_OwnedHeroes == null)
        {
            return;
        }


        Dictionary <int, HeroInfoBase> dict = HeroInfoBase.data;

        foreach (HeroData hero in m_OwnedHeroes.Where(hero => hero.CreatedFromRecipe))
        {
            dict[hero.HashCode] = Resources.FindObjectsOfTypeAll <HeroInfoBase>().Where(heroBase => heroBase.heroName == hero.HeroName).First();
        }

        HeroFactory.ResetAvailableHeroes();
    }
コード例 #23
0
 public static void SetUpVirtualHeros()
 {
     for (int i = 0; i < Instance.gridWidth; ++i)
     {
         for (int j = 0; j < Instance.gridHeight; ++j)
         {
             if (Instance.m_normalBlockGrid [i, j].State == Block.BlockState.Hero)
             {
                 HeroType type = Instance.m_normalBlockGrid [i, j].GetHeroInfo().type;
                 Hero     hero = HeroFactory.SetupVirtualHero(type);
                 virtualHeroList.Add(hero);
                 virtualHeroMap [Instance.m_normalBlockGrid [i, j].GetHeroInfo().parent] = hero;
                 Instance.m_virtualBlockGrid [i, j].RegisterHero(hero);
             }
         }
     }
 }
コード例 #24
0
    public IHero CreateHero(Heroes hero, HeroSide side)
    {
        var result = HeroFactory.CreateHero(entityRoot, hero, side, Game.Levels.CurrentLevel.GetHeroSpawn(side));

        if (side == HeroSide.Top)
        {
            Game.Hud.CurrentHud.ScoreBar.AttachHero(HeroSide.Top, result);
            TopHero = result;
        }
        else
        {
            Game.Hud.CurrentHud.ScoreBar.AttachHero(HeroSide.Bottom, result);
            BottomHero = result;
        }

        Game.Hud.CurrentHud.GetHeroController(side).AttachHero(result);

        return(result);
    }
コード例 #25
0
        public string CreateHero(List <string> args)
        {
            string type     = args[0];
            string heroName = args[1];

            if (_heroes.ContainsKey(heroName))
            {
                return($"Hero with name: {heroName} already exists!");
            }

            Hero hero = HeroFactory.CreateHero(args);

            if (hero == null)
            {
                return($"Invalid type hero: {type}.");
            }

            _heroes.Add(heroName, hero);

            return($"{type}: {heroName} joined the Arena!");
        }
コード例 #26
0
        //customize the hero with your own stats
        public void customizeHero()
        {
            HeroFactory heroFactory = new HeroFactory();

            myHero = heroFactory.getHero(HeroTypes.Custom);

            int    health = 0, damage = 0, gold = 0;
            string name = "";

            Console.WriteLine("Introduce the name of your hero: ");
            name = Console.ReadLine();

            while (health < 1 || health > 1000)
            {
                Console.WriteLine("Introduce " + name + "'s Health (between 1 to 1000): ");
                health = Convert.ToInt32(Console.ReadLine());
            }


            while (damage < 1 || damage > 100)
            {
                Console.WriteLine("Introduce " + name + "'s Damage (between 1 to 100): ");
                damage = Convert.ToInt32(Console.ReadLine());
            }


            while (gold < 1 || gold > 5000)
            {
                Console.WriteLine("Introduce " + name + "'s Gold (between 1 and 5000): ");
                gold = Convert.ToInt32(Console.ReadLine());
            }

            myHero.Health = health;
            myHero.Damage = damage;
            myHero.Gold   = gold;
            myHero.Name   = name;


            myHero.showStats();
        }
コード例 #27
0
        //choose iron man/hulk/spiderman
        public void chooseYourHero()
        {
            HeroFactory heroFactory = new HeroFactory();
            int         heroType    = 0;


            while (heroType <= 0 || heroType > Enum.GetNames(typeof(HeroTypes)).Length)
            {
                Console.WriteLine("Choose your favorite hero:\n");
                Console.WriteLine("Iron Man - press 1\n");
                Console.WriteLine("Hulk - press 2\n");
                Console.WriteLine("Spiderman - press 3\n");
                Console.WriteLine("-----------------------\n");
                Console.WriteLine("IronMan has more gold\n");
                Console.WriteLine("Hulk has more health\n");
                Console.WriteLine("Spiderman has more damage\n");

                heroType = Convert.ToInt32(Console.ReadLine());
            }

            myHero = heroFactory.getHero((HeroTypes)(heroType - 1));

            switch (heroType)
            {
            case 1: { Console.WriteLine("Iron Man selected!\n"); break; }

            case 2: { Console.WriteLine("Hulk selected!\n"); break; }

            case 3: { Console.WriteLine("Spiderman selected!\n"); break; }

            default: { Console.WriteLine(); break; }
            }

            Console.WriteLine("Your hero's stats are:");
            myHero.showStats();
        }
コード例 #28
0
        private static HeroFactory CreateHero(List <HeroFactory> list, HeroFactory hero, string nameHero, string typeHero)
        {
            switch (typeHero)
            {
            case "Druid":
                hero = new DruidFactory(nameHero);
                break;

            case "Paladin":
                hero = new PaladinFactory(nameHero);
                break;

            case "Rogue":
                hero = new RogueFactory(nameHero);
                break;

            case "Warrior":
                hero = new WarriorFactory(nameHero);
                break;
            }

            list.Add(hero);
            return(hero);
        }
コード例 #29
0
ファイル: Engine.cs プロジェクト: stefandenchev/Softuni
        public void Run()
        {
            HeroFactory heroFactory = new HeroFactory();
            int         n           = int.Parse(Console.ReadLine());
            int         counter     = 0;

            while (n != counter)
            {
                string name = Console.ReadLine();
                string type = Console.ReadLine();

                BaseHero hero = null;

                try
                {
                    hero = this.heroFactory.Create(name, type);
                    this.heroes.Add(hero);
                    counter++;
                }

                catch (InvalidOperationException ioe)
                {
                    Console.WriteLine(ioe.Message);
                }
            }

            int bossPower = int.Parse(Console.ReadLine());

            foreach (var hero in heroes)
            {
                Console.WriteLine(hero.CastAbility());
            }
            int heroPower = heroes.Sum(h => h.Power);

            WonOrNot(bossPower, heroPower);
        }
コード例 #30
0
 public HeroManager()
 {
     this.heroes      = new Dictionary <string, IHero>();
     this.heroFactory = new HeroFactory();
 }
コード例 #31
0
ファイル: Program.cs プロジェクト: alexismartinezrs/csharpdd
    static void Main(string[] args)
    {
        VehiculoFactory honda = new HondaFactory();
        VehiculoClient hondaclient = new VehiculoClient(honda, "Regular");

        Console.WriteLine("******* Honda **********");
        Console.WriteLine(hondaclient.obtenerbiciNombre());
        Console.WriteLine(hondaclient.GetScooterNombre());

        hondaclient = new VehiculoClient(honda, "Deportes");
        Console.WriteLine(hondaclient.obtenerbiciNombre());
        Console.WriteLine(hondaclient.GetScooterNombre());

        VehiculoFactory hero = new HeroFactory();
        VehiculoClient heroclient = new VehiculoClient(hero, "Regular");

        Console.WriteLine("******* Hero **********");
        Console.WriteLine(heroclient.obtenerbiciNombre());
        Console.WriteLine(heroclient.GetScooterNombre());

        heroclient = new VehiculoClient(hero, "Deportes");
        Console.WriteLine(heroclient.obtenerbiciNombre());
        Console.WriteLine(heroclient.GetScooterNombre());

        Console.ReadKey();
    }