2025-10-03 00:02:43 -04:00
|
|
|
|
using System.Collections.Generic;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
using NaughtyAttributes;
|
|
|
|
|
|
using SLSFramework.General;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using Unity.VisualScripting;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.MainGame
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class AttributeGroup
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 基础属性,不会改变,通常情况下不会直接使用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Dictionary<string, float> original;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前属性,会受到buff和其他效果的影响
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Dictionary<string, float> current;
|
|
|
|
|
|
|
|
|
|
|
|
public AttributeGroup(Dictionary<string, float> original)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.original = new Dictionary<string, float>();
|
|
|
|
|
|
this.current = new Dictionary<string, float>();
|
|
|
|
|
|
|
|
|
|
|
|
this.original.AddRange(original);
|
|
|
|
|
|
this.current.AddRange(original);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public AttributeGroup(Dictionary<string, float> original, Dictionary<string, string> endowing)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.original = new Dictionary<string, float>();
|
|
|
|
|
|
this.current = new Dictionary<string, float>();
|
|
|
|
|
|
|
|
|
|
|
|
this.original.AddRange(original);
|
|
|
|
|
|
this.current.AddRange(original);
|
|
|
|
|
|
|
|
|
|
|
|
SetUpEndowments(endowing);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetUpEndowments(Dictionary<string, string> endowing)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (endowing == null || endowing.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, string> endowment in endowing)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(endowment.Value))
|
|
|
|
|
|
{
|
|
|
|
|
|
current.Add(endowment.Key, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (float.TryParse(endowment.Value, out float value))
|
|
|
|
|
|
{
|
|
|
|
|
|
current.Add(endowment.Key, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
current.Add(endowment.Key, original.GetValueOrDefault(endowment.Value, 0));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class AttributeGroup
|
|
|
|
|
|
{
|
|
|
|
|
|
public void ResetAttribute(string attributeName)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (original.TryGetValue(attributeName, out float originalAttribute))
|
|
|
|
|
|
{
|
|
|
|
|
|
current[attributeName] = originalAttribute;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ModifyAttribute(string attributeName,
|
|
|
|
|
|
float numericChange, float percentageChangeOfAccumulation, float percentChangeOfMultiplication)
|
|
|
|
|
|
{
|
|
|
|
|
|
current[attributeName] += numericChange;
|
|
|
|
|
|
current[attributeName] = (1 + percentageChangeOfAccumulation) * current[attributeName];
|
|
|
|
|
|
current[attributeName] = percentChangeOfMultiplication * current[attributeName];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class AttributeGroup
|
|
|
|
|
|
{
|
|
|
|
|
|
public void ApplyAllAttributes()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (KeyValuePair<string, float> attribute in original)
|
|
|
|
|
|
{
|
|
|
|
|
|
current[attribute.Key] = attribute.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|