88 lines
2.8 KiB
C#
88 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.MainGame.Card
|
|
{
|
|
public partial class CardBuffBase
|
|
{
|
|
public abstract class CardBuffSubmodule : BuffSubmodule
|
|
{
|
|
public CardLogicBase card => (buff as CardBuffBase)?.attachedCard;
|
|
|
|
protected CardBuffSubmodule(CardBuffBase buff) : base(buff)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Buff的卡牌属性调整模块
|
|
/// </summary>
|
|
public class AttributeSubmodule : CardBuffSubmodule
|
|
{
|
|
public Dictionary<string, float> numericChange;
|
|
public Dictionary<string, float> percentageChangeOfAccumulation;
|
|
public Dictionary<string, float> percentageChangeOfMultiplication;
|
|
|
|
public AttributeSubmodule(CardBuffBase buff) : base(buff)
|
|
{
|
|
this.numericChange = new Dictionary<string, float>();
|
|
this.percentageChangeOfAccumulation = new Dictionary<string, float>();
|
|
this.percentageChangeOfMultiplication = new Dictionary<string, float>();
|
|
}
|
|
|
|
public List<string> RefreshAllModifiedAttributes()
|
|
{
|
|
List<string> modifiedAttributes = new List<string>();
|
|
modifiedAttributes.AddRange(numericChange.Select(kvp => kvp.Key));
|
|
modifiedAttributes.AddRange(percentageChangeOfAccumulation.Select(kvp => kvp.Key));
|
|
modifiedAttributes.AddRange(percentageChangeOfMultiplication.Select(kvp => kvp.Key));
|
|
|
|
modifiedAttributes.ForEach(attr => card.attributeSubmodule.RefreshAttribute(attr));
|
|
|
|
return modifiedAttributes;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Buff的使用次数模块
|
|
/// </summary>
|
|
public class UsageSubmodule : CardBuffSubmodule
|
|
{
|
|
public int currentUsage;
|
|
public int maxUsageCount;
|
|
|
|
public UsageSubmodule(CardBuffBase buff, int maxUsageCount) : base(buff)
|
|
{
|
|
this.maxUsageCount = maxUsageCount;
|
|
this.currentUsage = 0;
|
|
}
|
|
|
|
public void UpdateModule()
|
|
{
|
|
currentUsage++;
|
|
|
|
if (currentUsage >= maxUsageCount)
|
|
{
|
|
buff.Remove();
|
|
}
|
|
}
|
|
|
|
public void RefreshUsage()
|
|
{
|
|
currentUsage = 0;
|
|
}
|
|
|
|
public void ModifyMaxUsage(int change)
|
|
{
|
|
maxUsageCount += change;
|
|
|
|
if (maxUsageCount <= currentUsage)
|
|
{
|
|
buff.Remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |