Exemplo n.º 1
0
    public override string Execute()
    {
        AbstractHero hero = (AbstractHero)this.Manager.heroes[ArgsList[1]];

        ArgsList.RemoveAt(1);
        return(Manager.AddRecipeToHero(ArgsList, hero));
    }
Exemplo n.º 2
0
    public string AddHero(List <String> arguments)
    {
        string result = String.Empty;

        string heroName = arguments[0];
        string heroType = arguments[1];

        try
        {
            Type typeOfHero   = Type.GetType(heroType);
            var  constructors = typeOfHero.GetConstructors();
            var  inventory    = new HeroInventory();


            AbstractHero hero = (AbstractHero)constructors[0].Invoke(new object[] { heroName });

            this.heroes.Add(heroName, hero);

            result = string.Format($"Created {heroType} - {hero.Name}");
        }
        catch (Exception e)
        {
            return(e.Message);
        }

        return(result);
    }
 private void InstantiateHeroes(AbstractHero h1, AbstractHero h2)
 {
     SetTransform(_hero1Obj, 1, _heroPosition);
     SetTransform(_hero2Obj, -1, _enemyHeroPosition);
     ExecuteOnMainThread.Enqueue(() =>
     {
         _hero1            = _hero1Obj.GetComponent <Hero>();
         _hero1.Attributes = h1;
         _hero2            = _hero2Obj.GetComponent <Hero>();
         _hero2.Attributes = h2;
     });
 }
Exemplo n.º 4
0
        /// <summary>
        /// Ejecuta un ataque hacia un héroe.
        /// Aquí entran en juego los puntos de salud del héroe, el ataque del villano y los puntos de
        /// defensa del héroe. Estos últimos pueden ser nada o muy efectivos, se genera un número random
        /// desde 0 hasta el valor de la defensa del héroe, el número resultante se le resta al ataque del villano
        /// y el valor resultante se le resta a los puntos de salud del héroe.
        /// </summary>
        /// <param name="hero">El <see cref="AbstractHero"/> a atacar.</param>
        /// <exception cref="CannotAttackDeadException">Arrojada cuando cualquiera de los dos personajes se encuentra sin vida.</exception>
        public void Attack(AbstractHero hero)
        {
            if (!this.IsAlive() || !hero.IsAlive())
            {
                throw new CannotAttackDeadException("Uno de los dos caracteres que iba a ser atacado estaba muerto.");
            }
            hero.Hp = Math.Max(0, hero.Hp - Math.Max(0, this.Damage - new Random().Next(hero.Defense)));

            if (!hero.IsAlive())
            {
                TorreDeLosCaidos.Instance.Notify(this, hero);
            }
        }
Exemplo n.º 5
0
    public override string Execute()
    {
        string name = base.Args[0];
        string type = base.Args[1];

        try
        {
            Type         heroClassType = Type.GetType(type);
            AbstractHero heroInstance  = Activator.CreateInstance(heroClassType, name) as AbstractHero;
            base.Manager.AddHero(heroInstance);
        }
        catch (Exception e)
        {
            return(e.Message);
        }

        return($"Created {type} - {name}");
    }
Exemplo n.º 6
0
    public string AddRecipeToHero(List <String> arguments, AbstractHero hero)
    {
        var recipeName   = arguments[0];
        var strength     = long.Parse(arguments[1]);
        var agility      = long.Parse(arguments[2]);
        var intelligence = long.Parse(arguments[3]);
        var hitPoints    = long.Parse(arguments[4]);
        var damage       = long.Parse(arguments[5]);

        string[] reqItems = arguments.Skip(6).ToArray();

        var recipe = new Recipe(recipeName, strength, agility, intelligence, hitPoints, damage, reqItems);

        hero.AddRecipe(recipe);
        var result = string.Format(Constants.RecipeCreatedMessage, recipe.Name, hero.Name);

        return(result);
    }
Exemplo n.º 7
0
    public string AddItemToHero(List <String> arguments, AbstractHero hero)
    {
        string itemName          = arguments[0];
        string heroName          = arguments[1];
        int    strengthBonus     = int.Parse(arguments[2]);
        int    agilityBonus      = int.Parse(arguments[3]);
        int    intelligenceBonus = int.Parse(arguments[4]);
        int    hitPointsBonus    = int.Parse(arguments[5]);
        int    damageBonus       = int.Parse(arguments[6]);

        IItem newItem = new CommonItem(itemName, strengthBonus, agilityBonus, intelligenceBonus, hitPointsBonus,
                                       damageBonus);

        hero.inventory.AddCommonItem(newItem);

        string result = string.Format(Constants.ItemCreateMessage, newItem.Name, heroName);

        return(result);
    }
Exemplo n.º 8
0
    public string AddHero(List <string> arguments)
    {
        string result = null;

        string heroName = arguments[0];
        string heroType = arguments[1];

        try
        {
            Type         clazz        = Type.GetType(heroType);
            var          constructors = clazz.GetConstructors();
            AbstractHero hero         = (AbstractHero)constructors[0].Invoke(new object[] { heroName });
            this.heroes.Add(heroName, hero);
            result = String.Format(Constants.HeroCreateMessage, hero.GetType().Name, heroName);
        }
        catch (Exception e)
        {
            return(e.Message);
        }

        return(result);
    }
Exemplo n.º 9
0
    public string AddHero(AbstractHero hero)
    {
        this.heroes.Add(hero.Name, hero);

        return(string.Empty);
    }
Exemplo n.º 10
0
        public override double StartGame()
        {
            Visualizer.DrawEverything(this.boardElements);
            this.gameStatus = 0;
            Position      scorePosition = new Position(Constants.PlayerScoreWidth, Constants.PlayerScoreDebth);
            IDisplayPiece scoreShower   = GetPieceAtPosition(scorePosition, this.boardElements);

            Visualizer.DrawDisplayPieceOnConsole(scoreShower);

            this.winAreaPoints = ((WinArea)this.boardElements
                                  .Find(x => x.DisplaySymbol == "W")).GetPositions();

            Position playerStartingPosition = new Position(Constants.PlayerStartingX, Constants.PlayerStartingY);

            this.player = (AbstractHero)GetPieceAtPosition(playerStartingPosition, this.boardElements);

            while (this.gameStatus == 0)
            {
                if (this.playerScore >= minimumWinScore)
                {
                    int      widthCooOfDoor      = this.positionOfBorderAroundWinArea.GetWidthCoo();
                    int      debtCooOfDoor       = this.positionOfBorderAroundWinArea.GetDebthCoo() + 1;
                    Position positionOfDoorToWin = new Position(widthCooOfDoor, debtCooOfDoor);

                    IDisplayPiece doorToWinArea = GetPieceAtPosition(positionOfDoorToWin, this.boardElements);
                    if (doorToWinArea != null)
                    {
                        RemoveDisplayPiece(doorToWinArea);
                    }
                }

                //// TODO: make every move to remove 0.1 points from the player score and explain it at the begining so that the players think on how they play and there is gamification to the movement as well
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo userInput = Console.ReadKey();

                    if (userInput.Key == ConsoleKey.Q)
                    {
                        this.gameStatus = -1;
                    }
                    else
                    {
                        this.TryMovingToDirection(this.player.Move(userInput));
                    }
                }

                if (this.player.Hp <= 0)
                {
                    this.gameStatus = -1;
                }
            }

            Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();
            if (gameStatus == 1)
            {
                Console.WriteLine("Congratulations you won!");
                Console.WriteLine("Your Score: {0}", PlayerScore);

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(this.player.ToString());
            }
            else if (gameStatus == -1)
            {
                Console.WriteLine("You lost the game");
            }

            Console.ReadLine();

            return(playerScore);
        }
 public void SyncHero(BoardInfo board, AbstractHero h1, AbstractHero h2)
 {
     InitializeBoard(board);
     InstantiateHeroes(h1, h2);
     InstantiateCreature();
 }
Exemplo n.º 12
0
    public override string Execute()
    {
        AbstractHero hero = (AbstractHero)this.Manager.heroes[ArgsList[1]];

        return(Manager.AddItemToHero(ArgsList, hero));
    }
Exemplo n.º 13
0
 /// <summary>
 /// Constructor utilizado para crear batallas entre bandos de 1 personaje.
 /// Se aplica el patrón creator ya que en este constructor se crean las nuevas
 /// listas que contienen a cada uno de los personajes.
 /// </summary>
 /// <param name="hero"></param>
 /// <param name="villain"></param>
 public BattleEncounter(AbstractHero hero, AbstractVillain villain)
     : this(new List <AbstractHero>() { hero }, new List <AbstractVillain>() { villain })
 {
 }