public void Check(float fromLength, float toLength) { if (enabled) { bool flag = false; switch (type) { case Type.Growing: flag = (toLength >= targetLength && fromLength < targetLength); break; case Type.Shrinking: flag = (toLength <= targetLength && fromLength > targetLength); break; case Type.Both: flag = ((toLength >= targetLength && fromLength < targetLength) || (toLength <= targetLength && fromLength > targetLength)); break; } if (flag) { action.Invoke(); } } }
public void Check(float fromLength, float toLength) { if (!enabled) { return; } bool condition = false; switch (type) { case Type.Growing: condition = toLength >= targetLength && fromLength < targetLength; break; case Type.Shrinking: condition = toLength <= targetLength && fromLength > targetLength; break; case Type.Both: condition = toLength >= targetLength && fromLength <targetLength || toLength <= targetLength && fromLength> targetLength; break; } if (condition) { action.Invoke(); } }