116 lines
3.6 KiB
C#
116 lines
3.6 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 combatActionTimeSubmodule;
|
|
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()
|
|
{
|
|
coreAttributeSubmodule?.RefreshAllModifiedAttributes();
|
|
generalAttributeSubmodule?.RefreshAllModifiedAttributes();
|
|
}
|
|
|
|
public override void OnBuffRemove()
|
|
{
|
|
coreAttributeSubmodule?.RefreshAllModifiedAttributes();
|
|
generalAttributeSubmodule?.RefreshAllModifiedAttributes();
|
|
}
|
|
|
|
public virtual void OnRoundStart()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnRoundEnd()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnActionStart()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnActionEnd()
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public partial class CombatBuffBase
|
|
{
|
|
protected bool FindExistingBuff<T>(out T existingBuff) where T : CharacterBuffBase
|
|
{
|
|
return base.FindExistingBuff(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 (uiSubmodule is { hasIcon: true })
|
|
{
|
|
(attachedCharacter.characterView.hudContainer.enablingHUDs["CharacterBuffCollection"] as HUD_CharacterBuffCollection)?.AddBuffIcon(this);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (existingBuff.uiSubmodule is { hasIcon: true })
|
|
{
|
|
existingBuff.uiSubmodule.buffIcon.UpdateIcon();
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Remove()
|
|
{
|
|
OnBuffRemove();
|
|
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
|
}
|
|
|
|
public override void UntriggerRemove()
|
|
{
|
|
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
|
}
|
|
}
|
|
} |