Exemple #1
0
    // Computation of the absolute x and z coordinates for each node
    private void SecondWalk(GenericOperator nodeN, float x, float z, float l, float t)
    {
        IconProperties np  = nodeN.GetIcon().GetComponent <IconProperties>();
        Vector3        pos = new Vector3(x, 2, z);

        l = np.depth / (np.depth + 1);

        nodeN.GetIcon().transform.position = pos;
        float dd        = l * np.d;
        float p         = t + Mathf.PI;
        float freeSpace = (nodeN.Children.Count == 0 ? 0 : np.f / (nodeN.Children.Count + 1));
        float previous  = 0;

        foreach (var child in nodeN.Children)
        {
            IconProperties cp = child.GetIcon().GetComponent <IconProperties>();
            float          aa = np.c * cp.a;
            float          rr = np.d * Mathf.Tan(aa) / (1 - Mathf.Tan(aa));
            p += previous + aa + freeSpace;
            float xx = (l * rr + dd) * Mathf.Cos(p);
            float zz = (l * rr + dd) * Mathf.Sin(p);
            previous = aa;
            SecondWalk(child, x + xx, z + zz, l * np.c, p);
        }
    }
    private void drawConnectionToChildren(GenericOperator go)
    {
        if (go.Children == null || go.Children.Count == 0)
        {
            return;
        }
        foreach (GenericOperator child in go.Children)
        {
            if (go.GetIcon() == null || child == null || child.GetIcon() == null)
            {
                continue;
            }

            GameObject   line         = new GameObject();
            LineRenderer lineRenderer = line.AddComponent <LineRenderer>();
            lineRenderer.SetWidth(0.01f, 0.01f);

            lineRenderer.SetPositions(new Vector3[] {
                go.GetIcon().transform.position + new Vector3(0, 0, 0.001f), child.GetIcon().transform.position + new Vector3(0, 0, 0.001f)
            });
            line.transform.parent         = Container.transform;
            lineRenderer.transform.parent = Container.transform;
            graphEdges.Add(line);
        }
    }
        public void displayOptions()
        {
            optionIconPrefabs = new List <GenericIcon>();
            lines             = new List <GameObject>();
            var prefabs = GetOperator().Observer.GetOperatorPrefabs();

            operatorPrefabs = new List <GameObject>();

            foreach (GameObject prefab in prefabs)
            {
                //first validate if the respective prefab can be used with the current parent
                if (prefab.GetComponent <GenericOperator>().ValidateIfOperatorPossibleForParents(ClickedOp))
                {
                    optionIconPrefabs.Add(prefab.GetComponent <GenericOperator>().GetComponentInChildren <GenericIcon>());
                    operatorPrefabs.Add(prefab);
                }
            }

            optionIcons = new List <GenericIcon>();
            foreach (GenericIcon optionIcon in optionIconPrefabs)
            {
                GenericIcon  instance = GameObject.Instantiate(optionIcon);
                Targetable[] scripts  = instance.GetComponentsInChildren <Targetable>();
                foreach (Targetable script in scripts)
                {
                    Destroy(script);
                }

                instance.transform.parent     = ClickedOp.GetIcon().transform.parent;
                instance.transform.localScale = ClickedOp.GetIcon().transform.localScale;
                instance.transform.position   = getSpawnPositionOffsetForButton(ClickedOp.GetIcon().transform, optionIcons.Count, optionIconPrefabs.Count);

                foreach (Transform child in instance.gameObject.GetComponentsInChildren <Transform>())
                {
                    child.gameObject.AddComponent <NewIconInteractionButton>();
                    child.gameObject.GetComponent <NewIconInteractionButton>().controller = this;
                    child.gameObject.GetComponent <NewIconInteractionButton>().id         = optionIcons.Count;
                }

                optionIcons.Add(instance);

                // add lines between the icons
                GameObject   line         = new GameObject();
                LineRenderer lineRenderer = line.AddComponent <LineRenderer>();
                lineRenderer.SetWidth(0.01f, 0.01f);
                lineRenderer.SetPositions(new Vector3[] {
                    GetOperator().GetIcon().transform.position + new Vector3(0, 0, 0.001f), instance.transform.position + new Vector3(0, 0, 0.001f)
                });

                lines.Add(line);
            }
            optionsDisplayed = true;
        }
    public void moveToSpawnPosition(GenericOperator op)
    {
        if (op.GetType().Equals((typeof(NewOperator))) && op.Parents != null)
        {
            op.GetIcon().transform.position = op.Parents[0].GetIcon().transform.position + new Vector3(1, 0, 0);
        }

        if (op.Parents != null && op.Parents.Count > 0 && op.Parents[0].Children != null)
        {
            op.GetIcon().transform.position += new Vector3(0, (op.Parents[0].Children.Count - 1) * 0.3f, 0);
        }
    }
    IEnumerator SetIconLocation(GenericOperator op, Vector3 position)
    {
        yield return(0);

        op.GetIcon().transform.position = position;
        op.Fetchdata();
        op.Process();
    }
Exemple #6
0
 // Update is called once per frame
 void Update()
 {
     if (runConeTree)
     {
         root        = observer.GetOperators()[0];
         _anchor     = root.GetIcon().transform.position;
         runConeTree = false;
         Layout(root, _anchor.x, _anchor.z);
     }
 }
 public void moveNewIconAndDestroyOperator(GenericOperator genericOperator)
 {
     if (spawnedPrefab.GetComponent <GenericOperator>() == genericOperator) //genericOperator.GetType().Equals((typeof(NewOperator))) &&
     {
         genericOperator.GetIcon().gameObject.transform.localPosition =
             GetOperator().GetIcon().transform.localPosition;
         GetOperator().Observer.NewOperatorInitializedAndRunnningEvent -= moveNewIconAndDestroyOperator;
         GetOperator().Observer.DestroyOperator(GetOperator());
     }
 }
Exemple #8
0
    /* Bottom up proceeding, computing value for distances
     * possibly computing scaling factor for children and
     * computing radius of circles
     */
    private void FirstWalk(GenericOperator node)
    {
        IconProperties np = node.GetIcon().GetComponent <IconProperties>();

        np.d = 0;
        float s = 0;

        foreach (var child in node.Children)
        {
            FirstWalk(child);
            IconProperties cp = child.GetIcon().GetComponent <IconProperties>();
            np.d = Mathf.Max(np.d, cp.r);
            cp.a = Mathf.Atan(cp.r / (np.d + cp.r));
            s   += cp.a;
        }
        AdjustChildren(np, s);
        SetRadius(np);
    }
 public void InstallNewIcon(GenericOperator op)
 {
     op.GetIcon().gameObject.transform.parent = GameObject.Find("ControlWall").transform;
     op.GetIcon().gameObject.transform.localPosition = new Vector3(-0.4f, 0, 0);
     op.GetIcon().gameObject.transform.localScale = _scale;
 }
 private void ApplyForce(GenericOperator op, Vector3 force)
 {
     op.GetIcon().GetComponent <IconProperties>().ApplyForce(force);
 }