Пример #1
0
    public void CalcStats(Battlefield bf, CardGO cardGO, bool apply = true)
    {
        if (!apply)
        {
            Strength = GetBaseStrength();
            ClearBonds();
            Morale = 0;
            Horn   = false;
            cardGO.GetComponent <CardGO>().UpdateStrengthText();
        }
        else if (!Hero)
        {
            //1. apply Weather effects
            if (bf.Weather)
            {
                Strength = 1;
            }
            else
            {
                Strength = GetBaseStrength();
            }
            //2. apply Bond effects
            if (Ability == Abilities.Bond)
            {
                ClearBonds();
                int index     = bf.Cards.IndexOf(cardGO);
                int tempindex = -1;
                while (index + tempindex >= 0 &&
                       bf.Cards[index + tempindex].GetComponent <CardGO>().Card.Name == cardGO.Card.Name)
                {
                    AddBond();
                    tempindex--;
                }

                tempindex = 1;
                while (index + tempindex <= bf.Cards.Count - 1 &&
                       bf.Cards[index + tempindex].GetComponent <CardGO>().Card.Name == cardGO.Card.Name)
                {
                    AddBond();
                    tempindex++;
                }

                for (int i = 0; i < Bond; i++)
                {
                    Strength += GetBaseStrength();
                }
            }
            //3. apply Morale effects
            if (bf.Morale > 0 && Ability != Abilities.Morale)
            {
                Morale    = bf.Morale;
                Strength += Morale;
            }
            else if (bf.Morale > 1 && Ability == Abilities.Morale)
            {
                Morale    = bf.Morale;
                Strength += Morale - 1;
            }
            //4.1 apply Horn effect from Horn unit cards
            Horn = false;
            if (bf.ZoneHorn.HasHorn)
            {
                HornZone hz = bf.ZoneHorn;
                if (hz.SpecialHorn != null)
                {
                    Strength += Strength;
                    Horn      = true;
                }
                //check to see this card is not doubling itself
                else if ((Ability == Abilities.Horn && hz.UnitHorns.Count > 1) ||
                         (Ability != Abilities.Horn && hz.UnitHorns.Count > 0))
                {
                    Strength += Strength;
                    Horn      = true;
                }
            }
            //update Strength text
            cardGO.GetComponent <CardGO>().UpdateStrengthText();
        }
    }
Пример #2
0
 private void Reset()
 {
     hornZone = transform.parent.GetComponentInChildren <HornZone>();
 }