public override void Raise() { if (targetVariable is FloatScriptable) { FloatScriptable floatVariable = (FloatScriptable)targetVariable; targetSlider.value = floatVariable.value; return; } if (targetVariable is IntScriptable) { IntScriptable integerVariable = (IntScriptable)targetVariable; targetSlider.value = integerVariable.value; } }
/// <summary> /// Raise true or false event stack based on the comparison of two number variables /// </summary> public override void Raise() { if (firstValue == null || secondValue == null) { Debug.Log("Number variable comparison doesn't have variables assigned! " + this.gameObject); return; } float first = 0; float second = 0; if (firstValue is FloatScriptable) { FloatScriptable floatScriptable = (FloatScriptable)firstValue; first = floatScriptable.value; } if (firstValue is IntScriptable) { IntScriptable intScriptable = (IntScriptable)firstValue; first = intScriptable.value; } if (secondValue is FloatScriptable) { FloatScriptable floatScriptable = (FloatScriptable)secondValue; second = floatScriptable.value; } if (secondValue is IntScriptable) { IntScriptable intScriptable = (IntScriptable)secondValue; second = intScriptable.value; } if (first < second) { onFirstValueIsLower.Invoke(); } else { onFirstValueIsHigher.Invoke(); } }
/// <summary> /// Invoke the true or false event stack based on a comparison of your targetVariable and a fixed number /// The comparison only runs when the Raise() is called, it's not monitored in Update or etc. /// </summary> public override void Raise() { if (targetValue == null) { Debug.Log("No number variable assigned in a fixed number to numberVariable comparison! " + this.gameObject.name); return; } if (targetValue is FloatScriptable) { FloatScriptable floatScriptable = (FloatScriptable)targetValue; if (floatScriptable.value < fixedNumber) { onVariableIsLower.Invoke(); } else { onVariableIsHigher.Invoke(); } } if (targetValue is IntScriptable) { IntScriptable intScriptable = (IntScriptable)targetValue; if (intScriptable.value < Mathf.RoundToInt(fixedNumber)) { onVariableIsLower.Invoke(); } else { onVariableIsHigher.Invoke(); } } }