dev/bolas #11

Merged
Garutako merged 7 commits from dev/bolas into main 2025-07-23 06:39:59 +00:00
3 changed files with 22 additions and 15 deletions
Showing only changes of commit a1a2823a96 - Show all commits

View File

@ -26,7 +26,7 @@ public abstract class Entity : LevelObject
private StatusHandler _statusHandler; private StatusHandler _statusHandler;
// status modifiers // status modifiers
private float _speedStatusModifier = 1; private float _speedStatusModifier = 1f;
//Enemy Spotted //Enemy Spotted
private bool _isEnemyDetected = false; private bool _isEnemyDetected = false;

View File

@ -5,8 +5,8 @@ using UnityEngine;
public class Slow : Status public class Slow : Status
{ {
private float _latestSpeedModifier; private float _previousSpeedModifier = 1f;
private float _cumulativeSpeedModifier = 1; private float _speedModifier = 1f;
public override void Apply(float duration) public override void Apply(float duration)
{ {
@ -14,18 +14,15 @@ public class Slow : Status
_duration = Mathf.Max(_duration, duration); _duration = Mathf.Max(_duration, duration);
// slow entity // slow entity
EntityLinked.SpeedStatusModifier *= _latestSpeedModifier; EntityLinked.SpeedStatusModifier /= _previousSpeedModifier;
Debug.Log(_speedModifier);
// store cumulative speed modifier to revert it later EntityLinked.SpeedStatusModifier *= _speedModifier;
_cumulativeSpeedModifier *= _latestSpeedModifier;
} }
public override void Unapply() public override void Unapply()
{ {
// bring entity to normal speed // bring entity to normal speed
Debug.Log(EntityLinked.SpeedStatusModifier); EntityLinked.SpeedStatusModifier /= _speedModifier;
EntityLinked.SpeedStatusModifier /= _cumulativeSpeedModifier;
Debug.Log(EntityLinked.SpeedStatusModifier);
// stop effect // stop effect
Destroy(this); Destroy(this);
@ -35,8 +32,13 @@ public class Slow : Status
/// A higher intensity results in a stronger slow. /// 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) /// 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 - _latestSpeedModifier; {
set => _latestSpeedModifier = 1 - value; get => 1 - _speedModifier;
set
{
_previousSpeedModifier = _speedModifier;
_speedModifier = Mathf.Min(_speedModifier, 1 - value);
}
} }
} }

View File

@ -27,7 +27,7 @@ public class StatusHandler : MonoBehaviour
// check if status already exists // 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 doesn't exist, instantiate it
if (!status) if (!status)
{ {
switch (type) switch (type)
@ -37,8 +37,13 @@ public class StatusHandler : MonoBehaviour
break; break;
default: break; default: break;
} }
// if key value pair doesn't exist, create it
if (!activeStatuses.ContainsKey(type))
{
activeStatuses.Add(type, status); activeStatuses.Add(type, status);
} }
}
// link entity to status // link entity to status
status.EntityLinked = _entityLinked; status.EntityLinked = _entityLinked;