Exemplo n.º 1
0
 private void OnSliderValueChanged(GroupedSlider argSlider)
 {
     if (!argSlider.changing)
     {
         //Normalize( argSlider );
         CreatureSliderUpdateEvent(argSlider.buttonType, argSlider.sliderType, (int)argSlider.slider.value);
     }
 }
Exemplo n.º 2
0
        private void NormalizeByInt(GroupedSlider argFixed)
        {
            int total         = 0;
            int nonFixedTotal = 0;

            foreach (GroupedSlider slider in sliders)
            {
                slider.changing = true;

                total += (int)slider.slider.value;
                if (slider != argFixed)
                {
                    nonFixedTotal += (int)slider.slider.value;
                }
            }

            //if(total != desiredTotal)
        }
Exemplo n.º 3
0
        private void Normalize(GroupedSlider argFixed)
        {
            // get current total

            float total         = 0f;
            float nonFixedTotal = 0f;

            foreach (GroupedSlider slider in sliders)
            {
                slider.changing = true;

                total += slider.slider.value;
                if (slider != argFixed)
                {
                    nonFixedTotal += slider.slider.value;
                }
            }

            if (total != desiredTotal)
            {
                float totalLeftForNonFixed = desiredTotal - argFixed.slider.value;

                foreach (GroupedSlider slider in sliders)
                {
                    if (slider != argFixed)
                    {
                        if (nonFixedTotal == 0)
                        {
                            slider.slider.value = totalLeftForNonFixed / (float)(sliders.Count - 1);
                        }
                        else
                        {
                            slider.slider.value = slider.slider.value * totalLeftForNonFixed / nonFixedTotal;
                        }
                    }
                }
            }

            foreach (GroupedSlider slider in sliders)
            {
                slider.changing = false;
            }
        }
Exemplo n.º 4
0
 public void RegisterSlider(GroupedSlider argSlider)
 {
     sliders.Add(argSlider);
     argSlider.slider.onValueChanged.AddListener(delegate { OnSliderValueChanged(argSlider); });
     Normalize(argSlider);
 }