private void UserChangeValue() { if (!dragging) { return; } int newValue = Value; if (conflictIdx != null) { OnUnconflicted?.Invoke((int)conflictIdx); } conflictIdx = FindConflict(newValue); if (conflictIdx != null) { OnConflicted?.Invoke((int)conflictIdx); snapBackValue = currentValue; slider.targetGraphic.color = fill.color = Color.red; } else { OnUserSlid?.Invoke(currentValue, newValue); conflictIdx = null; snapBackValue = null; currentValue = newValue; slider.targetGraphic.color = fill.color = Color.white; } }
void Start() { nameField.OnUserNameChanged += s => SetNameFromInputField(s); sizeTrait.OnUserSlid += (x, y) => SetSizeFromSlider(x, y); greedTrait.OnUserSlid += (x, y) => SetGreedFromSlider(x, y); // x here is value to check, and the function returns the idx of the conflict sizeTrait.AddExternalConflict(x => CheckSizeConflict(x)); greedTrait.AddExternalConflict(x => CheckGreedConflict(x)); sizeTrait.OnConflicted += i => OnConflicted?.Invoke(i, "Identical"); greedTrait.OnConflicted += i => OnConflicted?.Invoke(i, "Identical"); sizeTrait.OnUnconflicted += i => OnUnconflicted?.Invoke(i); greedTrait.OnUnconflicted += i => OnUnconflicted?.Invoke(i); initiator.OnProducerWanted += () => IncubateNew(true); initiator.OnConsumerWanted += () => IncubateNew(false); incubator.OnDropped += () => SpawnIncubated(); }