コード例 #1
0
    protected internal override void OnMouseWheel(dfMouseEventArgs args)
    {
        int      num   = (this.orientation != dfControlOrientation.Horizontal ? 1 : -1);
        dfSlider value = this;

        value.Value = value.Value + this.scrollSize * args.WheelDelta * (float)num;
        args.Use();
        base.Signal("OnMouseWheel", new object[] { args });
        base.RaiseEvent("MouseWheel", new object[] { this, args });
    }
コード例 #2
0
    public void OnSliderChanged(dfControl control, float value)
    {
        if (legit)
        {
            legit = false;
        }
        else
        {
            return;
        }
        dfSlider[] sliders   = new dfSlider[5];
        int        currIndex = 0;
        int        sum       = 0;

        //get the sum
        for (int i = 0; i < sliders.Length; i++)
        {
            sliders [i] = GameObject.Find("Slider" + (i + 1)).GetComponent <dfSlider> ();
            if (sliders [i] == control)
            {
                currIndex = i;
            }
            sum += (int)sliders [i].Value;
        }

        //check if sum adds up to one hunnered
        if (sum < 100)
        {
            int adjustIndex = (currIndex + 1) % sliders.Length;
            sliders [adjustIndex].Value += 100 - sum;
        }
        else if (sum > 100)
        {
            int adjustIndex = (currIndex + 1) % sliders.Length;
            do
            {
                print("sum:" + sum);
                int adjustmentNeeded = sum - 100;
                sum = (int)(sum - sliders [adjustIndex].Value);
                int adjustmentAvailable = (int)sliders [adjustIndex].Value;
                print("Slider preadjusted val:" + sliders [adjustIndex].Value);
                sliders [adjustIndex].Value -= Mathf.Min(adjustmentNeeded, adjustmentAvailable);
                print("Slider adjusted val:" + sliders [adjustIndex].Value);
                sum         = (int)(sum + sliders [adjustIndex].Value);
                adjustIndex = (adjustIndex + 1) % sliders.Length;
            } while (sum > 100);
        }

        legit = true;
    }
コード例 #3
0
    public void UpdateFromConVar()
    {
        dfSlider component = base.GetComponent <dfSlider>();

        if (component != null)
        {
            component.Value = ConVar.GetFloat(this.convarName, component.Value);
        }
        dfDropdown _dfDropdown = base.GetComponent <dfDropdown>();

        if (_dfDropdown != null)
        {
            if (!this.useValuesNotNumbers)
            {
                int num = ConVar.GetInt(this.convarName, -1f);
                if (num != -1)
                {
                    _dfDropdown.SelectedIndex = num;
                }
            }
            else
            {
                string str = ConVar.GetString(this.convarName, string.Empty);
                if (!string.IsNullOrEmpty(str))
                {
                    int selectedIndex = _dfDropdown.SelectedIndex;
                    _dfDropdown.SelectedValue = str;
                    if (_dfDropdown.SelectedIndex == -1)
                    {
                        _dfDropdown.SelectedIndex = selectedIndex;
                    }
                }
            }
        }
        dfCheckbox flag = base.GetComponent <dfCheckbox>();

        if (flag != null)
        {
            flag.IsChecked = ConVar.GetBool(this.convarName, flag.IsChecked);
        }
    }
コード例 #4
0
    public void UpdateFromConVar()
    {
        dfSlider component = base.GetComponent <dfSlider>();

        if (component != null)
        {
            component.Value = ConVar.GetFloat(this.convarName, component.Value);
        }
        dfDropdown dropdown = base.GetComponent <dfDropdown>();

        if (dropdown != null)
        {
            if (this.useValuesNotNumbers)
            {
                string str = ConVar.GetString(this.convarName, string.Empty);
                if (!string.IsNullOrEmpty(str))
                {
                    int selectedIndex = dropdown.SelectedIndex;
                    dropdown.SelectedValue = str;
                    if (dropdown.SelectedIndex == -1)
                    {
                        dropdown.SelectedIndex = selectedIndex;
                    }
                }
            }
            else
            {
                int @int = ConVar.GetInt(this.convarName, -1f);
                if (@int != -1)
                {
                    dropdown.SelectedIndex = @int;
                }
            }
        }
        dfCheckbox checkbox = base.GetComponent <dfCheckbox>();

        if (checkbox != null)
        {
            checkbox.IsChecked = ConVar.GetBool(this.convarName, checkbox.IsChecked);
        }
    }
コード例 #5
0
    public bool GetStringValueFromControl(out string value)
    {
        dfSlider component = base.GetComponent <dfSlider>();

        if (component != null)
        {
            value = component.Value.ToString();
            return(true);
        }
        dfDropdown _dfDropdown = base.GetComponent <dfDropdown>();

        if (!_dfDropdown)
        {
            dfCheckbox _dfCheckbox = base.GetComponent <dfCheckbox>();
            if (!_dfCheckbox)
            {
                value = string.Empty;
                return(false);
            }
            value = (!_dfCheckbox.IsChecked ? bool.FalseString : bool.TrueString);
            return(true);
        }
        int selectedIndex = _dfDropdown.SelectedIndex;

        if (selectedIndex == -1)
        {
            value = string.Empty;
            return(false);
        }
        if (!this.useValuesNotNumbers)
        {
            value = selectedIndex.ToString();
        }
        else
        {
            value = _dfDropdown.SelectedValue;
        }
        return(true);
    }
コード例 #6
0
 protected internal override void OnKeyDown(dfKeyEventArgs args)
 {
     if (this.Orientation != dfControlOrientation.Horizontal)
     {
         if (args.KeyCode == KeyCode.UpArrow)
         {
             dfSlider value = this;
             value.Value = value.Value - this.ScrollSize;
             args.Use();
             return;
         }
         if (args.KeyCode == KeyCode.DownArrow)
         {
             dfSlider _dfSlider = this;
             _dfSlider.Value = _dfSlider.Value + this.ScrollSize;
             args.Use();
             return;
         }
     }
     else
     {
         if (args.KeyCode == KeyCode.LeftArrow)
         {
             dfSlider value1 = this;
             value1.Value = value1.Value - this.ScrollSize;
             args.Use();
             return;
         }
         if (args.KeyCode == KeyCode.RightArrow)
         {
             dfSlider _dfSlider1 = this;
             _dfSlider1.Value = _dfSlider1.Value + this.ScrollSize;
             args.Use();
             return;
         }
     }
     base.OnKeyDown(args);
 }
コード例 #7
0
    private int GetEvolutionSpeed()
    {
        dfSlider slider = GameObject.Find("Speed Slider").GetComponent <dfSlider>();

        return(6 + (int)slider.Value);
    }
コード例 #8
0
 public void Start()
 {
     this.slider = GetComponent <dfSlider>();
 }
コード例 #9
0
 public void Start()
 {
     this.slider = GetComponent<dfSlider>();
 }
コード例 #10
0
    public void OnSliderChanged(dfControl control, float value)
    {
        if (legit) {
                        legit = false;
                } else {
                        return;
                }
                dfSlider[] sliders = new dfSlider[5];
                int currIndex = 0;
                int sum = 0;

                //get the sum
                for (int i = 0; i < sliders.Length; i++) {
                        sliders [i] = GameObject.Find ("Slider" + (i + 1)).GetComponent<dfSlider> ();
                        if (sliders [i] == control)
                                currIndex = i;
                        sum += (int)sliders [i].Value;
                }

                //check if sum adds up to one hunnered
                if (sum < 100) {
                        int adjustIndex = (currIndex + 1) % sliders.Length;
                        sliders [adjustIndex].Value += 100 - sum;
                } else if (sum > 100) {
                        int adjustIndex = (currIndex + 1) % sliders.Length;
                        do {
                                print ("sum:" + sum);
                                int adjustmentNeeded = sum - 100;
                                sum = (int)(sum - sliders [adjustIndex].Value);
                                int adjustmentAvailable = (int)sliders [adjustIndex].Value;
                                print ("Slider preadjusted val:" + sliders [adjustIndex].Value);
                                sliders [adjustIndex].Value -= Mathf.Min (adjustmentNeeded, adjustmentAvailable);
                                print ("Slider adjusted val:" + sliders [adjustIndex].Value);
                                sum = (int)(sum + sliders [adjustIndex].Value);
                                adjustIndex = (adjustIndex + 1) % sliders.Length;
                        } while (sum > 100);
                }

                legit = true;
    }
コード例 #11
0
    // Use this for initialization
    void Start()
    {
        if (Settings.Brain == null)
        {
            Settings.Brain = new Brain();
        }
        if (Settings.Brain.Population != null)
        {
            TrainButton.Disable();
            StartCoroutine(WaitForRequest(Settings.Brain, true));
        }
        if (Settings.Brain.ChampionGene != null)
        {
            TrainButton.Disable();
            StartCoroutine(WaitForRequest(Settings.Brain, false));
        }
        //   if (!Settings.IsNewBrain && Settings.Brain.Name != null && Settings.Brain.Name.Length > 0)
        {
            NameTextbox.Text = Settings.Brain.Name;
        }
        //     if (!Settings.IsNewBrain && Settings.Brain.Description != null && Settings.Brain.Description.Length > 0)
        {
            DescriptionTextBox.Text = Settings.Brain.Description;
        }

        GameObject.Find("s_DistanceToKeep").GetComponent <dfSlider>().Value = Settings.Brain.DistanceToKeep;
        GameObject.Find("s_KeepDistance").GetComponent <dfSlider>().Value   = Settings.Brain.KeepDistance;

        GameObject.Find("s_FaceTarget").GetComponent <dfSlider>().Value         = Settings.Brain.FaceTarget;
        GameObject.Find("s_TurretFaceTarget").GetComponent <dfSlider>().Value   = Settings.Brain.TurretFaceTarget;
        GameObject.Find("s_MeleeAttacks").GetComponent <dfSlider>().Value       = Settings.Brain.MeleeAttacks;
        GameObject.Find("s_MeleeHits").GetComponent <dfSlider>().Value          = Settings.Brain.MeleeHits;
        GameObject.Find("s_MeleePrecision").GetComponent <dfSlider>().Value     = Settings.Brain.MeleePrecision;
        GameObject.Find("s_RifleAttacks").GetComponent <dfSlider>().Value       = Settings.Brain.RifleAttacks;
        GameObject.Find("s_RifleHits").GetComponent <dfSlider>().Value          = Settings.Brain.RifleHits;
        GameObject.Find("s_RiflePrecision").GetComponent <dfSlider>().Value     = Settings.Brain.RiflePrecision;
        GameObject.Find("s_MortarAttacks").GetComponent <dfSlider>().Value      = Settings.Brain.MortarAttacks;
        GameObject.Find("s_MortarHits").GetComponent <dfSlider>().Value         = Settings.Brain.MortarHits;
        GameObject.Find("s_MortarPrecision").GetComponent <dfSlider>().Value    = Settings.Brain.MortarPrecision;
        GameObject.Find("s_MortarDamagePerHit").GetComponent <dfSlider>().Value = Settings.Brain.MortarDamagePerHit;
        GameObject.Find("s_MortarDamagePerHit").GetComponent <dfSlider>().PerformLayout();

        // Simple fitness values
        //GameObject.Find("SMovement Checkbox").GetComponent<dfCheckbox>().IsChecked = Settings.Brain.SMovement;
        //GameObject.Find("SDistance Slider").GetComponent<dfSlider>().Value = Settings.Brain.SDistance;
        //GameObject.Find("SMelee Checkbox").GetComponent<dfCheckbox>().IsChecked = Settings.Brain.SMelee;
        //GameObject.Find("SRifle Checkbox").GetComponent<dfCheckbox>().IsChecked = Settings.Brain.SRifle;
        //GameObject.Find("SMortar Checkbox").GetComponent<dfCheckbox>().IsChecked = Settings.Brain.SMortar;

        dfDropdown dropdown = GameObject.Find("Target Movement Dropdown").GetComponent <dfDropdown>();

        int index = 0;

        dropdown.SelectedIndex = index;
        for (index = 0; index < dropdown.Items.Length; index++)
        {
            if (dropdown.Items[index].Equals(Settings.Brain.TargetBehaviorMovement))
            {
                dropdown.SelectedIndex = index;
                break;
            }
        }

        switch (Settings.Brain.FitnessMode)
        {
        case Brain.SIMPLE:
            TabStrip.SelectedIndex = 0;
            break;

        case Brain.ADVANCED:
            TabStrip.SelectedIndex = 1;
            break;

        case Brain.BATTLE:
            TabStrip.SelectedIndex = 2;
            break;
        }

        dfSlider slider   = GameObject.Find("Speed Slider").GetComponent <dfSlider>();
        int      evoSpeed = PlayerPrefs.GetInt("Evolution Speed");

        if (evoSpeed >= 6 && evoSpeed <= 10)
        {
            slider.Value = evoSpeed - 6;
        }
        else
        {
            slider.Value = 2;
        }
    }