文本显示和Command大修
This commit is contained in:
@@ -131,6 +131,65 @@ namespace Continentis.MainGame.Card
|
||||
return GetFinalDamage(target, elementalTags, out _, out _, out _, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取最终伤害
|
||||
/// </summary>
|
||||
/// <param name="elementalTags">元素标签,若为null则使用卡牌的元素标签</param>
|
||||
public virtual int GetUserDamage(List<string> elementalTags = null)
|
||||
{
|
||||
return GetUserDamage(elementalTags, out _, out _, out _, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取在没有指定目标时的最终伤害值
|
||||
/// </summary>
|
||||
protected virtual int GetUserDamage(List<string> elementalTags,
|
||||
out float baseDamageAfterOffset, out float elementalMultiplier, out float magicMultiplier, out float finalMultiplier)
|
||||
{
|
||||
elementalTags ??= GetElementalKeywords();
|
||||
|
||||
//----计算基础伤害增量----
|
||||
int physicsOffset = 0;
|
||||
if (HasKeyword("Physics") || HasKeyword("Slash") || HasKeyword("Prick") || HasKeyword("Strike"))
|
||||
{
|
||||
physicsOffset = user.GetAttribute("PhysicsDamageDealtOffset"); //物理伤害基础增量
|
||||
}
|
||||
|
||||
int magicOffset = 0;
|
||||
if (HasKeyword("Magic") || HasKeyword("Arcane") || HasKeyword("Sorcery"))
|
||||
{
|
||||
magicOffset = user.GetAttribute("MagicDamageDealtOffset"); //魔法伤害基础增量
|
||||
}
|
||||
|
||||
Debug.Log("Magic Offset: " + magicOffset);
|
||||
|
||||
//----计算伤害因数----
|
||||
|
||||
//计算元素伤害加成,注意,“物理Physics”也是一种元素,因此下方没有“通用物理伤害加成”的计算
|
||||
elementalMultiplier = 1;
|
||||
foreach (string element in elementalTags)
|
||||
{
|
||||
elementalMultiplier *= user.GetRawAttribute(element + "DamageDealtMultiplier", 1);
|
||||
}
|
||||
|
||||
//计算通用的魔法伤害加成
|
||||
magicMultiplier = 1;
|
||||
if (HasKeyword("Magic") || HasKeyword("Arcane") || HasKeyword("Sorcery"))
|
||||
{
|
||||
magicMultiplier = user.GetRawAttribute("MagicDamageDealtMultiplier", 1);
|
||||
}
|
||||
|
||||
//计算最终伤害加成
|
||||
finalMultiplier = user.GetRawAttribute("FinalDamageDealtMultiplier", 1);
|
||||
|
||||
//----计算最终伤害----
|
||||
baseDamageAfterOffset = attributeSubmodule.GetCurrentAttribute("Damage") + physicsOffset + magicOffset;
|
||||
|
||||
float finalDamage = baseDamageAfterOffset * elementalMultiplier * magicMultiplier * finalMultiplier;
|
||||
|
||||
return Mathf.RoundToInt(finalDamage);
|
||||
}
|
||||
|
||||
protected virtual int GetFinalDamage(CharacterBase target, List<string> elementalTags,
|
||||
out float baseDamageAfterOffset, out float elementalMultiplier, out float magicMultiplier, out float finalMultiplier)
|
||||
{
|
||||
|
||||
@@ -86,10 +86,8 @@ namespace Continentis.MainGame.Card
|
||||
}
|
||||
|
||||
attributeSubmodule?.RefreshAllModifiedAttributes();
|
||||
Debug.Log(base.attachedCard.GetAttribute("Damage"));
|
||||
CardTextInterpreter.InterpretText(attachedCard);
|
||||
attachedCard.handCardView?.Setup();
|
||||
attachedCard.intentionCardView?.Setup();
|
||||
attachedCard.contentSubmodule.dirtyMark = true;
|
||||
|
||||
Debug.Log(base.attachedCard.contentSubmodule.interpretedFunctionText);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Continentis.MainGame.Character;
|
||||
using Continentis.MainGame.Equipment;
|
||||
using SLSFramework.General;
|
||||
using SLSFramework.UModAssistance;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.MainGame.Card
|
||||
@@ -14,6 +15,7 @@ namespace Continentis.MainGame.Card
|
||||
[Header("Reference")]
|
||||
public CardData cardData;
|
||||
public CardInstance cardInstance;
|
||||
public CompositeDisposable disposables = new CompositeDisposable();
|
||||
|
||||
public ICardOwner owner => cardInstance.owner;
|
||||
public CharacterBase user => cardInstance.user;
|
||||
@@ -82,8 +84,7 @@ namespace Continentis.MainGame.Card
|
||||
public virtual void Initialize()
|
||||
{
|
||||
RefreshCardAttributes();
|
||||
CardTextInterpreter.InterpretText(this);
|
||||
|
||||
|
||||
if (HasKeyword("Instant")) //如果是“瞬发”牌,添加抽牌后立刻打出的事件
|
||||
{
|
||||
eventSubmodule.onDraw.InsertByPriority("Instant", new PrioritizedAction(() =>
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
eventSubmodule.onUntargeting();
|
||||
}
|
||||
|
||||
contentSubmodule.dirtyMark = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,7 +200,7 @@ namespace Continentis.MainGame.Card
|
||||
});
|
||||
}));
|
||||
|
||||
CommandQueueManager.Instance.AddCommand(PlayEffect(targetList));
|
||||
CommandQueueManager.Instance.AddCommands(PlayEffect(targetList));
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(() =>
|
||||
{
|
||||
eventSubmodule.onAfterPlay.Invoke(targetList);
|
||||
@@ -225,7 +227,7 @@ namespace Continentis.MainGame.Card
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual CommandBase PlayEffect(List<CharacterBase> targetList)
|
||||
protected virtual List<CommandBase> PlayEffect(List<CharacterBase> targetList)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,12 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
attributeGroup.ResetAttribute(attributeName);
|
||||
owner.ApplyAttributeChangesByCard();
|
||||
owner.combatBuffSubmodule.GetAttributeChange(attributeName, out float numeric, out float pAccumulation, out float pMultiplication);
|
||||
attributeGroup.ModifyAttribute(attributeName, numeric, pAccumulation, pMultiplication);
|
||||
owner.user.combatBuffSubmodule.GetGeneralAttributeChange(attributeName, out float cha_numeric, out float cha_pAccumulation, out float cha_pMultiplication);
|
||||
owner.combatBuffSubmodule.GetAttributeChange(attributeName, out float card_numeric, out float card_pAccumulation, out float card_pMultiplication);
|
||||
float final_numeric = cha_numeric + card_numeric;
|
||||
float final_pAccumulation = cha_pAccumulation + card_pAccumulation;
|
||||
float final_pMultiplication = cha_pMultiplication * card_pMultiplication;
|
||||
attributeGroup.ModifyAttribute(attributeName, final_numeric, final_pAccumulation, final_pMultiplication);
|
||||
string displayAttributeName = "Display" + attributeName;
|
||||
if(attributeGroup.current.ContainsKey(displayAttributeName))
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SLSFramework.General;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.MainGame.Card
|
||||
@@ -16,6 +17,11 @@ namespace Continentis.MainGame.Card
|
||||
public string originalFunctionText;
|
||||
public string interpretedFunctionText;
|
||||
|
||||
/// <summary>
|
||||
/// 标记:内容已更改,需要刷新
|
||||
/// </summary>
|
||||
public bool dirtyMark;
|
||||
|
||||
public ContentSubmodule(CardLogicBase card) : base(card)
|
||||
{
|
||||
keywords = card.cardData.keywords;
|
||||
@@ -24,9 +30,27 @@ namespace Continentis.MainGame.Card
|
||||
originalFunctionText = card.cardData.functionText.Localize();
|
||||
cardRarity = card.cardData.cardRarity;
|
||||
cardType = card.cardData.cardType;
|
||||
dirtyMark = false;
|
||||
|
||||
Observable.EveryLateUpdate().Subscribe(_ =>
|
||||
{
|
||||
if (dirtyMark)
|
||||
{
|
||||
RefreshContent();
|
||||
dirtyMark = false;
|
||||
}
|
||||
}).AddTo(card.disposables);
|
||||
|
||||
//CardDescriptionInterpreter.InterpretDescription(card);
|
||||
//keywords = CardDescriptionInterpreter.GetKeywords(card.cardData.cardDescription);
|
||||
//Debug.Log($"Extracted Keywords: {string.Join(", ", keywords)}");
|
||||
}
|
||||
|
||||
public void RefreshContent()
|
||||
{
|
||||
CardTextInterpreter.InterpretText(owner);
|
||||
owner.handCardView?.Setup();
|
||||
owner.intentionCardView?.Setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,13 +76,12 @@ namespace Continentis.MainGame.Card
|
||||
if (card != null)
|
||||
{
|
||||
cardInstance = card;
|
||||
isOccupied = false;
|
||||
isHovering = false;
|
||||
isSelecting = false;
|
||||
isDuringPlaying = false;
|
||||
}
|
||||
|
||||
isOccupied = false;
|
||||
isHovering = false;
|
||||
isSelecting = false;
|
||||
isDuringPlaying = false;
|
||||
|
||||
|
||||
cardNameText.text = cardLogic.contentSubmodule.cardName;
|
||||
cardDescriptionText.text = cardLogic.contentSubmodule.interpretedFunctionText;
|
||||
cardImage.sprite = cardLogic.contentSubmodule.cardSprite;
|
||||
|
||||
@@ -19,8 +19,7 @@ namespace Continentis.MainGame.Card
|
||||
public override void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
base.OnPointerEnter(eventData);
|
||||
CardTextInterpreter.InterpretText(cardLogic);
|
||||
cardDescriptionText.text = cardLogic.contentSubmodule.interpretedFunctionText;
|
||||
cardLogic.contentSubmodule.dirtyMark = true;
|
||||
if (CombatUIManager.Instance.selectingCardView == null)
|
||||
{
|
||||
canvas.overrideSorting = true;
|
||||
@@ -114,9 +113,7 @@ namespace Continentis.MainGame.Card
|
||||
currentTargetingCharacterView = null;
|
||||
}
|
||||
|
||||
// 因为目标发生了变化(无论是选中了新的还是取消了),所以统一在这里更新描述
|
||||
CardTextInterpreter.InterpretText(cardLogic);
|
||||
cardDescriptionText.text = cardLogic.contentSubmodule.interpretedFunctionText;
|
||||
cardLogic.contentSubmodule.dirtyMark = true;
|
||||
}
|
||||
|
||||
Vector3 startPosition = cardTransform.position + new Vector3(0, cardTransform.rect.height * cardTransform.lossyScale.y / 2, 0);
|
||||
@@ -237,8 +234,7 @@ namespace Continentis.MainGame.Card
|
||||
canvas.overrideSorting = false;
|
||||
canvas.sortingOrder = 0;
|
||||
cardLogic.eventSubmodule.onUntargeting();
|
||||
CardTextInterpreter.InterpretText(cardLogic);
|
||||
cardDescriptionText.text = cardLogic.contentSubmodule.interpretedFunctionText;
|
||||
cardLogic.contentSubmodule.dirtyMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -267,8 +263,7 @@ namespace Continentis.MainGame.Card
|
||||
if (!cardLogic.Play(new List<CharacterBase>() { CombatUIManager.Instance.hoveringCharacterView.character }))
|
||||
{
|
||||
cardLogic.eventSubmodule.onUntargeting();
|
||||
CardTextInterpreter.InterpretText(cardLogic);
|
||||
cardDescriptionText.text = cardLogic.contentSubmodule.interpretedFunctionText;
|
||||
cardLogic.contentSubmodule.dirtyMark = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Continentis.MainGame.Card
|
||||
|
||||
protected override void UntargetingEffect()
|
||||
{
|
||||
card.SetAttribute("DisplayDamage", card.GetAttribute("Damage"));
|
||||
card.SetAttribute("DisplayDamage", card.GetUserDamage());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user