83 lines
2.8 KiB
C#
83 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using SLSFramework.General;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.MainGame.Card
|
|
{
|
|
public partial class CombatBuffSubmodule : SubmoduleBase<CardInstance>
|
|
{
|
|
public List<CardCombatBuffBase> buffList;
|
|
|
|
public CombatBuffSubmodule(CardInstance owner) : base(owner)
|
|
{
|
|
buffList = new List<CardCombatBuffBase>();
|
|
}
|
|
}
|
|
|
|
public partial class CombatBuffSubmodule
|
|
{
|
|
public T GetBuff<T>() where T : CardCombatBuffBase
|
|
{
|
|
return (T)buffList.Find(x => x.GetType() == typeof(T));
|
|
}
|
|
|
|
public bool HasBuff<T>() where T : CardCombatBuffBase
|
|
{
|
|
return buffList.Exists(x => x.GetType() == typeof(T));
|
|
}
|
|
}
|
|
|
|
public partial class CombatBuffSubmodule
|
|
{
|
|
public void Use()
|
|
{
|
|
buffList.For(buff => buff.usageSubmodule?.UpdateModule());
|
|
buffList.For(buff => buff.OnUsage());
|
|
}
|
|
|
|
public void RoundStart()
|
|
{
|
|
buffList.For(buff => buff.combatRoundTimeSubmodule?.Update());
|
|
buffList.For(buff => buff.OnRoundStart());
|
|
}
|
|
|
|
public void RoundEnd()
|
|
{
|
|
buffList.For(buff => buff.OnRoundEnd());
|
|
}
|
|
|
|
public void ActionStart()
|
|
{
|
|
buffList.For(buff => buff.combatActionTimeSubmodule?.Update());
|
|
buffList.For(buff => buff.OnActionStart());
|
|
}
|
|
|
|
public void ActionEnd()
|
|
{
|
|
buffList.For(buff => buff.OnActionEnd());
|
|
}
|
|
}
|
|
|
|
public partial class CombatBuffSubmodule
|
|
{
|
|
public void GetAttributeChange(string attributeName, out float numericChange,
|
|
out float percentageChangeOfAccumulation, out float percentChangeOfMultiplication)
|
|
{
|
|
numericChange = buffList.Where(buff => buff.attributeSubmodule != null)
|
|
.SelectMany(buff => buff.attributeSubmodule.numericChange)
|
|
.Where(change => change.Key == attributeName)
|
|
.Sum(change => change.Value);
|
|
|
|
percentageChangeOfAccumulation = buffList.Where(buff => buff.attributeSubmodule != null)
|
|
.SelectMany(buff => buff.attributeSubmodule.percentageChangeOfAccumulation)
|
|
.Where(change => change.Key == attributeName)
|
|
.Sum(change => change.Value);
|
|
|
|
percentChangeOfMultiplication = buffList.Where(buff => buff.attributeSubmodule != null)
|
|
.SelectMany(buff => buff.attributeSubmodule.percentageChangeOfMultiplication)
|
|
.Where(change => change.Key == attributeName)
|
|
.Aggregate<KeyValuePair<string, float>, float>(1, (current, change) => current * change.Value);
|
|
}
|
|
}
|
|
} |