 |
Jypeli
9
The simple game programming library
|
Siirry tämän tiedoston dokumentaatioon.
33 using System.Xml.Serialization;
40 #if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE && !NETFX_CORE
44 [AdvBrowsableOrder(
"Min,Value,Max")]
46 #if !(WINDOWS_PHONE || XBOX || NETFX_CORE)
49 IComparable<Clamped>, IEquatable<Clamped>
56 throw new ArgumentNullException(
"s");
58 #if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
60 string[] vals = s.Split(
new char[] {
'<',
'(',
')' }, StringSplitOptions.RemoveEmptyEntries);
62 string[] temp = s.Split(
new char[] {
'<',
'(',
')' });
64 for (
int index1 = 0; index1 < temp.Length; ++index1)
66 if (temp[index1].Length > 0)
68 temp[index2++] = temp[index1];
71 string[] vals =
new string[index2];
72 Array.Copy(temp, vals, vals.Length);
76 throw new FormatException();
83 #if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
88 string[] vals = s.Split(
new char[] {
'<',
'(',
')' }, StringSplitOptions.RemoveEmptyEntries);
140 this.value = copy.
value;
150 get {
return this.
value; }
165 if (
value >
max) {
throw new ArgumentOutOfRangeException(
"value"); }
179 if (
value <
min) {
throw new ArgumentOutOfRangeException(
"value"); }
215 get {
return this.value ==
max; }
222 get {
return this.value ==
min; }
249 return newValue -
max;
251 else if (newValue <
min)
254 return newValue -
min;
258 this.value = newValue;
273 result = newValue -
max;
275 else if (newValue <
min)
278 result = newValue -
min;
282 this.value = newValue;
294 if (
min >
max) {
throw new ArgumentOutOfRangeException(
"min"); }
302 return string.Format(
"({0} < {1} < {2})",
min,
value,
max);
306 return this.value.GetHashCode();
311 return other !=
null &&
Equals(other);
315 return this.value.Equals(other.
value);
319 return this.value.CompareTo(other.
value);
override string ToString()
override int GetHashCode()
Clamped()
Creates a new Clamped instance all values being zero.
Scalar Add(Scalar value)
Adds a value to the clamped vaule and returns the overflow/underflow.
void Maximize()
Sets it to its maximum value;
int CompareTo(Clamped other)
Scalar Min
Gets and Sets the minimum value.
void Add(ref Scalar value, out Scalar result)
Adds a value to the clamped vaule and returns the overflow/underflow.
bool IsMax
Gets if the value is at its maximum value;
void SetValues(Scalar value, Scalar min, Scalar max)
Sets all the values at once.
static Scalar Lerp(Scalar left, Scalar right, Scalar amount)
static Scalar Clamp(Scalar value, Scalar min, Scalar max)
bool IsMin
Gets if the value is at its minimum value;
A class that keeps a value clamped.
static bool TryParse(string s, out Clamped result)
Clamped(Scalar value)
Creates a new Clamped instance with zero being either the max or min.
Scalar Value
Gets and Sets the current value.
void Minimize()
Sets it to its minimum value;
override bool Equals(object obj)
Scalar Percent
Gets and Sets the percent with Min being 0 (0%) and Max being 1 (100%)
static Clamped Parse(string s)
bool Equals(Clamped other)
Clamped(Scalar value, Scalar min, Scalar max)
Creates a new Clamped instance.
Scalar Max
Gets and Sets the maximum value.