fixed bug relating to bolas slow duration
This commit is contained in:
parent
2cfeb398ca
commit
747fc76846
@ -73,7 +73,7 @@ MonoBehaviour:
|
||||
_angle: 0
|
||||
_speed: 2
|
||||
_slowIntensity: 0.25
|
||||
_slowDuration: 10
|
||||
_slowDuration: 5
|
||||
--- !u!1 &6962989256011107503
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -1,24 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting.YamlDotNet.Core.Tokens;
|
||||
using UnityEngine;
|
||||
|
||||
public class Slow : Status
|
||||
{
|
||||
private float _speedModifier;
|
||||
private float _latestSpeedModifier;
|
||||
private float _cumulativeSpeedModifier = 1;
|
||||
|
||||
public override void Apply(float duration)
|
||||
{
|
||||
// reset slow duration
|
||||
_duration += duration;
|
||||
_duration = Mathf.Max(_duration, duration);
|
||||
|
||||
// slow entity
|
||||
EntityLinked.SpeedStatusModifier *= _speedModifier;
|
||||
EntityLinked.SpeedStatusModifier *= _latestSpeedModifier;
|
||||
|
||||
// store cumulative speed modifier to revert it later
|
||||
_cumulativeSpeedModifier *= _latestSpeedModifier;
|
||||
}
|
||||
|
||||
public override void Unapply()
|
||||
{
|
||||
// bring entity to normal speed
|
||||
EntityLinked.SpeedStatusModifier /= _speedModifier;
|
||||
Debug.Log(EntityLinked.SpeedStatusModifier);
|
||||
EntityLinked.SpeedStatusModifier /= _cumulativeSpeedModifier;
|
||||
Debug.Log(EntityLinked.SpeedStatusModifier);
|
||||
|
||||
// stop effect
|
||||
Destroy(this);
|
||||
@ -29,7 +36,7 @@ public class Slow : Status
|
||||
/// 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 => _speedModifier = _speedModifier == 0 ? 1 - value : _speedModifier + (1 - _speedModifier) * value;
|
||||
get => 1 - _latestSpeedModifier;
|
||||
set => _latestSpeedModifier = 1 - value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,11 @@ public class StatusHandler : MonoBehaviour
|
||||
private Status GetStatus(Enum.StatusType type)
|
||||
{
|
||||
Status status;
|
||||
|
||||
// check if status already exists
|
||||
activeStatuses.TryGetValue(Enum.StatusType.Slow, out status);
|
||||
|
||||
// if status doesn't exist, create it
|
||||
if (!status)
|
||||
{
|
||||
switch (type)
|
||||
@ -33,8 +37,12 @@ public class StatusHandler : MonoBehaviour
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
activeStatuses.Add(type, status);
|
||||
}
|
||||
|
||||
// link entity to status
|
||||
status.EntityLinked = _entityLinked;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user