Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
 private void UndoConflict()
 {
     if (snapBackValue != null)
     {
         SetValueWithoutCallback((int)snapBackValue);
         snapBackValue = null;
     }
     if (conflictIdx != null)
     {
         OnUnconflicted?.Invoke((int)conflictIdx);
         conflictIdx = null;
         slider.targetGraphic.color = fill.color = Color.white;
     }
 }
Ejemplo n.º 3
0
        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();
        }