public InspectorNeuron LoadNeuron(Vector2 position, int layer, int type) { InspectorNeuron Inspector = null; if ((_panel != null) && (_neurons != null) && (prefabNeuron != null)) { GameObject clone = Instantiate(prefabNeuron, position, transform.rotation) as GameObject; clone.name = "Neuron"; if (_neurons.transform.childCount < InsertLayer) { NewLauers(); } clone.transform.parent = _neurons.transform.GetChild(InsertLayer); clone.GetComponent <InspectorNeuron>().isNeuron = GetComponent <SpaceNeuron>().CreateNeuron(new Vector2(position.x, position.y), layer, type); clone.GetComponent <InspectorNeuron>().reColor(); clone.GetComponent <InspectorNeuron>().isNeuron.onAction += clone.GetComponent <InspectorNeuron>().OnActionNeuron; clone.GetComponent <InspectorNeuron>().isNeuron.deAction += clone.GetComponent <InspectorNeuron>().deActionNeuron; if (type == 2) { (clone.GetComponent <InspectorNeuron>().isNeuron.summator as SummatordIN).DeReActionNeuron += clone.GetComponent <InspectorNeuron>().DeReActionNeuron; } Inspector = clone.GetComponent <InspectorNeuron>(); } return(Inspector); }
void Load() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Application.dataPath + "/Data/" + PathFile + ".tad"); //открываем файл List <InspectorNeuron> ListInspector = new List <InspectorNeuron>(); int maxId = 0; foreach (XmlNode node in xmlDoc.SelectNodes("NetSave/Neurons/Neuron")) { int type = int.Parse(node.Attributes.GetNamedItem("Type").Value); Vector2 pos = new Vector2(float.Parse(node.Attributes.GetNamedItem("X").Value), float.Parse(node.Attributes.GetNamedItem("Y").Value)); int Layer = int.Parse(node.Attributes.GetNamedItem("Layer").Value); InspectorNeuron Inspector = GetComponent <InsertOneNeuron>().LoadNeuron(pos, Layer, type); int id = int.Parse(node.Attributes.GetNamedItem("IDNeuron").Value); Inspector.isNeuron.IDNeuron = id; if (id > maxId) { maxId = id; } if (node.Attributes["MaxSumm"] != null) { if (Inspector.isNeuron.summator.GetType() == typeof(SummatorSimple)) { (Inspector.isNeuron.summator as SummatorSimple).MaxSumm = float.Parse(node.Attributes.GetNamedItem("MaxSumm").Value); } if (Inspector.isNeuron.summator.GetType() == typeof(SummatordIN)) { (Inspector.isNeuron.summator as SummatordIN).MaxSumm = float.Parse(node.Attributes.GetNamedItem("MaxSumm").Value); } } if (node.Attributes["MinSumm"] != null) { if (Inspector.isNeuron.summator.GetType() == typeof(SummatorSimple)) { (Inspector.isNeuron.summator as SummatorSimple).MinSumm = float.Parse(node.Attributes.GetNamedItem("MinSumm").Value); } if (Inspector.isNeuron.summator.GetType() == typeof(SummatordIN)) { (Inspector.isNeuron.summator as SummatordIN).MinSumm = float.Parse(node.Attributes.GetNamedItem("MinSumm").Value); } } if (node.Attributes["threshold"] != null) { if (Inspector.isNeuron.summator.GetType() == typeof(SummatorSimple)) { (Inspector.isNeuron.summator as SummatorSimple).threshold = float.Parse(node.Attributes.GetNamedItem("threshold").Value); } if (Inspector.isNeuron.summator.GetType() == typeof(SummatordIN)) { (Inspector.isNeuron.summator as SummatordIN).threshold = float.Parse(node.Attributes.GetNamedItem("threshold").Value); } } if (node.Attributes["Dampfer"] != null) { if (Inspector.isNeuron.summator.GetType() == typeof(SummatorSimple)) { (Inspector.isNeuron.summator as SummatorSimple).Dampfer = float.Parse(node.Attributes.GetNamedItem("Dampfer").Value); } if (Inspector.isNeuron.summator.GetType() == typeof(SummatordIN)) { (Inspector.isNeuron.summator as SummatordIN).Dampfer = float.Parse(node.Attributes.GetNamedItem("Dampfer").Value); } } if (node.Attributes["AnswerTime"] != null) { if (Inspector.isNeuron.summator.GetType() == typeof(SummatorSimple)) { (Inspector.isNeuron.summator as SummatorSimple).AnswerTime = int.Parse(node.Attributes.GetNamedItem("AnswerTime").Value); } if (Inspector.isNeuron.summator.GetType() == typeof(SummatordIN)) { (Inspector.isNeuron.summator as SummatordIN).AnswerTime = int.Parse(node.Attributes.GetNamedItem("AnswerTime").Value); } } if (node.Attributes["ReposeTime"] != null) { if (Inspector.isNeuron.summator.GetType() == typeof(SummatorSimple)) { (Inspector.isNeuron.summator as SummatorSimple).ReposeTime = int.Parse(node.Attributes.GetNamedItem("ReposeTime").Value); } if (Inspector.isNeuron.summator.GetType() == typeof(SummatordIN)) { (Inspector.isNeuron.summator as SummatordIN).ReposeTime = int.Parse(node.Attributes.GetNamedItem("ReposeTime").Value); } } if (node.Attributes["MaxModul"] != null) { (Inspector.isNeuron.modulator as ModulatorMod).MaxModul = float.Parse(node.Attributes.GetNamedItem("MaxModul").Value); } if (node.Attributes["DampferM"] != null) { (Inspector.isNeuron.modulator as ModulatorMod).DampferM = float.Parse(node.Attributes.GetNamedItem("DampferM").Value); } if (node.Attributes["EvaluationTime"] != null) { (Inspector.isNeuron.modulator as ModulatorMod).EvaluationTime = int.Parse(node.Attributes.GetNamedItem("EvaluationTime").Value); } if (node.Attributes["IterationLimit"] != null) { (Inspector.isNeuron.modulator as ModulatorMod).IterationLimit = int.Parse(node.Attributes.GetNamedItem("IterationLimit").Value); } if (node.Attributes["thresholdUp"] != null) { (Inspector.isNeuron.modulator as ModulatorMod).thresholdUp = float.Parse(node.Attributes.GetNamedItem("thresholdUp").Value); } if (node.Attributes["StartAdaptTime"] != null) { (Inspector.isNeuron.modulator as ModulatorMod).StartAdaptTime = int.Parse(node.Attributes.GetNamedItem("StartAdaptTime").Value); } if (node.Attributes["SpeedAdapt"] != null) { (Inspector.isNeuron.modulator as ModulatorMod).SpeedAdapt = int.Parse(node.Attributes.GetNamedItem("SpeedAdapt").Value); } if (node.Attributes["MinThreshold"] != null) { (Inspector.isNeuron.modulator as ModulatorMod).MinThreshold = float.Parse(node.Attributes.GetNamedItem("MinThreshold").Value); } if (node.Attributes["thresholdDown"] != null) { (Inspector.isNeuron.summator as SummatordIN).thresholdDown = float.Parse(node.Attributes.GetNamedItem("thresholdDown").Value); } if (node.Attributes["TimeReAction"] != null) { (Inspector.isNeuron.summator as SummatordIN).TimeReAction = int.Parse(node.Attributes.GetNamedItem("TimeReAction").Value); } ListInspector.Add(Inspector); } GetComponent <SpaceNeuron>().MaxIDNeuron = maxId; foreach (XmlNode node in xmlDoc.SelectNodes("NetSave/Synapses/Synapse")) { int parentN = int.Parse(node.Attributes.GetNamedItem("parentNeuron").Value); int targetN = int.Parse(node.Attributes.GetNamedItem("targetNeuron").Value); GetComponent <InsertSynapse>().SynapseInsert(ListInspector[parentN].gameObject, ListInspector[targetN].gameObject); int indexS = int.Parse(node.Attributes.GetNamedItem("index").Value); GetComponent <SpaceNeuron>().SynapseList[indexS].TypeSynapse = int.Parse(node.Attributes.GetNamedItem("TypeSynapse").Value); GetComponent <SpaceNeuron>().SynapseList[indexS].descriptor = int.Parse(node.Attributes.GetNamedItem("descriptor").Value); GetComponent <SpaceNeuron>().SynapseList[indexS].Force = float.Parse(node.Attributes.GetNamedItem("Force").Value); GetComponent <SpaceNeuron>().SynapseList[indexS].Delay = int.Parse(node.Attributes.GetNamedItem("Delay").Value); GetComponent <SpaceNeuron>().SynapseList[indexS].Freeze = bool.Parse(node.Attributes.GetNamedItem("Freeze").Value); } foreach (GameObject value in listTols) { XmlNode node = xmlDoc.SelectSingleNode("NetSave/" + value.name); if (node.Attributes.GetNamedItem("target").Value != "-1") { value.GetComponentInChildren <ToolSelect>().LoodTool(ListInspector[int.Parse(node.Attributes.GetNamedItem("target").Value)].gameObject); } } }