Reviewed-on: #20 Co-authored-by: William <william-gin1@hotmail.com> Co-committed-by: William <william-gin1@hotmail.com>
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Slow : Status
|
|
{
|
|
private float _previousSpeedModifier = 1f;
|
|
private float _speedModifier = 1f;
|
|
|
|
public override void Apply(float duration)
|
|
{
|
|
// reset slow duration
|
|
_duration = Mathf.Max(_duration, duration);
|
|
|
|
// slow entity
|
|
EntityLinked.SpeedStatusModifier /= _previousSpeedModifier;
|
|
EntityLinked.SpeedStatusModifier *= _speedModifier;
|
|
}
|
|
|
|
public override void Unapply()
|
|
{
|
|
// bring entity to normal speed
|
|
EntityLinked.SpeedStatusModifier /= _speedModifier;
|
|
|
|
// 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 - _speedModifier;
|
|
set
|
|
{
|
|
_previousSpeedModifier = _speedModifier;
|
|
_speedModifier = Mathf.Min(_speedModifier, 1 - value);
|
|
}
|
|
}
|
|
}
|