/// <summary> /// When overridden in the derived class, tries to add an <see cref="IStatusEffect{StatType, StatusEffectType}"/> to /// this collection. /// </summary> /// <param name="statusEffect">The status effect to add.</param> /// <param name="power">The power of the status effect.</param> /// <returns>True if the <paramref name="statusEffect"/> of the given <paramref name="power"/> was added /// to this collection; otherwise false.</returns> /// <exception cref="ArgumentNullException"><paramref name="statusEffect" /> is <c>null</c>.</exception> public override bool TryAdd(IStatusEffect<StatType, StatusEffectType> statusEffect, ushort power) { if (statusEffect == null) throw new ArgumentNullException("statusEffect"); ActiveStatusEffect existingStatusEffect; var alreadyExists = TryGetStatusEffect(statusEffect.StatusEffectType, out existingStatusEffect); var time = GetTime(); var disableTime = (TickCount)(time + statusEffect.GetEffectTime(power)); if (alreadyExists) { var changed = existingStatusEffect.MergeWith(time, power, disableTime); if (changed) RecalculateStatBonuses(); return changed; } else { var ase = new ActiveStatusEffect(statusEffect, power, disableTime); _statusEffects.Add(ase); OnAdded(ase); return true; } }
bool CheckEnd(IStatusEffect runtime) { if (runtime.IsEndEffect()) { runtime.OnEndStatusEffect(); return true; } return false; }
/// <summary> /// Removes status effect if exist. /// </summary> /// <param name="e"></param> public void RemoveEffect(IStatusEffect e) { KeyValue <IStatusEffect, float> effect = Effects.Where(p => p.Key == e).SingleOrDefault(); if (effect != null) { Effects.Remove(effect); e.Revert(this); } }
public void AddStatusEffect(IStatusEffect effect) { if (HasStatusEffect(effect.Name)) { CurrentStatusEffects.First(x => x.Name == effect.Name).RemainingTime = effect.Duration; } else { CurrentStatusEffects.Add(effect.Copy()); } }
/// <summary> /// Uniquely add a status effects if it's not already added. /// </summary> /// <param name="e"></param> public void AddEffect(IStatusEffect e, float Duration) { KeyValue <IStatusEffect, float> effect = Effects.Where(p => p.Key == e).SingleOrDefault(); if (effect == null) { Effects.Add(new KeyValue <IStatusEffect, float>(e, Duration)); e.Init(this); } else { effect.Value = Duration; } }
//Apply the status effect for the remaining ticks. IEnumerator ApplyStatusEffect(IStatusEffect effect) { effect.OnAdd(this); while (effect.GetRemainingTicks() > 0) { effect.UseTick(this); yield return(new WaitForSeconds(1f)); } effect.OnRemove(this); effects.Remove(effect); yield break; }
private void Update() { float time = Time.time; for (int i = 0; i < _statusEffects.Count; i++) { IStatusEffect statusEffect = _statusEffects[i]; statusEffect.Update(); if (time - _statusEffectStartTimes[i] >= statusEffect.Duration) { Remove(i); } } }
/// <summary> /// Handles the add status. /// </summary> /// <param name="effect">Effect.</param> /// <param name="printLog">If set to <c>true</c> print log.</param> public void HandleAddStatus(BattleEntity sourceEntity, IStatusEffect effect) { StatusEffectNode node = GetNode (effect); bool wasEmpty = node.isEmpty; node.ApplyEffect(sourceEntity, effect); CheckCleanup(node); // check to see if we should fire an event if(wasEmpty && !node.isEmpty) { BattleSystem.Instance.PostBattleEvent(new StatusEffectEvent( mBattleEntity, effect.property, StatusEffectEvent.StatusEventType.NEW, effect.type)); } else if(!wasEmpty && node.isEmpty) { BattleSystem.Instance.PostBattleEvent(new StatusEffectEvent( mBattleEntity, effect.property, StatusEffectEvent.StatusEventType.REMOVED, effect.type)); } }
/// <summary> /// When overridden in the derived class, tries to add an <see cref="IStatusEffect{StatType, StatusEffectType}"/> to /// this collection. /// </summary> /// <param name="statusEffect">The status effect to add.</param> /// <param name="power">The power of the status effect.</param> /// <returns>True if the <paramref name="statusEffect"/> of the given <paramref name="power"/> was added /// to this collection; otherwise false.</returns> /// <exception cref="ArgumentNullException"><paramref name="statusEffect" /> is <c>null</c>.</exception> public override bool TryAdd(IStatusEffect <StatType, StatusEffectType> statusEffect, ushort power) { if (statusEffect == null) { throw new ArgumentNullException("statusEffect"); } ASEWithID existingStatusEffect; var alreadyExists = TryGetStatusEffect(statusEffect.StatusEffectType, out existingStatusEffect); var time = GetTime(); var disableTime = (TickCount)(time + statusEffect.GetEffectTime(power)); if (alreadyExists) { // Status effect already exists - merge with it var changed = existingStatusEffect.Value.MergeWith(time, power, disableTime); if (changed) { RecalculateStatBonuses(); UpdateInDatabase(existingStatusEffect); } return(changed); } else { // Status effect doesn't exist - create new instance var ase = new ActiveStatusEffect(statusEffect, power, disableTime); var id = InsertInDatabase(ase); var aseWithID = new ASEWithID(id, ase); _statusEffects.Add(aseWithID); OnAdded(aseWithID.Value); return(true); } }
public void AddStatusEffect(IStatusEffect effect) { state.statusHandler.AddStatus(effect); }
/// <summary> /// When overridden in the derived class, tries to add an <see cref="IStatusEffect{StatType, StatusEffectType}"/> to /// this collection. /// </summary> /// <param name="statusEffect">The status effect to add.</param> /// <param name="power">The power of the status effect.</param> /// <returns>True if the <paramref name="statusEffect"/> of the given <paramref name="power"/> was added /// to this collection; otherwise false.</returns> public abstract bool TryAdd(IStatusEffect <StatType, StatusEffectType> statusEffect, ushort power);
/// <summary> /// When overridden in the derived class, tries to add an <see cref="IStatusEffect{StatType, StatusEffectType}"/> to /// this collection. /// </summary> /// <param name="statusEffect">The status effect to add.</param> /// <param name="power">The power of the status effect.</param> /// <returns>True if the <paramref name="statusEffect"/> of the given <paramref name="power"/> was added /// to this collection; otherwise false.</returns> /// <exception cref="ArgumentNullException"><paramref name="statusEffect" /> is <c>null</c>.</exception> public override bool TryAdd(IStatusEffect<StatType, StatusEffectType> statusEffect, ushort power) { if (statusEffect == null) throw new ArgumentNullException("statusEffect"); ASEWithID existingStatusEffect; var alreadyExists = TryGetStatusEffect(statusEffect.StatusEffectType, out existingStatusEffect); var time = GetTime(); var disableTime = (TickCount)(time + statusEffect.GetEffectTime(power)); if (alreadyExists) { // Status effect already exists - merge with it var changed = existingStatusEffect.Value.MergeWith(time, power, disableTime); if (changed) { RecalculateStatBonuses(); UpdateInDatabase(existingStatusEffect); } return changed; } else { // Status effect doesn't exist - create new instance var ase = new ActiveStatusEffect(statusEffect, power, disableTime); var id = InsertInDatabase(ase); var aseWithID = new ASEWithID(id, ase); _statusEffects.Add(aseWithID); OnAdded(aseWithID.Value); return true; } }
/// <summary> /// Initializes a new instance of the <see cref="ActiveStatusEffect"/> class. /// </summary> /// <param name="statusEffect">The <see cref="IStatusEffect{TStatType, TSkillType}"/> to use.</param> /// <param name="power">The power of the StatusEffect.</param> /// <param name="disableTime">The game time at which this <see cref="ActiveStatusEffect"/> will be disabled.</param> public ActiveStatusEffect(IStatusEffect <StatType, StatusEffectType> statusEffect, ushort power, TickCount disableTime) { _statusEffect = statusEffect; _power = power; _disableTime = disableTime; }
public void AddStatusEffect(IStatusEffect effect) { CurrentStatusEffects.Add(effect); }
public StatusEffectRunner(BattleEntity sourceEntity, IStatusEffect statusEffect) { m_SourceEntity = sourceEntity; m_StatusEffect = statusEffect; }
/// <summary> /// Lazy create the node. /// </summary> /// <returns>The node.</returns> /// <param name="effect">Effect.</param> private StatusEffectNode GetNode(IStatusEffect effect) { StatusEffectNode node = null; mEffectNodeMap.TryGetValue(effect.property, out node); if(node == null) { node = new StatusEffectNode(this); mEffectNodeMap[effect.property] = node; } return node; }
/// <summary> /// 状態異常の追加 /// </summary> /// <param name="statusEffect"></param> public void AddStatusEffect(IStatusEffect statusEffect) { runtimeStatusEffects.Add(statusEffect); statusEffect.OnStartStatusEffect(); }
public void setUp() { statusEffect = new StaminaRegenEffect(); }
public void AddEffect(BattleEntity sourceEntity, IStatusEffect statusEffect) { // TODO sorted list from capacity solves max capacity problem // TODO sorted list from endDuration solves checking all IStatusEffectRunner runner = new StatusEffectRunner(sourceEntity, statusEffect); maxCapacity = Math.Max(maxCapacity, runner.capacity); effects.Add(runner); netValue += runner.strength; }
/// <summary> /// Applies the magical buff effect. If we have a debuff, lets remove it instead. /// </summary> /// <param name="effect">Effect.</param> private void ApplyEffect(BattleEntity sourceEntity, IStatusEffect effect, StatusEffectAggregator aggregator) { aggregator.AddEffect(sourceEntity, effect); }
public void ApplyEffect(BattleEntity sourceEntity, IStatusEffect effect) { switch(effect.type) { case StatusEffectType.POSITIVE: ApplyEffect(sourceEntity, effect, positiveEffects); break; case StatusEffectType.NEGATIVE: ApplyEffect(sourceEntity, effect, negativeEffects); break; case StatusEffectType.NULLIFY: ClearEffects(); break; } }
public void AddEffect(IStatusEffect effect) { StatusEffects.Add(new Tuple <IStatusEffect, int>(effect, effect.Duration)); effect.BeforeFirstTick(this); }
public void RemoveEffect(IStatusEffect effect) { StatusEffects.RemoveAll(e => e.Item1 == effect); }
public virtual void AddStatusEffect(IStatusEffect effect) { StatusEffects.Add(effect); effect.Apply(this); }
//Get a status effect and start coroutine to apply void GetStatusEffect(IStatusEffect effect) { effects.Add(effect); StartCoroutine(ApplyStatusEffect(effect)); }
public virtual void RemoveStatusEffect(IStatusEffect effect) { effectsToRemove.Add(effect); effect.Remove(this); }
public void AddStatusEffect(IStatusEffect statusEffect) { statusEffects.Add(statusEffect); }
public void ApplyStatusEffect(BattleEntity sourceEntity, IStatusEffect statusEffect) { mStatusEffectManager.HandleAddStatus(sourceEntity, statusEffect); }