public void AddStatus(CharacterStatusEffects statusEffect, int duration)//adds new or replaces existing status effect { if (AllStatusEffects.ContainsKey(statusEffect)) { AllStatusEffects.Remove(statusEffect); } AllStatusEffects.Add(statusEffect, duration); }
public void RemoveStatus(CharacterStatusEffects statusEffect)//removes status effect { AllStatusEffects.Remove(statusEffect); }
/// <summary> /// Handles when an ActiveStatusEffect is removed from this Character's StatusEffects. /// </summary> /// <param name="characterStatusEffects">The CharacterStatusEffects the event took place on.</param> /// <param name="activeStatusEffect">The ActiveStatusEffect that was removed.</param> protected virtual void StatusEffects_HandleOnRemove(CharacterStatusEffects characterStatusEffects, EventArgs<ActiveStatusEffect> activeStatusEffect) { _updateModStats = true; }
/// <summary> /// adds buff or debuff /// </summary> /// <param name="statusEffect"></param> /// <param name="duration"></param> public void ReceiveStatusEffect(CharacterStatusEffects statusEffect, int duration) { StatusEffects.AddStatus(statusEffect, duration); }
/// <summary> /// Initializes a new instance of the <see cref="Character"/> class. /// </summary> /// <param name="world">World that the character belongs to.</param> /// <param name="isPersistent">If the Character's state is persistent. If true, Load() MUST be called /// at some point during the Character's constructor!</param> protected Character(World world, bool isPersistent) : base(Vector2.Zero, Vector2.One) { IsAlive = false; _skillCaster = new CharacterSkillCaster(this); _world = world; _isPersistent = isPersistent; if (IsPersistent) _statusEffects = new PersistentCharacterStatusEffects(this); else _statusEffects = new NonPersistentCharacterStatusEffects(this); _statusEffects.Added -= StatusEffects_HandleOnAdd; _statusEffects.Added += StatusEffects_HandleOnAdd; _statusEffects.Removed -= StatusEffects_HandleOnRemove; _statusEffects.Removed += StatusEffects_HandleOnRemove; _baseStats = CreateStats(StatCollectionType.Base); _modStats = CreateStats(StatCollectionType.Modified); _spSync = CreateSPSynchronizer(); _inventory = CreateInventory(); _equipped = CreateEquipped(); // Set up the listeners for when the stat collections change BaseStats.StatChanged -= BaseStatChangedHandler; BaseStats.StatChanged += BaseStatChangedHandler; ModStats.StatChanged -= ModStatChangedHandler; ModStats.StatChanged += ModStatChangedHandler; // Set up the listeners for when the equipped items change _equipped.Equipped -= EquippedHandler; _equipped.Equipped += EquippedHandler; _equipped.Unequipped -= UnequippedHandler; _equipped.Unequipped += UnequippedHandler; }