コード例 #1
0
        public void EndTurn()
        {
            // Regenerate Health
            foreach (DD4EStatusEffect status in StatusEffects.FindAll(s => s.Type == DD4EStatusEffectType.Regeneration))
            {
                var damageStatus = (status as DD4EDamageModifier);
                if (damageStatus != null)
                {
                    Heal(damageStatus.DamageAmount);
                }
            }

            // End Effects
            StatusEffects.RemoveAll(s => s.Duration == DD4EStatusEffectDuration.EndOfMyTurn);

            for (int i = 0; i < StatusEffects.Count; i++)
            {
                if (StatusEffects[i].Duration == DD4EStatusEffectDuration.EndOfMyNextTurn)
                {
                    StatusEffects[i].Duration = DD4EStatusEffectDuration.EndOfMyTurn;
                }

                if (StatusEffects[i].Duration == DD4EStatusEffectDuration.EndOfMyNextTurnSustain)
                {
                    StatusEffects[i].Duration = DD4EStatusEffectDuration.EndOfMyTurnSustain;
                }
            }

            OnPropertyChanged("StatusEffects");
        }
コード例 #2
0
 internal void AddStatusEffect(ElementalBuff elementalBuff)
 {
     if (StatusEffects.FindAll(delegate(StatusEffect se) { return(se is ElementalBuff); }).Count == 0)
     {
         StatusEffects.Add(elementalBuff);
     }
     //elementalBuff.Draw(this);
 }
コード例 #3
0
        public void StartTurn()
        {
            // Take ongoing Damage
            foreach (DD4EStatusEffect status in StatusEffects.FindAll(s => s.Type == DD4EStatusEffectType.OngoingDamage))
            {
                var damageStatus = (status as DD4EDamageModifier);
                if (damageStatus != null)
                {
                    TakeDamage(damageStatus.DamageType, damageStatus.DamageAmount);
                }
            }

            // End effects
            StatusEffects.RemoveAll(s => s.Duration == DD4EStatusEffectDuration.StartOfMyTurn);

            OnPropertyChanged("StatusEffects");
        }
コード例 #4
0
        public void TakeDamage(DD4EDamageType damageType, int damage)
        {
            int incomingDamage = damage;

            // Find Vulnerability Amount
            var vulnerabilityModifier = 0;

            foreach (DD4EStatusEffect status in StatusEffects.FindAll(s => s.Type == DD4EStatusEffectType.Vulnerability))
            {
                var damageStatus = (status as DD4EDamageModifier);
                if (damageStatus != null)
                {
                    if ((damageStatus.DamageType & damageType) != DD4EDamageType.None)
                    {
                        vulnerabilityModifier = Math.Max(vulnerabilityModifier, damageStatus.DamageAmount);
                    }
                }
            }
            incomingDamage += vulnerabilityModifier;

            // Apply Resitances
            // 1) Build List of Resistance
            var            resistanceModifier = Int32.MaxValue;
            DD4EDamageType resistanceList     = DD4EDamageType.None;

            foreach (DD4EStatusEffect status in StatusEffects.FindAll(s => s.Type == DD4EStatusEffectType.Resistance))
            {
                var damageStatus = (status as DD4EDamageModifier);
                if (damageStatus != null)
                {
                    resistanceList |= damageStatus.DamageType;
                }
            }

            // 2) Figure out if they resist everything
            if ((resistanceList & damageType) == damageType)
            {
                // 3) If they resist everything, find lowest resistance value and do so
                foreach (DD4EStatusEffect status in StatusEffects.FindAll(s => s.Type == DD4EStatusEffectType.Resistance))
                {
                    var damageStatus = (status as DD4EDamageModifier);
                    if (damageStatus != null)
                    {
                        if ((damageStatus.DamageType & damageType) != DD4EDamageType.None)
                        {
                            resistanceModifier = Math.Min(resistanceModifier, damageStatus.DamageAmount);
                        }
                    }
                }

                // 4) If they have a resist all use the maximum between all and the current resistance
                if (StatusEffects.Exists(s => s.Type == DD4EStatusEffectType.Resistance && (s as DD4EDamageModifier).DamageType == DD4EDamageType.All))
                {
                    resistanceModifier = Math.Max(resistanceModifier, (StatusEffects.Find(s => s.Type == DD4EStatusEffectType.Resistance && (s as DD4EDamageModifier).DamageType == DD4EDamageType.All) as DD4EDamageModifier).DamageAmount);
                }

                // 5) Apply Resistance
                incomingDamage -= resistanceModifier;
            }

            if (incomingDamage > 0)
            {
                if (TemporaryHP > 0)
                {
                    if (TemporaryHP > incomingDamage)
                    {
                        TemporaryHP   -= incomingDamage;
                        incomingDamage = 0;
                    }
                    else
                    {
                        incomingDamage -= TemporaryHP;
                        TemporaryHP     = 0;
                    }
                }
            }

            if (incomingDamage > 0)
            {
                CurrentHP = Math.Max(0, CurrentHP - incomingDamage);
            }

            if (CurrentHP <= 0)
            {
                // Remove Regeneration and Ongoing Damage
                StatusEffects.RemoveAll(s => (s.Type == DD4EStatusEffectType.OngoingDamage || s.Type == DD4EStatusEffectType.Regeneration));
                OnPropertyChanged("StatusEffects");
            }
        }