public static IEnumerator PingPongFloat(FloatSetter floatSetter, float minValue, float maxValue, float period, bool useGameTime = false, AnimationCurve animationCurve = null) { animationCurve = animationCurve ?? AnimationCurve.Linear(0.0f, 0.0f, 1.0f, 1.0f); animationCurve.preWrapMode = WrapMode.PingPong; animationCurve.postWrapMode = WrapMode.PingPong; float startTime = Time.realtimeSinceStartup; float timeElapsed = 0.0f; float progress = 0.0f; floatSetter(minValue); float duration = period / 2; while (true) { timeElapsed = UpdateTimeElapsed(timeElapsed, startTime, useGameTime); progress = timeElapsed / duration; float scaledProgress = ScaleProgress( progress, minValue, maxValue, animationCurve); floatSetter(scaledProgress); yield return(null); } }
private bool loadAllosteryFloat(string value, FloatSetter setter) { if (String.IsNullOrEmpty(value)) { Debug.Log("Error: Empty productionMax field"); return false; } setter(float.Parse(value.Replace(",", "."))); return true; }
/*! \brief Load and parse a string and give it to the given setter \param value The string to parse and load \param setter The delegate setter */ private bool loadEnzymeFloat(string value, FloatSetter setter) { if (String.IsNullOrEmpty(value)) { Logger.Log("EnzymeReaction::loadEnzymeFloat : Empty productionMax field" , Logger.Level.ERROR); return false; } setter(float.Parse(value.Replace(",", "."))); return true; }