示例#1
0
        public static void RushFountain(Elf e)
        {
            ManaFountain fountain;

            e.ShouldTargetFountain(out fountain);
            if (e.InRange(fountain, e.MaxSpeed * 2))
            {
                double savingDuration = 1.0 * (GameState.Game.InvisibilityCost - GameState.CurrentMana) / GameState.Game.GetMyself().ManaPerTurn;
                savingDuration = System.Math.Ceiling(savingDuration);
                int duration = (int)System.Math.Max(savingDuration, 1);

                if (!e.SafeNotToMove(duration))
                {
                    if (GameState.HasManaFor(CreatableObject.Invisibility))
                    {
                        e.CastInvisibility();
                    }
                    else
                    {
                        GameState.SaveManaFor(CreatableObject.Invisibility);
                    }
                }
            }
            if (!e.AlreadyActed && e.ShouldAttack(fountain) && e.InAttackRange(fountain))
            {
                e.Attack(fountain);
            }
            else if (!e.AlreadyActed)
            {
                MissionExtensions.MoveTargets[e] = fountain;
                Mission.MoveToTarget.ExecuteWith(e);
            }
        }
        public void AtackCheckHealthEnemy()
        //Se prueba que el valor total de la vida del enemigo sea el esperado despues de recibir un ataque por el elfo.
        {
            //Act
            wizard.Respawn();
            int expectedHealthLeftEnemy = 10;

            elf.Equip(bow);
            elf.Equip(cloak);
            wizard.Equip(spellBook);
            wizard.LearnSpell(spell);
            elf.Attack(wizard);

            //Assert
            Assert.AreEqual(expectedHealthLeftEnemy, wizard.Health);
        }
示例#3
0
    public static void Main()
    {
        Enemy e = new Elf();

        e.Attack();

        Enemy o = new Orc();

        o.Attack();
    }
示例#4
0
        public static void MoveToCastle(Elf e)
        {
            Location attackLocation =
                GameState.EnemyCastle.Location.Towards(e, e.AttackRange + GameState.EnemyCastle.Size);

            if (e.Location.Equals(attackLocation))
            {
                if (e.ShouldAttack(GameState.EnemyCastle))
                {
                    e.Attack(GameState.EnemyCastle);
                    return;
                }

                var target = e.GetAttackTarget();
                if (target is Elf && LocationFinder.GetPossibleAttackers(e, exceptions: target).Count == 0)
                {
                    e.Attack(target);
                    return;
                }
            }
            e.MoveSafely(attackLocation);
        }
示例#5
0
        public void AtackCheckHealthEnemy()

        /*Se prueba que el valor total de la vida del enemigo sea el esperado
         * despues de recibir un ataque por el elfo.*/
        {
            int expectedHealthLeftEnemy = 145;

            //Act
            elf.Attack(orc);

            //Assert
            Assert.AreEqual(expectedHealthLeftEnemy, orc.Health);
        }
示例#6
0
        public static void SaveForPortal(Elf e)
        {
            // if we should build but there is no mana, we don't move and save the mana for the next turn
            // so we can build it in the following turns
            GameState.SaveManaFor(CreatableObject.Portal);
            // if we don't move from the position we at least attack
            // so we don't completely waste the turn
            GameObject attackObject = e.GetAttackTarget();

            if (attackObject != null)
            {
                e.Attack(attackObject);
            }
            System.Console.WriteLine("saved");
        }
示例#7
0
        /// <summary>
        /// Tries to attack gameObject, if we can't we move to it's intercept location
        /// </summary>
        /// <param name="elf"></param>
        /// <param name="target"></param>
        public static void TryAttack(Elf elf, GameObject target)
        {
            if (target == null)
            {
                return;
            }

            if (elf.InAttackRange(target))
            {
                elf.Attack(target);
            }
            else
            {
                elf.MoveToIntercept(target);
            }
        }
示例#8
0
        static void Main(string[] args)
        {
            GoldenShield goldenShield = new GoldenShield("GoldenShield", 0, 25, "Escudo Protector", false);
            Sword        sword1       = new Sword("Katana", 50, 0, "Corte Fugaz", false);
            Orc          orc          = new Orc("Grom", sword1, goldenShield, "Tanque");
            Sword        sword2       = new Sword("Excalibur", 10, 0, "Corte Diagonal", false);

            orc.AttachSword(sword2);

            InvisibilityCloak invisibilityCloak = new InvisibilityCloak("Capa maxima", 0, 85, "Invisibilidad", false);
            Bow bow1 = new Bow("Arco gigante", 75, 5, "Tira fuego", false);
            Elf elf  = new Elf("Frank", bow1, invisibilityCloak, "Escurridizo");
            Bow bow2 = new Bow("Arco", 60, 5, "Automatico", false);

            elf.AttachBow(bow2);

            MagicStaff magicStaff = new MagicStaff("Varita", "Es mágica(?)", true);
            SpellBook  spellBook  = new SpellBook("Libro de Hechizos", "Tiene hechizos(?)", true);
            Wizard     wizard     = new Wizard("Harry", magicStaff, spellBook, "Support");
            Spell      spell      = new Spell("Lumos", "La varita enciende luz", true);

            wizard.LearnSpell(spell);

            Axe       axe1      = new Axe("El ejecutor", 65, 5, "Hacha giratoria", false);
            Axe       axe2      = new Axe("Verdugo", 70, 0, "Juicio final", false);
            Warhammer warhammer = new Warhammer("Mjölnir", 90, 10, "Aplastar y machacar", false);
            Dwarf     dwarf     = new Dwarf("Thorin", axe1, warhammer, "Luchador");

            dwarf.AttachAxe(axe2);

            wizard.Attack(orc);
            orc.Attack(dwarf);
            wizard.HealOrc(orc);
            dwarf.Attack(orc);
            dwarf.HealWizard(wizard);
            elf.Attack(orc);
        }
示例#9
0
 public static void AttackTarget(Elf e)
 {
     e.Attack(e.GetAttackTarget());
 }
示例#10
0
        public override void DoGameAction()
        {
            Elf elf = (Elf)gameObject;

            elf.Attack(attackObject);
        }