2025-10-24 09:11:22 -04:00
|
|
|
|
using System.Collections.Generic;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Continentis.MainGame.Card;
|
|
|
|
|
|
using Continentis.MainGame.UI;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
using SLSFramework.General;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.MainGame.Character
|
|
|
|
|
|
{
|
2025-10-24 09:11:22 -04:00
|
|
|
|
public abstract partial class CharacterCombatBuffBase : CharacterBuffBase
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
|
|
|
|
|
public CardLogicBase sourceCard;
|
|
|
|
|
|
|
2025-10-30 04:21:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 行动计数,每次行动开始时计数-1。
|
|
|
|
|
|
/// </summary>
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public CountSubmodule actionCountSubmodule;
|
2025-10-30 04:21:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 回合计数,每回合开始时计数-1。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public CountSubmodule roundCountSubmodule;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 首次行动计数,仅在角色本回合首次行动时计数-1。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public CountSubmodule roundFirstActionCountSubmodule;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
|
|
|
|
|
|
public UnitedStackSubmodule unitedStackSubmodule;
|
|
|
|
|
|
public IndependentStackSubmodule independentStackSubmodule;
|
|
|
|
|
|
public CoreAttributeSubmodule coreAttributeSubmodule;
|
|
|
|
|
|
public GeneralAttributeSubmodule generalAttributeSubmodule;
|
|
|
|
|
|
public StatusSubmodule statusSubmodule;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
public partial class CharacterCombatBuffBase
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
|
|
|
|
|
public sealed override bool OnBuffApply(out BuffBase<CharacterBase> existingBuff)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new System.NotImplementedException("请使用类型约束更强的OnBuffApply方法");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-12 01:20:19 -06:00
|
|
|
|
public abstract bool OnBuffApply(out CharacterCombatBuffBase existingBuff);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public override void OnAfterFirstApply()
|
|
|
|
|
|
{
|
2025-10-24 09:11:22 -04:00
|
|
|
|
statusSubmodule?.AddStatus();
|
2025-11-10 12:57:04 -05:00
|
|
|
|
attachedCharacter.combatBuffSubmodule.buffList.Exclude(this).For(buff => buff.eventSubmodule?.onOtherBuffFirstApplied.Invoke(this));
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public override void OnBuffRemove()
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
RefreshAttributes();
|
2025-10-24 09:11:22 -04:00
|
|
|
|
statusSubmodule?.RemoveStatus();
|
2025-10-23 00:49:44 -04:00
|
|
|
|
iconSubmodule?.Remove();
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
public partial class CharacterCombatBuffBase
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
protected bool FindExistingSameBuff<T>(out T existingBuff) where T : CharacterBuffBase
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
return FindExistingSameBuff(out existingBuff, attachedCharacter.combatBuffSubmodule.buffList);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Apply(CharacterBase attachedCharacter, CharacterBase sourceCharacter = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Apply(attachedCharacter, sourceCharacter, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Apply(CharacterBase attachedCharacter, CharacterBase sourceCharacter = null, CardLogicBase sourceCard = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.attachedCharacter = attachedCharacter;
|
|
|
|
|
|
this.sourceCharacter = sourceCharacter;
|
|
|
|
|
|
this.sourceCard = sourceCard;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
if (OnBuffApply(out CharacterCombatBuffBase existingBuff))
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-10-24 09:11:22 -04:00
|
|
|
|
this.attachedCharacter.combatBuffSubmodule.buffList.AddByPriority(this);
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
OnAfterFirstApply();
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
|
|
|
|
|
if (iconSubmodule != null)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
(attachedCharacter.characterView.hudContainer.enablingHUDs["CharacterBuffCollection"] as HUD_CharacterBuffCollection)
|
|
|
|
|
|
?.AddBuffIcon(this);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-10-25 07:49:39 -04:00
|
|
|
|
existingBuff.iconSubmodule?.Update();
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-11-10 12:57:04 -05:00
|
|
|
|
|
|
|
|
|
|
attachedCharacter.combatBuffSubmodule.buffList.Exclude(this).For(buff => buff.eventSubmodule?.onOtherBuffApplied.Invoke(this));
|
2025-10-23 00:49:44 -04:00
|
|
|
|
RefreshAttributes();
|
|
|
|
|
|
iconSubmodule?.Update();
|
2025-11-08 09:50:55 -05:00
|
|
|
|
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.cardLogic.RefreshCardAttributes());
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Remove()
|
|
|
|
|
|
{
|
|
|
|
|
|
OnBuffRemove();
|
|
|
|
|
|
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
2025-11-08 09:50:55 -05:00
|
|
|
|
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.cardLogic.RefreshCardAttributes());
|
2025-11-10 12:57:04 -05:00
|
|
|
|
attachedCharacter.combatBuffSubmodule.buffList.Exclude(this).For(buff => buff.eventSubmodule?.onOtherBuffRemoved.Invoke(this));
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void UntriggerRemove()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
2025-11-08 09:50:55 -05:00
|
|
|
|
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.cardLogic.RefreshCardAttributes());
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-10-24 09:11:22 -04:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查并处理专注类Buff的添加逻辑。
|
|
|
|
|
|
/// 如果已有相同Buff存在,则返回true,并通过out参数返回该Buff。
|
|
|
|
|
|
/// 如果没有相同Buff存在,则返回false,并在必要时移除优先级最低的专注类Buff以腾出空间。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="existingBuff"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool FocusingCheck(out CharacterCombatBuffBase existingBuff)
|
|
|
|
|
|
{
|
2025-10-31 10:02:30 -04:00
|
|
|
|
if (buffType != BuffType.Focusing)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("FocusingCheck只能用于专注类Buff");
|
|
|
|
|
|
existingBuff = null;
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
// 移除超出上限的专注类Buff
|
|
|
|
|
|
List<CharacterCombatBuffBase> focusingBuffs =
|
|
|
|
|
|
attachedCharacter.combatBuffSubmodule.buffList.Where(buff => buff.buffType == BuffType.Focusing).ToList();
|
|
|
|
|
|
focusingBuffs.Sort();
|
|
|
|
|
|
int maximumFocusingBuffAmount = attachedCharacter.GetAttribute("MaximumFocusingBuffAmount", 1);
|
|
|
|
|
|
for (int i = maximumFocusingBuffAmount; i < focusingBuffs.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
focusingBuffs[i].Remove();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否已有相同Buff存在
|
|
|
|
|
|
if (FindExistingSameBuff(out existingBuff))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果没有相同Buff存在但已达上限,则移除优先级最低的专注类Buff(将由新Buff替代)
|
|
|
|
|
|
if(focusingBuffs.Count >= maximumFocusingBuffAmount)
|
|
|
|
|
|
{
|
|
|
|
|
|
CharacterCombatBuffBase lowestPriorityBuff = focusingBuffs[focusingBuffs.Count - 1];
|
|
|
|
|
|
lowestPriorityBuff.Remove();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
public partial class CharacterCombatBuffBase
|
2025-10-23 00:49:44 -04:00
|
|
|
|
{
|
|
|
|
|
|
private void RefreshAttributes()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (coreAttributeSubmodule != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
coreAttributeSubmodule.RefreshAllModifiedAttributes();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
generalAttributeSubmodule?.RefreshAllModifiedAttributes();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|