Exemplo n.º 1
0
        /// <summary>
        /// Oculta la diana y ataca el objetivo en caso de que tenga.
        /// Distinguiendo entre Minion y Fuerte
        /// </summary>
        public override void OnEndDrag()
        {
            base.OnEndDrag();

            //Si se ha elegido un objetivo correcto (minion enemigo o fuerte enemigo)
            if (DragSuccessful())
            {
                //Si estamos atacando a un minion
                Minion minion = Target.GetComponent <Minion>();
                if (minion != null)
                {
                    attacker.AttackMinion(minion);
                }

                //Si estamos atacando a un fuerte
                else
                {
                    Fort fort = Target.GetComponent <Fort>();
                    if (fort != null)
                    {
                        attacker.AttackFort(fort);
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Se le llama cuando se pierde un fuerte. Detecta si es el final de la partida
 /// </summary>
 /// <param name="fort"></param>
 public void LostFort(Fort fort)
 {
     activeForts--;
     if (activeForts <= 1)
     {
         new GameOverCommand(this).EnqueueComand();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Juega un hechizo en un fuerte
        /// </summary>
        /// <param name="playedCard"></param>
        /// <param name="tablePos"></param>
        public void PlayATargetSpellFromHand(SpellCard spellCard, Fort fort)
        {
            Gold.AddGold(-spellCard.CurrentGoldCost);

            //Borramos la carta de la mano
            Hand.RemoveCard(spellCard);
            Destroy(spellCard.gameObject);

            fort.ApplyEffect(spellCard.Effect);
        }
        /// <summary>
        /// Devuelve true si el objeto es válido para el hechizo
        /// </summary>
        /// <returns></returns>
        protected override bool DragSuccessful()
        {
            if (Target != null)
            {
                Minion minion = Target.GetComponent <Minion>();
                if (minion != null)
                {
                    switch (spell.SpellTarget)
                    {
                    case SpellTarget.MINION:
                        return(true);

                    case SpellTarget.ENEMYMINION:
                        return(minion.Owner != spell.Owner);

                    case SpellTarget.ALLYMINION:
                        return(minion.Owner == spell.Owner);

                    case SpellTarget.CHARACTER:
                        return(true);

                    case SpellTarget.ALLYCHARACTER:
                        return(minion.Owner == spell.Owner);

                    case SpellTarget.ENEMYCHARACTER:
                        return(minion.Owner != spell.Owner);
                    }
                }
                else
                {
                    Fort fort = Target.GetComponent <Fort>();

                    if (fort != null)
                    {
                        switch (spell.SpellTarget)
                        {
                        case SpellTarget.CHARACTER:
                            return(true);

                        case SpellTarget.ALLYCHARACTER:
                            return(fort.Player == spell.Owner);

                        case SpellTarget.ENEMYCHARACTER:
                            return(fort.Player != spell.Owner);
                        }
                    }
                }
            }

            //TODO CON LOS HECHIZOS
            return(false);
        }
        /// <summary>
        /// Oculta la diana y juega el hechizo si tiene un objetivo válido
        /// </summary>
        public override void OnEndDrag()
        {
            base.OnEndDrag();

            if (DragSuccessful())
            {
                //Si estamos atacando a un minion
                Minion minion = Target.GetComponent <Minion>();
                if (minion != null)
                {
                    spell.Owner.PlayATargetSpellFromHand(spell, minion);
                }

                //Si estamos atacando a un fuerte
                else
                {
                    Fort fort = Target.GetComponent <Fort>();
                    if (fort != null)
                    {
                        spell.Owner.PlayATargetSpellFromHand(spell, fort);
                    }
                }
            }
        }
Exemplo n.º 6
0
 //TODO: A LO MEJOR NO ESTÁ DEMASIADO BIEN
 /// <summary>
 /// Determina si el Drag es válido. Comprueba que el Target es un minion del enemigo o el fuerte
 /// </summary>
 /// <returns></returns>
 protected override bool DragSuccessful()
 {
     if (Target != null)
     {
         //Si estamos atacando a un minion
         Minion minion = Target.GetComponent <Minion>();
         if (minion != null)
         {
             //Comprobamos si atacamos a un enemigo
             if (minion.Owner != attacker.Owner)
             {
                 //Comprobamos si no ha muerto ya
                 if (minion.CurrentHealth > 0)
                 {
                     //Comprobamos si el enemigo tiene STEALTH
                     if (!minion.Stealth)
                     {
                         //Comprobamos si el enemigo tiene TAUNT
                         if (minion.Taunt)
                         {
                             return(true);
                         }
                         //Si el enemigo no tiene TAUNT, comprobamos si hay algún minion con TAUNT en en BATTLEFIELD
                         else if (!minion.Owner.PlayerBattlefield.SomeoneWithTaunt())
                         {
                             return(true);
                         }
                         else
                         {
                             new ShowMessageCommand("Hay esbirros que se interponen con provocar", 1.0f).EnqueueComand();
                         }
                     }
                     else
                     {
                         new ShowMessageCommand("No puedes atacar un esbirro con sigilo", 1.0f).EnqueueComand();
                     }
                 }
             }
             return(false);
         }
         //Si estamos atacando a un fuerte
         else
         {
             Fort fort = Target.GetComponent <Fort>();
             if (fort != null)
             {
                 //Si estamos atacando al fuerte enemigo
                 if (attacker.Owner != fort.Player)
                 {
                     //Si hay algún minion con Taunt, no podemos atacar al fuerte
                     if (!fort.Player.PlayerBattlefield.SomeoneWithTaunt())
                     {
                         return(true);
                     }
                     else
                     {
                         new ShowMessageCommand("Hay esbirros que se interponen con provocar", 1.0f).EnqueueComand();
                     }
                 }
                 return(false);
             }
         }
     }
     return(false);
 }
 public MinionAttackFaceCommand(Minion attacker, Fort target)
 {
     this.attacker = attacker;
     this.target   = target;
     initialPos    = attacker.transform.position;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Ataca un fuerte enemigo, recibiendo el fuerte daño
        /// </summary>
        /// <param name="target"></param>
        public void AttackFort(Fort target)
        {
            OnAttack();

            new MinionAttackFaceCommand(this, target).EnqueueComand();
        }