133 lines
4.8 KiB
C#
133 lines
4.8 KiB
C#
|
|
using System.Collections.Generic;
|
|||
|
|
using Continentis.MainGame.Character;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Continentis.MainGame.Card
|
|||
|
|
{
|
|||
|
|
public partial class CardLogicBase
|
|||
|
|
{
|
|||
|
|
public bool HasTag(string tag)
|
|||
|
|
{
|
|||
|
|
return functionalTags.Contains(tag) || elementalTags.Contains(tag);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool HasKeyword(string keyword)
|
|||
|
|
{
|
|||
|
|
return contentSubmodule.keywords.Contains(keyword);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public partial class CardLogicBase
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取最终伤害
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="target">目标</param>
|
|||
|
|
/// <param name="elementalTags">元素标签,若为null则使用卡牌的元素标签</param>
|
|||
|
|
protected virtual int GetFinalDamage(CharacterBase target, List<string> elementalTags = null)
|
|||
|
|
{
|
|||
|
|
elementalTags ??= this.elementalTags;
|
|||
|
|
|
|||
|
|
float elementalAmplifier = 1;
|
|||
|
|
foreach (var element in elementalTags) //计算元素伤害加成
|
|||
|
|
{
|
|||
|
|
elementalAmplifier *= user.attributeSubmodule.GetCurrentGeneralAttribute(element + "DamageDealtMultiplier", 1);
|
|||
|
|
elementalAmplifier *= target.attributeSubmodule.GetCurrentGeneralAttribute(element + "DamageGainMultiplier", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
float finalDamage =
|
|||
|
|
attributeSubmodule.GetRoundCurrentAttribute("Damage") * elementalAmplifier *
|
|||
|
|
attributeSubmodule.GetCurrentAttribute("FinalDamageDealtMultiplier", 1) *
|
|||
|
|
target.attributeSubmodule.GetCurrentGeneralAttribute("FinalDamageGainMultiplier", 1);
|
|||
|
|
|
|||
|
|
return Mathf.RoundToInt(finalDamage);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region Attributes
|
|||
|
|
public partial class CardLogicBase
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 设置可变属性值
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="attributeName">属性名,通常为</param>
|
|||
|
|
/// <param name="additive">是否为叠加,true为叠加,false为覆盖,true时,originalValue为外部传入值</param>
|
|||
|
|
/// <param name="originalValue">原始伤害值,仅在additive为true时有效,否则此值被覆盖为BaseAttribute</param>
|
|||
|
|
/// <param name="baseOffset">伤害增量</param>
|
|||
|
|
public void SetVariableAttribute(string attributeName, bool additive, int originalValue, int baseOffset)
|
|||
|
|
{
|
|||
|
|
string baseName = "Base" + attributeName;
|
|||
|
|
string baseOffsetName = baseName + "Offset";
|
|||
|
|
|
|||
|
|
if (!additive) originalValue = GetAttribute(baseName);
|
|||
|
|
|
|||
|
|
SetAttribute(attributeName, originalValue);
|
|||
|
|
SetAttribute(baseOffsetName, baseOffset);
|
|||
|
|
ModifyAttribute(attributeName, baseOffset);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取卡牌的属性值
|
|||
|
|
/// </summary>
|
|||
|
|
public int GetAttribute(string attributeName)
|
|||
|
|
{
|
|||
|
|
return attributeSubmodule.GetRoundCurrentAttribute(attributeName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 设置卡牌的属性值
|
|||
|
|
/// </summary>
|
|||
|
|
public void SetAttribute(string attributeName, int value)
|
|||
|
|
{
|
|||
|
|
attributeSubmodule.attributeGroup.current[attributeName] = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 修改卡牌的属性值
|
|||
|
|
/// </summary>
|
|||
|
|
public void ModifyAttribute(string attributeName, int delta)
|
|||
|
|
{
|
|||
|
|
attributeSubmodule.attributeGroup.current[attributeName] += delta;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
public partial class CardLogicBase
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 检查是否有足够的体力
|
|||
|
|
/// </summary>
|
|||
|
|
protected virtual bool CheckEnoughStamina()
|
|||
|
|
{
|
|||
|
|
int staminaCost = attributeSubmodule.GetRoundCurrentAttribute("StaminaCost");
|
|||
|
|
return user.attributeSubmodule.generalAttributeGroup.current["Stamina"] >= staminaCost;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 消耗体力
|
|||
|
|
/// </summary>
|
|||
|
|
protected virtual void ConsumeStamina()
|
|||
|
|
{
|
|||
|
|
int staminaCost = attributeSubmodule.GetRoundCurrentAttribute("StaminaCost");
|
|||
|
|
user.attributeSubmodule.generalAttributeGroup.current["Stamina"] -= staminaCost;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 检查是否有足够的魔法
|
|||
|
|
/// </summary>
|
|||
|
|
protected virtual bool CheckEnoughMana()
|
|||
|
|
{
|
|||
|
|
int manaCost = attributeSubmodule.GetRoundCurrentAttribute("ManaCost");
|
|||
|
|
return user.attributeSubmodule.generalAttributeGroup.current["Mana"] >= manaCost;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 消耗魔法
|
|||
|
|
/// </summary>
|
|||
|
|
protected virtual void ConsumeMana()
|
|||
|
|
{
|
|||
|
|
int manaCost = attributeSubmodule.GetRoundCurrentAttribute("ManaCost");
|
|||
|
|
user.attributeSubmodule.generalAttributeGroup.current["Mana"] -= manaCost;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|