コード例 #1
0
ファイル: StartLogic.cs プロジェクト: IoTUDresden/HoloFlows
        public void OnInputClicked(InputClickedEventData eventData)
        {
            if (SourceName.Contains("dimmer"))
            {
                if (SourceType.Equals("Sensor"))
                {
                    SourceName = SourceName + "_Sensor";
                }
                else
                {
                    SourceName = SourceName + "_Actuator";
                }
            }

            Item source = ItemManager.getInstance().getItem(SourceName);
            Item target = ItemManager.getInstance().getItem(TargetName);

            AktuellesFenster   = this.gameObject.transform.parent;
            AktuellesFensterGO = this.gameObject.transform.parent.gameObject;
            Line = GameObject.Find(LineID);

            if ((source is Poti && target is DimmerActuator) || (source is Poti && target is HueDimmer) || (source is ColorSensor && target is HueDimmer))
            {
                this.transform.localScale = new Vector3(0, 0, 0);
                Debug.Log("ich versuche auf (0 0 0) zu skalieren: " + this.transform.name);
                AktuellesFensterGO.transform.GetChild(2).transform.localScale = new Vector3(0, 0, 0);
                Debug.Log("ich versuche auf (0 0 0) zu skalieren: " + AktuellesFensterGO.transform.GetChild(2).name);
                AktuellesFensterGO.transform.GetChild(3).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                Debug.Log("ich versuche auf (0,1 0,1 0,1) zu skalieren: " + AktuellesFensterGO.transform.GetChild(3).name);
                AktuellesFensterGO.transform.GetChild(4).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                Debug.Log("ich versuche auf (0,1 0,1 0,1) zu skalieren: " + AktuellesFensterGO.transform.GetChild(4).name);

                if (!ConnectionManager.getInstance().getConnections().ContainsKey(LineID))
                {
                    if (source is Poti)
                    {
                        if (target is DimmerActuator)
                        {
                            this.c = ConnectionCreator.createPotiDimmerConnection(LineID, SourceName, TargetName);
                        }
                        else
                        {
                            this.c = ConnectionCreator.createPotiHueConnection(LineID, SourceName, TargetName);
                        }
                    }
                    else
                    {
                        this.c = ConnectionCreator.createColorHueConnection(LineID, SourceName, TargetName);
                    }
                    ConnectionManager.getInstance().startConnection(LineID);
                }
                else
                {
                    ConnectionManager.getInstance().startConnection(LineID);
                }
            }

            else
            {
                if (source is Sensor)
                {
                    Destroy(AktuellesFensterGO);
                    LogicSenActInitializer = Instantiate(LogicSenActPrefabb) as Transform;
                    LogicSenActInitializer.transform.position = FensterPoss;
                    LogicSenActInitializer.name = "Window_" + SourceName + TargetName;
                    EingabeFensterName          = LogicSenActInitializer.name; // weiß nicht ob es sinnvoll ist das nochmal irgendwohin zu übergeben
                    LogicSenActInitializer.GetChild(0).GetChild(1).GetChild(1).GetComponent <Text>().text = SourceNameShort;
                    LogicSenActInitializer.GetChild(0).GetChild(3).GetChild(1).GetComponent <Text>().text = TargetNameShort;
                    LogicSenActInitializer.GetChild(0).GetChild(2).GetChild(2).GetComponent <Text>().text = source.state;
                    Debug.Log("source " + SourceName + " is of type " + SourceType);
                    Sensor Sens = (Sensor)source;
                    LogicSenActInitializer.GetChild(0).GetChild(2).GetChild(4).GetComponent <Text>().text = Sens.unit;

                    LogicSenActInitializer.GetComponent <LogicSenActInput>().SourceName = SourceName;
                    LogicSenActInitializer.GetComponent <LogicSenActInput>().TargetName = TargetName;
                    LogicSenActInitializer.GetComponent <LogicSenActInput>().LineID     = LineID;

                    LogicSenActInitializer.GetChild(2).GetComponent <DeleteConnection>().LineID = LineID;

                    LogicSenActInitializer.GetChild(1).GetComponent <StopConnection>().LineID = LineID;
                    LogicSenActInitializer.GetChild(1).transform.localScale = new Vector3(0, 0, 0);
                }

                else
                {
                    Destroy(AktuellesFensterGO);
                    LogicActActInitializer = Instantiate(LogicActActPrefabb) as Transform;
                    LogicActActInitializer.transform.position = FensterPoss;
                    LogicActActInitializer.name = "Window_" + SourceName + TargetName;
                    EingabeFensterName          = LogicActActInitializer.name; // weiß nicht ob es sinnvoll ist das nochmal irgendwohin zu übergeben

                    LogicActActInitializer.GetChild(0).GetChild(1).GetChild(1).GetComponent <Text>().text = SourceNameShort;
                    LogicActActInitializer.GetChild(0).GetChild(2).GetChild(1).GetComponent <Text>().text = TargetNameShort;

                    LogicActActInitializer.GetChild(3).GetComponent <StartActActConnection>().SourceNamelong = SourceName;
                    LogicActActInitializer.GetChild(3).GetComponent <StartActActConnection>().TargetNamelong = TargetName;
                    LogicActActInitializer.GetChild(3).GetComponent <StartActActConnection>().LineID         = LineID;

                    LogicActActInitializer.GetChild(2).GetComponent <DeleteConnection>().LineID = LineID;

                    LogicActActInitializer.GetChild(1).GetComponent <StopConnection>().LineID = LineID;
                    LogicActActInitializer.GetChild(1).transform.localScale = new Vector3(0, 0, 0);
                }
            }

            isSelected = !isSelected;
        }