Inheritance: dfInteractiveBase, IDFMultiRender, IRendersText
    /**
     * Create my own info box
     */
    void CreateMyPlayerInfoBox(Player pPlayer)
    {
        GameObject playerInfo = (GameObject)Instantiate(mMyPlayerInfoPrefab, Vector3.zero, Quaternion.identity);

        playerInfo.transform.parent = mPlayersList.gameObject.transform;

        dfTextbox myNameTextBox = (dfTextbox)playerInfo.GetComponentInChildren(typeof(dfTextbox));

        myNameTextBox.Text = pPlayer.uName;
        dfPropertyBinding.Bind(myNameTextBox.gameObject, myNameTextBox, "Text", pPlayer, "uName");

        dfDropdown myStation = (dfDropdown)playerInfo.GetComponentInChildren(typeof(dfDropdown));

        dfEventDrivenPropertyBinding.Bind(myStation.gameObject, pPlayer, "uAvailableStationNames", "AvailableStationsHaveChanged", myStation, "Items", null);

        dfPropertyBinding.Bind(myStation.gameObject, myStation, "SelectedIndex", pPlayer, "uSelectedStationIndex");

        dfTextureSprite stationLogo = playerInfo.transform.FindChild("StationLogo").GetComponent <dfTextureSprite>();

        dfPropertyBinding.Bind(stationLogo.gameObject, pPlayer, "uStationLogo", stationLogo, "Texture");

        dfTextureSprite d = playerInfo.transform.FindChild("IsPlayerReady").GetComponent <dfTextureSprite>();

        dfPropertyBinding.Bind(d.gameObject, pPlayer, "uReadyTexture", d, "Texture");
    }
    void Initialize()
    {
        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));
        }

        NameTextBox.Text = Settings.Brain.Name;


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

        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();

        GameObject.Find("Multiple Targets Checkbox").GetComponent <dfCheckbox>().IsChecked = Settings.Brain.MultipleTargets;

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

        GameObject.Find("TargetSize Slider").GetComponent <dfSlider>().Value = Settings.Brain.TargetSize > 0 ? Settings.Brain.TargetSize : 3;

        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;
            }
        }
    }
    void OnDropdownOpen(dfDropdown dropdown, dfListbox popup)
    {
        if (this.target != null)
        {
            StopCoroutine("animateOpen");
            StopCoroutine("animateClose");
            Destroy(this.target.gameObject);
        }

        this.target = popup;

        StartCoroutine(animateOpen(popup));
    }
Example #4
0
    void OnDropdownOpen( dfDropdown dropdown, dfListbox popup )
    {
        if( this.target != null )
        {
            StopCoroutine( "animateOpen" );
            StopCoroutine( "animateClose" );
            Destroy( this.target.gameObject );
        }

        this.target = popup;

        StartCoroutine( animateOpen( popup ) );
    }
Example #5
0
    private static void EditOptions(dfDropdown control)
    {
        GUILayout.BeginHorizontal();
        {
            EditorGUILayout.LabelField("Options", "", GUILayout.Width(100));

            EditorGUI.BeginChangeCheck();
            var optionsString = string.Join("\n", control.Items);
            var optionsEdit   = EditorGUILayout.TextArea(optionsString, GUILayout.Height(100f));
            if (EditorGUI.EndChangeCheck())
            {
                dfEditorUtil.MarkUndo(control, "Change options");
                var options = optionsEdit.Trim().Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
                control.Items = options;
            }
        }
        GUILayout.EndHorizontal();
    }
Example #6
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);
        }
    }
Example #7
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);
        }
    }
Example #8
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);
    }
    void Start()
    {
        if (Utility.IsWeb())
        {
            dfButton saveButton = GameObject.Find("SaveButton").GetComponent <dfButton> ();
            saveButton.Hide();
            dfTextbox saveText = GameObject.Find("NameTextbox").GetComponent <dfTextbox> ();
            saveText.Hide();
        }

        planet = GameObject.Find("Planet");
        mp     = planet.GetComponent <Planet> ();

        skyboxes = Utility.GetSkyboxes();
        dfDropdown skyboxDropdown = GameObject.Find("SkyBoxDropdown").GetComponent <dfDropdown> ();

        skyboxDropdown.Items         = skyboxes;
        skyboxDropdown.SelectedIndex = 0;

        planetNormals = Utility.GetPlanetNormals();
        dfDropdown normalDropdown = GameObject.Find("NormalDropdown").GetComponent <dfDropdown> ();

        normalDropdown.Items         = planetNormals;
        normalDropdown.SelectedIndex = 0;

        dfDropdown loadDropdown = GameObject.Find("LoadDropdown").GetComponent <dfDropdown> ();

        if (!Utility.IsWeb())
        {
            userPlanets        = Utility.GetAllFilesInFolder("config", "userplanet");
            loadDropdown.Items = userPlanets;
        }
        else
        {
            loadDropdown.Hide();
        }

        RedrawPlanet();
    }
Example #10
0
    private static void EditOptions( dfDropdown control )
    {
        GUILayout.BeginHorizontal();
        {

            EditorGUILayout.LabelField( "Options", "", GUILayout.Width( 100 ) );

            EditorGUI.BeginChangeCheck();
            var optionsString = string.Join( "\n", control.Items );
            var optionsEdit = EditorGUILayout.TextArea( optionsString, GUILayout.Height( 100f ) );
            if( EditorGUI.EndChangeCheck() )
            {
                dfEditorUtil.MarkUndo( control, "Change options" );
                var options = optionsEdit.Trim().Split( new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries );
                control.Items = options;
            }

        }
        GUILayout.EndHorizontal();
    }
 void OnDropdownClose(dfDropdown dropdown, dfListbox popup)
 {
     StartCoroutine(animateClose(popup));
 }
Example #12
0
 void OnDropdownClose( dfDropdown dropdown, dfListbox popup )
 {
     StartCoroutine( animateClose( popup ) );
 }
Example #13
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;
        }
    }