78 lines
2.8 KiB
C#
78 lines
2.8 KiB
C#
using System.Collections.Generic;
|
||
using Continentis.MainGame;
|
||
using Continentis.MainGame.Card;
|
||
using Continentis.MainGame.Character;
|
||
using SLSUtilities.General;
|
||
|
||
namespace Continentis.Mods.Basic.Buffs
|
||
{
|
||
/// <summary>
|
||
/// 魔力外溢/奥术充能(法师):必须先持有此 Buff,之后每次打出带 Magic 关键词的卡牌自动叠 1 层。
|
||
/// 层数可被特定卡牌消耗以触发爆发效果;本 Buff 不自动消耗。
|
||
/// </summary>
|
||
public class ArcaneCharge : CharacterCombatBuffBase
|
||
{
|
||
public ArcaneCharge()
|
||
{
|
||
Initialize(BuffType.Positive, BuffDispelLevel.Strong);
|
||
|
||
this.contentSubmodule = new ContentSubmodule(this)
|
||
.AddParameterGetter("Stack", () => unitedStackSubmodule.stackAmount.ToString());
|
||
|
||
this.iconSubmodule = new IconSubmodule(this).SetTextFunctions("Stack");
|
||
|
||
// 初始 0 层;层数完全由事件驱动累积
|
||
this.unitedStackSubmodule = new UnitedStackSubmodule(this, 0);
|
||
|
||
this.eventSubmodule = new EventSubmodule(this);
|
||
|
||
// 打出 Magic 关键词卡牌后叠 1 层
|
||
this.eventSubmodule.onAfterPlayCard.Add("ArcaneCharge_Stack",
|
||
new PrioritizedAction<CardInstance, List<CharacterBase>>(OnAfterPlayCard));
|
||
}
|
||
|
||
private void OnAfterPlayCard(CardInstance playedCard, List<CharacterBase> targets)
|
||
{
|
||
if (!playedCard.HasKeyword("Magic")) return;
|
||
unitedStackSubmodule.AddStack(1);
|
||
iconSubmodule.Update();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 消耗指定数量的层数。供卡牌逻辑调用。
|
||
/// 返回实际消耗的层数(受当前层数上限约束)。
|
||
/// </summary>
|
||
public int ConsumeStacks(int amount)
|
||
{
|
||
int actual = System.Math.Min(amount, unitedStackSubmodule.stackAmount);
|
||
unitedStackSubmodule.ReduceStack(actual);
|
||
iconSubmodule.Update();
|
||
return actual;
|
||
}
|
||
|
||
/// <summary>消耗全部层数并返回消耗量。</summary>
|
||
public int ConsumeAllStacks()
|
||
{
|
||
int amount = unitedStackSubmodule.stackAmount;
|
||
unitedStackSubmodule.ModifyStack(-amount);
|
||
iconSubmodule.Update();
|
||
return amount;
|
||
}
|
||
|
||
public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff)
|
||
{
|
||
MainGameManager.Instance.basePrefabs.GenerateInfoText(
|
||
contentSubmodule.displayName, attachedCharacter.characterView);
|
||
|
||
// 若已存在则保留现有实例(不重置层数,不二次叠加)
|
||
if (FindExistingSameBuff(out existingBuff))
|
||
{
|
||
return false;
|
||
}
|
||
|
||
existingBuff = null;
|
||
return true;
|
||
}
|
||
}
|
||
}
|