35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using SLSUtilities.General;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters.Inventory.Collections
|
|
{
|
|
public class AutomaticShield : ConsumableBase
|
|
{
|
|
public override void OnObtained()
|
|
{
|
|
base.OnObtained();
|
|
player.eventSm.onBeforeGetAttacked.Add("AutomaticShield", new PrioritizedAction<AttackAreaBase, AttackResult>(CheckAndEffect));
|
|
}
|
|
|
|
public override void OnDiscarded()
|
|
{
|
|
base.OnDiscarded();
|
|
player.eventSm.onBeforeGetAttacked.Remove("AutomaticShield");
|
|
}
|
|
|
|
void CheckAndEffect(AttackAreaBase attackArea, AttackResult attackResult)
|
|
{
|
|
if (attackResult.attackValue.damage > 1f)
|
|
{
|
|
if (Use(1))
|
|
{
|
|
// 使用最新的管线标记使其伤害彻底作废:
|
|
attackResult.isImmune = true;
|
|
attackResult.attackValue.damageMultiplier = 0f;
|
|
|
|
CameraEffectManager.Instance.vignetteEffects["Shield"].mainEffect.Play();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |