/// <summary> /// Check if damage should be reflected /// </summary> /// <param name="damage">Damage taken</param> /// <param name="source">The living object that gave the damage</param> public void ProcessReflection(int damage, Living source) { if (source.EquipmentSlots != null) // { foreach (ItemSlot slot in source.EquipmentSlots.Children) // Looking up the ring(s) the living object has equipped { if (slot.SlotItem != null && slot.Id.Contains("ringSlot")) // { RingEquipment ring = slot.SlotItem as RingEquipment; foreach (RingEffect effect in ring.RingEffects) { if (effect.EffectType == EffectType.Reflection) // Check if the ring is a Ring of Reflection { ReflectionEffect rEffect = effect as ReflectionEffect; double randomNumber = GameEnvironment.Random.NextDouble(); double reflectChance = rEffect["chance"] - 1 / source.luck; // Calculate reflection chance if (randomNumber <= reflectChance) { TakeReflectionDamage(source, damage, rEffect["power"]); // Deal Reflection Damage } } } } } } }
protected void AddReflection() { // This method adds a special effect to a ring, this being the "Reflection" effect. // It's the first attempt of magic in the game ReflectionEffect reflectionEffect = new ReflectionEffect(2.5, 1.5); ringEffects.Add(reflectionEffect); }