Пример #1
0
    private void NewNeironVoid()
    {
        GameObject clone = (GameObject)Instantiate(prefabNeiron, GizmaNeiron.transform.position, prefabNeiron.transform.rotation);

        foreach (GameObject AreaBouns in gameObject.GetComponent <ManagerArea>().hitArea)
        {
            if (AreaBouns.GetComponent <Collider>().bounds.Contains(clone.transform.position))
            {
                clone.GetComponent <NeironScript>().Area = AreaBouns;
                AreaBouns.GetComponent <AreaScript>().amount++;
                break;
            }
        }
        if (clone.GetComponent <NeironScript>().Area == null)
        {
            clone.GetComponent <NeironScript> ().Area = GlobalArea;
        }
        clone.GetComponent <NeironScript>().Area.GetComponent <AreaScript>().amount++;
        clone.GetComponent <NeironScript>().TypeIndexNeiron = selNewGrid;
        EndIndexNeiron++;
        clone.GetComponent <NeironScript>().IndexNeiron = EndIndexNeiron;
        clone.name = "Neiron" + EndIndexNeiron;
    }
Пример #2
0
    void OnGUI()
    {
        //...............................................................................................................................
        if (!AddNeironBool)
        {
            if (GUI.Button(new Rect(210, 10, 80, 20), "Edit"))
            {
                AddNeironBool = true;
                GizmaNeiron.transform.position = CamTarget.position;
                GizmaNeiron.SetActive(true);
            }
        }
        else
        {
            if (GUI.Button(new Rect(210, 10, 80, 20), "Add neuron"))
            {
                Collider[] hitColliders = Physics.OverlapSphere(GizmaNeiron.transform.position, 1f);
                bool       ExistNeiron  = false;
                foreach (Collider coll in hitColliders)
                {
                    if (coll.tag == "Neiron")
                    {
                        ExistNeiron = true;
                        break;
                    }
                }
                if (!ExistNeiron)
                {
                    NewNeironVoid();
                    AddNeironBool = false;
                    GizmaNeiron.SetActive(false);
                }
            }
            if (GUI.Button(new Rect(291, 10, 50, 20), "END"))
            {
                AddNeironBool = false;
                GizmaNeiron.SetActive(false);
            }
            selNewGrid = GUI.SelectionGrid(new Rect(210, 31, 130, 20), selNewGrid, selStrings, selStrings.Length);
        }
        //..................................................................................................................................



        if (Selektor != null)
        {
            GUI.Label(new Rect(200, 130, 200, 20), "Charge: " + Selektor.GetComponent <NeironScript>().Charge.ToString());

            foreach (GameObject value in Selektor.GetComponent <NeironScript>().hitSinaps)
            {
                GameObject valueLevel     = value.GetComponent <SinapsScript>().NeironTarget;
                Vector3    screenPosition = Camera.main.WorldToScreenPoint(valueLevel.transform.position);
                Vector3    cameraRelative = Camera.main.transform.InverseTransformPoint(valueLevel.transform.position);
                if (cameraRelative.z > 0)
                {
                    Rect position = new Rect(screenPosition.x + 10f, Screen.height - screenPosition.y - 23f, 100f, 20f);
                    GUI.Label(position, "" + value.GetComponent <SinapsScript>().Force.ToString("0.0"));
                }
            }


            GUI.Label(new Rect(5, 5, 180, 20), "Index neuron: " + Selektor.GetComponent <NeironScript>().IndexNeiron);
            selGridInt = GUI.SelectionGrid(new Rect(5, 30, 180, 20), selGridInt, selStrings, selStrings.Length);
            if (selGridInt != Selektor.GetComponent <NeironScript>().TypeIndexNeiron)
            {
                Selektor.GetComponent <NeironScript>().TypeIndexNeiron = selGridInt;
            }

            if (!AddSinapsBool)
            {
                if (GUI.Button(new Rect(5, 55, 180, 20), "Add synapse"))
                {
                    AddSinapsBool = true;
                }
            }
            else
            {
                GUI.Label(new Rect(5, 55, 250, 20), "Select neuron on target synapse..");
            }

            if (Selektor.GetComponent <NeironScript>().Area != null)
            {
                string AreaButton = "";
                if (Selektor.GetComponent <NeironScript>().Area.GetComponent <AreaScript>().Global)
                {
                    AreaButton = "Clear Global Area";
                }
                else
                {
                    AreaButton = "Clear Area";
                    GUI.Label(new Rect(5, 105, 180, 20), "" + Selektor.GetComponent <NeironScript>().Area.GetComponent <AreaScript>().Name);
                }
                if (GUI.Button(new Rect(5, 80, 180, 20), AreaButton))
                {
                    Selektor.GetComponent <NeironScript>().Area.GetComponent <AreaScript>().amount--;
                    Selektor.GetComponent <NeironScript>().Area = null;
                }
            }
            else
            {
                if (GUI.Button(new Rect(5, 80, 180, 20), "Add Global Area"))
                {
                    Selektor.GetComponent <NeironScript>().Area = GlobalArea;
                    GlobalArea.GetComponent <AreaScript>().amount++;
                }
                if (GUI.Button(new Rect(5, 105, 180, 20), "Add Included Area"))
                {
                    foreach (GameObject AreaBouns in gameObject.GetComponent <ManagerArea>().hitArea)
                    {
                        if (AreaBouns.GetComponent <Collider>().bounds.Contains(Selektor.transform.position))
                        {
                            Selektor.GetComponent <NeironScript>().Area = AreaBouns;
                            AreaBouns.GetComponent <AreaScript>().amount++;
                            break;
                        }
                        if (Selektor.GetComponent <NeironScript>().Area == null)
                        {
                            Selektor.GetComponent <NeironScript>().Area = GlobalArea;
                        }
                    }
                }
            }

            GUILayout.BeginArea(new Rect(5, 130, 180, Screen.height - 160), GUI.skin.box);
            _inventoryScroll = GUILayout.BeginScrollView(_inventoryScroll, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));

            GUILayout.Label("Adder:  " + Selektor.GetComponent <NeironScript>().Adder);
            GUILayout.Label("Max adder: ");
            MaxAdderString = GUILayout.TextField(MaxAdderString);
            GUILayout.Label("Damper: ");
            DampferAdderString = GUILayout.TextField(DampferAdderString);
            GUILayout.Label("Upper threshold:");
            thresholdTopString = GUILayout.TextField(thresholdTopString);
            GUILayout.Label("Response time: ");
            AnswerTimeString = GUILayout.TextField(AnswerTimeString);
            GUILayout.Label("Time relax: ");
            TimeReposeString = GUILayout.TextField(TimeReposeString);

            if (Selektor.GetComponent <NeironScript>().TypeIndexNeiron > 0)
            {
                GUILayout.Label("____________________");
                GUILayout.Label("t.Top + t.Bonus (t.Bonus)");
                float t = Selektor.GetComponent <NeironScript>().thresholdTop + Selektor.GetComponent <NeironScript>().bonusThreshold;
                GUILayout.Label(" " + t + "  (" + Selektor.GetComponent <NeironScript>().bonusThreshold + ")");
                GUILayout.Label("Lower threshold");
                thresholdDownString = GUILayout.TextField(thresholdDownString);
                GUILayout.Label("Negative time");
                timeIgnoreString = GUILayout.TextField(timeIgnoreString);
                GUILayout.Label("Damper threshold");
                DempferBonusThresholdString = GUILayout.TextField(DempferBonusThresholdString);
                GUILayout.Label("Valuation time");
                TimeEvaluationString = GUILayout.TextField(TimeEvaluationString);
                GUILayout.Label("Limit repeats");
                LimitRecurrenceString = GUILayout.TextField(LimitRecurrenceString);
                GUILayout.Label("Increasing threshold");
                thresholdTopUpString = GUILayout.TextField(thresholdTopUpString);
                GUILayout.Label("Adaptation time");
                AdaptationTimeString = GUILayout.TextField(AdaptationTimeString);
                GUILayout.Label("Basic threshold");
                thresholdAdaptString = GUILayout.TextField(thresholdAdaptString);
            }

            if (Selektor.GetComponent <NeironScript>().TypeIndexNeiron == 2)
            {
                GUILayout.Label("____________________");
                GUILayout.Label("Max force synapse:");
                MaxForceSinapsString = GUILayout.TextField(MaxForceSinapsString);
                GUILayout.Label("Speed:");
                TimeChargeString    = GUILayout.TextField(TimeChargeString);
                FocusDinamicSetting = GUILayout.Toggle(FocusDinamicSetting, "Focus Dynamics");
                if (FocusDinamicSetting)
                {
                    GUILayout.Label("Focus: " + Selektor.GetComponent <NeironScript>().FocusNeiron.ToString());
                    GUILayout.Label("Max focus: ");
                    MaxFocusNeironString = GUILayout.TextField(MaxFocusNeironString);
                    GUILayout.Label("Focus step:");
                    StepFocusString = GUILayout.TextField(StepFocusString);
                }
                else
                {
                    GUILayout.Label("Focus:");
                    FocusNeironString = GUILayout.TextField(FocusNeironString);
                }

                PlasticityDinamicSetting = GUILayout.Toggle(PlasticityDinamicSetting, "Plastic Dynamics");
                if (PlasticityDinamicSetting)
                {
                    GUILayout.Label("Plastic: " + Selektor.GetComponent <NeironScript>().Plasticity.ToString());
                    GUILayout.Label("Basic Plastic:");
                    BasicPlasticityString = GUILayout.TextField(BasicPlasticityString);
                    GUILayout.Label("Plastic step:");
                    StepPlasticityString = GUILayout.TextField(StepPlasticityString);
                }
                else
                {
                    GUILayout.Label("Plastic:");
                    PlasticityString = GUILayout.TextField(PlasticityString);
                    GUILayout.Label("Basic Plastic:");
                    BasicPlasticityString = GUILayout.TextField(BasicPlasticityString);
                }

                NewNeironDinamicSetting = GUILayout.Toggle(NewNeironDinamicSetting, "Dynamic net");
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();

            if (GUI.Button(new Rect(150, Screen.height - 25, 30, 20), "OK"))
            {
                Selektor.GetComponent <NeironScript>().MaxAdder = float.Parse(MaxAdderString);

                Selektor.GetComponent <NeironScript>().DampferAdder = float.Parse(DampferAdderString);
                Selektor.GetComponent <NeironScript>().thresholdTop = float.Parse(thresholdTopString);
                Selektor.GetComponent <NeironScript>().AnswerTime   = float.Parse(AnswerTimeString);
                Selektor.GetComponent <NeironScript>().TimeRepose   = float.Parse(TimeReposeString);

                Selektor.GetComponent <NeironScript>().thresholdDown         = float.Parse(thresholdDownString);
                Selektor.GetComponent <NeironScript>().timeIgnore            = float.Parse(timeIgnoreString);
                Selektor.GetComponent <NeironScript>().DempferBonusThreshold = float.Parse(DempferBonusThresholdString);
                Selektor.GetComponent <NeironScript>().TimeEvaluation        = float.Parse(TimeEvaluationString);
                Selektor.GetComponent <NeironScript>().LimitRecurrence       = int.Parse(LimitRecurrenceString);
                Selektor.GetComponent <NeironScript>().thresholdTopUp        = float.Parse(thresholdTopUpString);

                Selektor.GetComponent <NeironScript>().AdaptationTime = float.Parse(AdaptationTimeString);
                Selektor.GetComponent <NeironScript>().thresholdAdapt = float.Parse(thresholdAdaptString);

                Selektor.GetComponent <NeironScript>().MaxForceSinaps = float.Parse(MaxForceSinapsString);
                Selektor.GetComponent <NeironScript>().TimeCharge     = float.Parse(TimeChargeString);
                Selektor.GetComponent <NeironScript>().FocusNeiron    = float.Parse(FocusNeironString);
                Selektor.GetComponent <NeironScript>().MaxFocus       = float.Parse(MaxFocusNeironString);
                Selektor.GetComponent <NeironScript>().StepFocus      = float.Parse(StepFocusString);

                Selektor.GetComponent <NeironScript>().Plasticity      = float.Parse(PlasticityString);
                Selektor.GetComponent <NeironScript>().BasicPlasticity = float.Parse(BasicPlasticityString);
                Selektor.GetComponent <NeironScript>().StepPlasticity  = float.Parse(StepPlasticityString);

                Selektor.GetComponent <NeironScript>().FocusDinamic      = FocusDinamicSetting;
                Selektor.GetComponent <NeironScript>().PlasticityDinamic = PlasticityDinamicSetting;
                Selektor.GetComponent <NeironScript>().NewNeironDinamic  = NewNeironDinamicSetting;
            }

            if (GUI.Button(new Rect(5, Screen.height - 25, 100, 20), "Delete neuron"))
            {
                DeleteNeiron();
            }
        }

        if (WindowS)
        {
            WindowsRect = GUI.Window(0, WindowsRect, DoMyWindow, "");
        }
    }