-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed issue with zooming on Windows. Scroll value is multiplied by 100. - Fixed issue with cancelling the move to position routine. - Set some sensible default values for the camera settings. - Moved ValueRange and RolloffState nested classes to their own script file.
- Loading branch information
1 parent
7180666
commit c23d0f1
Showing
7 changed files
with
174 additions
and
133 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
CameraProject/Assets/ImpossibleOdds/TacticalCamera/Scripts/RolloffState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/// <summary> | ||
/// Class to keep track of the current rolloff state of a value. It is controlled by time and a curve. | ||
/// </summary> | ||
namespace ImpossibleOdds.TacticalCamera | ||
{ | ||
using UnityEngine; | ||
|
||
public class RolloffState | ||
{ | ||
private float time; | ||
private float rolloffTime; | ||
private float rolloffValue; | ||
private AnimationCurve rolloffCurve = AnimationCurve.Linear(0f, 1f, 1f, 0f); | ||
|
||
public float Time | ||
{ | ||
get { return time; } | ||
set { time = value; } | ||
} | ||
|
||
public float Value | ||
{ | ||
get | ||
{ | ||
float t = Mathf.InverseLerp(rolloffTime, 0f, time); | ||
return rolloffCurve.Evaluate(t) * rolloffValue; | ||
} | ||
} | ||
|
||
public float RolloffTime | ||
{ | ||
get { return rolloffTime; } | ||
set | ||
{ | ||
if (value <= 0f) | ||
{ | ||
throw new System.ArgumentOutOfRangeException("The rolloff time should be a value larger than 0."); | ||
} | ||
|
||
rolloffTime = value; | ||
} | ||
} | ||
|
||
public float RolloffValue | ||
{ | ||
get { return rolloffValue; } | ||
set | ||
{ | ||
rolloffValue = value; | ||
time = rolloffTime; | ||
} | ||
} | ||
|
||
public AnimationCurve RolloffCurve | ||
{ | ||
get { return rolloffCurve; } | ||
set { rolloffCurve = value; } | ||
} | ||
|
||
public float Update() | ||
{ | ||
if (time == 0f) | ||
{ | ||
return 0f; | ||
} | ||
|
||
time = Mathf.Clamp(time - UnityEngine.Time.deltaTime, 0f, rolloffTime); | ||
return Value; | ||
} | ||
|
||
public void ApplySettings(float rolloffTime, AnimationCurve rolloffCurve) | ||
{ | ||
this.rolloffTime = rolloffTime; | ||
this.rolloffCurve = rolloffCurve; | ||
time = 0f; | ||
rolloffValue = 0f; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
CameraProject/Assets/ImpossibleOdds/TacticalCamera/Scripts/RolloffState.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
CameraProject/Assets/ImpossibleOdds/TacticalCamera/Scripts/ValueRange.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
namespace ImpossibleOdds.TacticalCamera | ||
{ | ||
using System; | ||
using UnityEngine; | ||
|
||
[Serializable] | ||
public struct ValueRange | ||
{ | ||
public float Min | ||
{ | ||
get { return Mathf.Min(min, max); } | ||
} | ||
|
||
public float Max | ||
{ | ||
get { return Mathf.Max(min, max); } | ||
} | ||
|
||
[SerializeField] | ||
private float min; | ||
[SerializeField] | ||
private float max; | ||
|
||
public static ValueRange Lerp(ValueRange a, ValueRange b, float t) | ||
{ | ||
ValueRange result = new ValueRange(); | ||
result.min = Mathf.Lerp(a.min, b.min, t); | ||
result.max = Mathf.Lerp(a.max, b.max, t); | ||
return result; | ||
} | ||
|
||
public float Clamp(float value) | ||
{ | ||
return Mathf.Clamp(value, Min, Max); | ||
} | ||
|
||
public void Set(float min, float max) | ||
{ | ||
this.min = min; | ||
this.max = max; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return string.Format("Min: {0}, Max: {1}", Min.ToString("0.000"), Max.ToString("0.000")); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
CameraProject/Assets/ImpossibleOdds/TacticalCamera/Scripts/ValueRange.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.