111 lines
3.4 KiB
C#
111 lines
3.4 KiB
C#
using System.Linq;
|
|
using Continentis.MainGame.Card;
|
|
using Continentis.MainGame.UI;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.MainGame.Character
|
|
{
|
|
public abstract partial class CombatBuffBase : 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 CombatBuffBase
|
|
{
|
|
public sealed override bool OnBuffApply(out BuffBase<CharacterBase> existingBuff)
|
|
{
|
|
throw new System.NotImplementedException("请使用类型约束更强的OnBuffApply方法");
|
|
}
|
|
|
|
public virtual bool OnBuffApply(out CombatBuffBase existingBuff)
|
|
{
|
|
throw new System.NotImplementedException(); //需要在子类中实现
|
|
}
|
|
|
|
public override void OnAfterFirstApply()
|
|
{
|
|
|
|
}
|
|
|
|
public override void OnBuffRemove()
|
|
{
|
|
RefreshAttributes();
|
|
iconSubmodule?.Remove();
|
|
}
|
|
}
|
|
|
|
public partial class CombatBuffBase
|
|
{
|
|
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 CombatBuffBase existingBuff))
|
|
{
|
|
this.attachedCharacter.combatBuffSubmodule.buffList.Add(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);
|
|
}
|
|
}
|
|
|
|
public partial class CombatBuffBase
|
|
{
|
|
private void RefreshAttributes()
|
|
{
|
|
if (coreAttributeSubmodule != null)
|
|
{
|
|
coreAttributeSubmodule.RefreshAllModifiedAttributes();
|
|
}
|
|
else
|
|
{
|
|
generalAttributeSubmodule?.RefreshAllModifiedAttributes();
|
|
}
|
|
}
|
|
}
|
|
} |