继续
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Continentis.MainGame.Card;
|
||||
using Continentis.MainGame.UI;
|
||||
using SLSFramework.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.MainGame.Character
|
||||
{
|
||||
public abstract partial class CharacterCombatBuffBase : CharacterBuffBase
|
||||
{
|
||||
public CardLogicBase sourceCard;
|
||||
|
||||
public CountSubmodule actionCountSubmodule;
|
||||
public CountSubmodule combatRoundTimeSubmodule;
|
||||
|
||||
public UnitedStackSubmodule unitedStackSubmodule;
|
||||
public IndependentStackSubmodule independentStackSubmodule;
|
||||
public CoreAttributeSubmodule coreAttributeSubmodule;
|
||||
public GeneralAttributeSubmodule generalAttributeSubmodule;
|
||||
public StatusSubmodule statusSubmodule;
|
||||
}
|
||||
|
||||
public partial class CharacterCombatBuffBase
|
||||
{
|
||||
public sealed override bool OnBuffApply(out BuffBase<CharacterBase> existingBuff)
|
||||
{
|
||||
throw new System.NotImplementedException("请使用类型约束更强的OnBuffApply方法");
|
||||
}
|
||||
|
||||
public virtual bool OnBuffApply(out CharacterCombatBuffBase existingBuff)
|
||||
{
|
||||
throw new System.NotImplementedException(); //需要在子类中实现
|
||||
}
|
||||
|
||||
public override void OnAfterFirstApply()
|
||||
{
|
||||
statusSubmodule?.AddStatus();
|
||||
}
|
||||
|
||||
public override void OnBuffRemove()
|
||||
{
|
||||
RefreshAttributes();
|
||||
statusSubmodule?.RemoveStatus();
|
||||
iconSubmodule?.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CharacterCombatBuffBase
|
||||
{
|
||||
protected bool FindExistingSameBuff<T>(out T existingBuff) where T : CharacterBuffBase
|
||||
{
|
||||
return FindExistingSameBuff(out existingBuff, attachedCharacter.combatBuffSubmodule.buffList);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (OnBuffApply(out CharacterCombatBuffBase existingBuff))
|
||||
{
|
||||
this.attachedCharacter.combatBuffSubmodule.buffList.AddByPriority(this);
|
||||
|
||||
OnAfterFirstApply();
|
||||
|
||||
if (iconSubmodule != null)
|
||||
{
|
||||
(attachedCharacter.characterView.hudContainer.enablingHUDs["CharacterBuffCollection"] as HUD_CharacterBuffCollection)
|
||||
?.AddBuffIcon(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingBuff.iconSubmodule?.buffIcon.UpdateIcon();
|
||||
}
|
||||
|
||||
RefreshAttributes();
|
||||
iconSubmodule?.Update();
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
OnBuffRemove();
|
||||
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
||||
}
|
||||
|
||||
public override void UntriggerRemove()
|
||||
{
|
||||
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查并处理专注类Buff的添加逻辑。
|
||||
/// 如果已有相同Buff存在,则返回true,并通过out参数返回该Buff。
|
||||
/// 如果没有相同Buff存在,则返回false,并在必要时移除优先级最低的专注类Buff以腾出空间。
|
||||
/// </summary>
|
||||
/// <param name="existingBuff"></param>
|
||||
/// <returns></returns>
|
||||
public bool FocusingCheck(out CharacterCombatBuffBase existingBuff)
|
||||
{
|
||||
// 移除超出上限的专注类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;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CharacterCombatBuffBase
|
||||
{
|
||||
private void RefreshAttributes()
|
||||
{
|
||||
if (coreAttributeSubmodule != null)
|
||||
{
|
||||
coreAttributeSubmodule.RefreshAllModifiedAttributes();
|
||||
}
|
||||
else
|
||||
{
|
||||
generalAttributeSubmodule?.RefreshAllModifiedAttributes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user