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