43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting.YamlDotNet.Core.Tokens;
|
|
using UnityEngine;
|
|
|
|
public class Slow : Status
|
|
{
|
|
private float _latestSpeedModifier;
|
|
private float _cumulativeSpeedModifier = 1;
|
|
|
|
public override void Apply(float duration)
|
|
{
|
|
// reset slow duration
|
|
_duration = Mathf.Max(_duration, duration);
|
|
|
|
// slow entity
|
|
EntityLinked.SpeedStatusModifier *= _latestSpeedModifier;
|
|
|
|
// store cumulative speed modifier to revert it later
|
|
_cumulativeSpeedModifier *= _latestSpeedModifier;
|
|
}
|
|
|
|
public override void Unapply()
|
|
{
|
|
// bring entity to normal speed
|
|
Debug.Log(EntityLinked.SpeedStatusModifier);
|
|
EntityLinked.SpeedStatusModifier /= _cumulativeSpeedModifier;
|
|
Debug.Log(EntityLinked.SpeedStatusModifier);
|
|
|
|
// stop effect
|
|
Destroy(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// A higher intensity results in a stronger slow.
|
|
/// Example: An intensity of 0.99 multiplies the entity's speed by 0.01 (which would result in a really low speed)
|
|
/// </summary>
|
|
public float Intensity {
|
|
get => 1 - _latestSpeedModifier;
|
|
set => _latestSpeedModifier = 1 - value;
|
|
}
|
|
}
|