83 lines
2.2 KiB
C#
83 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DamageIncomeModifierEffectInstance : StatusEffectInstance
|
|
{
|
|
|
|
public float startingIncomeModifierPercent;
|
|
|
|
public float currentIncomeModifierPercent;
|
|
|
|
|
|
public float ModifyDamageIncome(float income)
|
|
{
|
|
return income = income * (1 + currentIncomeModifierPercent);
|
|
}
|
|
|
|
public float GetHighestAmount(float value)
|
|
{
|
|
float highestAmount = value;
|
|
for (int i = 0; i < activeStacks.Count; i++)
|
|
{
|
|
if (((DamageIncomeModifierEffect)activeStacks[i]).damageIncomeModifierPercentage > highestAmount)
|
|
highestAmount = ((DamageIncomeModifierEffect)activeStacks[i]).damageIncomeModifierPercentage;
|
|
}
|
|
|
|
return highestAmount;
|
|
}
|
|
|
|
public override void ApplyEffect(StatusEffect effect, float value)
|
|
{
|
|
base.ApplyEffect(effect, value);
|
|
}
|
|
|
|
protected override void AddStack(StatusEffect addedEffect, float value)
|
|
{
|
|
if (activeStacks.Count <= 0)
|
|
{
|
|
startingIncomeModifierPercent = value;
|
|
currentIncomeModifierPercent = value;
|
|
}
|
|
else if (canStack && (!activeStacks.Contains(addedEffect) || addedEffect.canApplyMultipleInstances))
|
|
{
|
|
currentIncomeModifierPercent += value;
|
|
}
|
|
else
|
|
{
|
|
OnEffectStackAdded();
|
|
return;
|
|
}
|
|
|
|
base.AddStack(addedEffect, value);
|
|
}
|
|
|
|
protected override void RefreshEffect(StatusEffect effect, float value)
|
|
{
|
|
base.RefreshEffect(effect, value);
|
|
|
|
startingIncomeModifierPercent = GetHighestAmount(value);
|
|
currentIncomeModifierPercent = startingIncomeModifierPercent;
|
|
|
|
OnEffectStackAdded();
|
|
}
|
|
|
|
protected override IEnumerator EffectStateCoroutine()
|
|
{
|
|
return base.EffectStateCoroutine();
|
|
}
|
|
|
|
protected override void EffectStateStarted()
|
|
{
|
|
base.EffectStateStarted();
|
|
}
|
|
|
|
protected override void EffectStateEnded()
|
|
{
|
|
startingIncomeModifierPercent = 0;
|
|
currentIncomeModifierPercent = startingIncomeModifierPercent;
|
|
|
|
base.EffectStateEnded();
|
|
}
|
|
}
|