Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
feat: use constants for pan speed settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelRauber committed Nov 7, 2023
1 parent 42cc287 commit 5e40dd8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions FairyTaleDefender/Assets/_Game/Scripts/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,14 @@ public static class AnimationStates
public static readonly int IsWalking = Animator.StringToHash("IsWalking");
public static readonly int IsHobbling = Animator.StringToHash("IsHobbling");
}

public static class Settings
{
public static class Panning
{
public const int Start = 0;
public const int End = 15;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public class CameraConfig
public bool EnableEdgePanning = true;
public bool EnableKeyboardPanning = true;

// Note: if you change this range, also change it in PanningSpeedSettings
[Range(0, 15)]
[Range(Constants.Settings.Panning.Start, Constants.Settings.Panning.Start)]
public float PanSpeed = 7.5f;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ public override void ResetSettings(SettingsSO mutableSettings)
{
base.ResetSettings(mutableSettings);

// Note: We remap from PanSpeed's [Range] attribute to 0 - 100
Slider.SetValueWithoutNotify(math.remap(0, 15, 0, 100, mutableSettings.Camera.PanSpeed));
Slider.SetValueWithoutNotify(math.remap(Constants.Settings.Panning.Start, Constants.Settings.Panning.End, 0, 100,
mutableSettings.Camera.PanSpeed));
}

public void SliderChange(float value)
{
MutableSettings.Camera.PanSpeed = math.remap(0, 100, 0, 15, value);
MutableSettings.Camera.PanSpeed =
math.remap(0, 100, Constants.Settings.Panning.Start, Constants.Settings.Panning.End, value);
OnSettingsChange();
}
}
Expand Down

0 comments on commit 5e40dd8

Please sign in to comment.