84 lines
3.1 KiB
C#
84 lines
3.1 KiB
C#
|
|
using System;
|
|||
|
|
using Cielonos.MainGame.Buffs;
|
|||
|
|
using Cielonos.MainGame.Buffs.Character;
|
|||
|
|
using Cielonos.MainGame.Characters;
|
|||
|
|
using SLSUtilities.General;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Cielonos.MainGame.Inventory.Collections
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 穿甲弹头 / Armor Piercing Round
|
|||
|
|
/// Kinetics 攻击命中时降低目标护甲。
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class ArmorPiercingRound : PassiveEquipmentBase
|
|||
|
|
{
|
|||
|
|
private const string EventKey = nameof(ArmorPiercingRound);
|
|||
|
|
|
|||
|
|
public override void OnObtained()
|
|||
|
|
{
|
|||
|
|
base.OnObtained();
|
|||
|
|
Action<AttackAreaBase, CharacterBase, Attack.Context> onStartAttack = OnStartAttack;
|
|||
|
|
player.eventSm.onStartAttack.Add(EventKey, onStartAttack.ToPrioritized());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void OnDiscarded()
|
|||
|
|
{
|
|||
|
|
player.eventSm.onStartAttack.Remove(EventKey);
|
|||
|
|
base.OnDiscarded();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnStartAttack(AttackAreaBase attackArea, CharacterBase target, Attack.Context context)
|
|||
|
|
{
|
|||
|
|
if (context.value.type == Attack.Type.Kinetics)
|
|||
|
|
{
|
|||
|
|
int armorReduction = Mathf.RoundToInt(passiveAttributeSm.GetItemAttribute("ArmorReduction"));
|
|||
|
|
new ArmorReduction(5f, armorReduction).Apply(target, player, this);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public partial class ArmorPiercingRound
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 穿甲弹头的Buff,默认降低目标等于unitedStack层数的护甲,持续5秒
|
|||
|
|
/// </summary>
|
|||
|
|
public class ArmorReduction : CharacterBuffBase
|
|||
|
|
{
|
|||
|
|
public ArmorReduction(float duration, int stack)
|
|||
|
|
{
|
|||
|
|
Initialize(BuffType.Positive, BuffDispelLevel.Basic);
|
|||
|
|
|
|||
|
|
this.contentSubmodule = new ContentSubmodule(this);
|
|||
|
|
this.timeSubmodule = new TimeSubmodule(this, duration);
|
|||
|
|
this.unitedStackSubmodule = new UnitedStackSubmodule(this, stack);
|
|||
|
|
this.attributeSubmodule = new AttributeSubmodule(this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override bool OnBuffApply(out CharacterBuffBase existingBuff)
|
|||
|
|
{
|
|||
|
|
if (FindExistingSameBuff(out ArmorReduction existing))
|
|||
|
|
{
|
|||
|
|
existingBuff = existing;
|
|||
|
|
existing.timeSubmodule.RefreshDuration();
|
|||
|
|
existing.unitedStackSubmodule.PickHigherStack(this.unitedStackSubmodule);
|
|||
|
|
existing.UpdateArmorValue(existing.unitedStackSubmodule.stackAmount);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
existingBuff = null;
|
|||
|
|
UpdateArmorValue(unitedStackSubmodule.stackAmount);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据当前层数更新护甲加成数值。
|
|||
|
|
/// </summary>
|
|||
|
|
private void UpdateArmorValue(int stacks)
|
|||
|
|
{
|
|||
|
|
attributeSubmodule.numericChange[CharacterAttribute.Armor] = -stacks;
|
|||
|
|
attributeSubmodule.RefreshAllModifiedAttributes();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|