Пример #1
0
    // Use this for initialization
    void Start()
    {
        cleared               = false;
        nodePanels            = new Dictionary <Node, Pair> ();
        Node.OnClickUpStatic += OnNodeClick;

        allInterfaces   = new List <Interface> ();
        allIfaceVisuals = new List <InterfaceVisuals> ();
        foreach (Node n in allNodes)
        {
            n.Load();
            n.GetComponent <NodeVisuals> ().Load();
            foreach (Interface i in n.Interfaces)
            {
                InterfaceVisuals iv = i.GetComponent <InterfaceVisuals> ();
                allInterfaces.Add(i);
                allIfaceVisuals.Add(iv);

                iv.iface      = i;
                iv.infoObject = Instantiate(interfaceInfoPrefab, canvasTransform);
                iv.InitVisuals();
            }
        }

        keyboard.shortcutPanel   = shortcutPanel;
        keyboard.allVisuals      = allIfaceVisuals;
        shortcutPanel.allVisuals = allIfaceVisuals;

        if (OnStart != null)
        {
            OnStart(this);
        }
        Start2();
    }
Пример #2
0
        IEnumerator InitNodesRoutine()
        {
            for (int i = 0; i < size; ++i)
            {
                yield return(null);

                Node        n  = nodes [i];
                NodeVisuals nv = GetComponent <NodeVisuals> ();
                nodesVisuals [i] = nv;
                n.Load();
                nv.Load();
                yield return(null);

                for (int j = 0; j < 3; ++j)
                {
                    Interface iface = n.Interfaces [j];
                    interfaces [i * 3 + j] = iface;
                    InterfaceVisuals iv = iface.GetComponent <InterfaceVisuals> ();
                    interfacesVisuals [i * 3 + j] = iv;

                    iv.iface      = iface;
                    iv.infoObject = Instantiate(interfaceInfoPrefab, canvasTransform);
                    iv.InitVisuals();
                }
            }
        }
Пример #3
0
    protected virtual void OnDisconnect(Interface other)
    {
        if (!string.IsNullOrEmpty(OnDisconnectAnimation.state))
        {
            animator.Play(OnDisconnectAnimation.state, OnDisconnectAnimation.layer);
        }

        if (connectionLine != null)
        {
            Destroy(connectionLine);
        }
        if (connectedTo != null)
        {
            connectedTo.line        = null;
            connectedTo.connectedTo = null;
            connectedTo             = null;
            line = null;
        }
    }
Пример #4
0
    IEnumerator MultipleLookAt(List <Interface> ifaces)
    {
        int total = ifaces.Count;

        //Get initial rotations
        Transform[]        transforms      = new Transform[total];
        Transform[]        otherTransforms = new Transform[total];
        Quaternion[]       rotsStart       = new Quaternion[total];
        Quaternion[]       otherRotsStart  = new Quaternion[total];
        InterfaceVisuals[] visuals         = new InterfaceVisuals[total];
        InterfaceVisuals[] otherVisuals    = new InterfaceVisuals[total];
        for (int i = 0; i < total; ++i)
        {
            visuals[i]                     = ifaces [i].GetComponent <InterfaceVisuals> ();
            otherVisuals[i]                = ifaces [i].connectedTo.GetComponent <InterfaceVisuals> ();
            visuals[i].blockAnimation      = true;
            otherVisuals[i].blockAnimation = true;
            transforms [i]                 = visuals[i].nodeAnchor;
            otherTransforms [i]            = otherVisuals[i].nodeAnchor;

            rotsStart [i]      = transforms [i].rotation;
            otherRotsStart [i] = otherTransforms [i].rotation;
        }

        //Final rotations maths
        Quaternion[] rotsEnd      = new Quaternion[total];
        Quaternion[] otherRotsEnd = new Quaternion[total];
        Quaternion   baseRotation = Quaternion.LookRotation(nodeAnchor.position - iface.connectedTo.node.transform.position);
        float        offset       = 15f;
        float        baseY        = baseRotation.eulerAngles.y - offset * 0.5f * total;
        float        otherBaseY   = baseRotation.eulerAngles.y + 180f + offset * 0.5f * total;

        for (int i = 0; i < total; ++i)
        {
            //print ((baseY + i * offset * 2f) + ", " + (otherBaseY - i * offset * 2f));
            otherRotsEnd[i] = Quaternion.Euler(0, baseY + i * offset * 2f, 0);
            rotsEnd[i]      = Quaternion.Euler(0, otherBaseY - i * offset * 2f, 0);
        }

        //Movement
        float t = 0f;

        while (t < 0.5f)
        {
            yield return(null);

            t += Time.deltaTime;
            float p = t / 0.5f;
            for (int i = 0; i < total; ++i)
            {
                transforms [i].rotation      = Quaternion.Lerp(rotsStart[i], rotsEnd[i], p);
                otherTransforms [i].rotation = Quaternion.Lerp(otherRotsStart[i], otherRotsEnd[i], p);
            }
        }

        //Create lines
        for (int i = 0; i < total; ++i)
        {
            visuals[i].blockAnimation = false;
            if (visuals [i].connectionLine == null)
            {
                Lines.Pair pair = Lines.RenderStraightLine(visuals [i].modelTransform, otherVisuals [i].modelTransform, 0.02f, 0.2f);
                connectionLine             = pair.gameObject;
                pair.lineRenderer.material = lineMaterial;

                visuals [i].StartCoroutine(LineRoutine(pair.lineRenderer, visuals [i].modelTransform, otherVisuals [i].modelTransform, 0.2f));
                otherVisuals [i].blockAnimation = false;
                otherVisuals [i].connectionLine = pair.gameObject;

                visuals [i].line             = pair.lineRenderer;
                visuals [i].connectedTo      = otherVisuals [i];
                otherVisuals [i].line        = pair.lineRenderer;
                otherVisuals [i].connectedTo = visuals [i];

                visuals [i].ChangeColor(visuals [i].meshRenderer.material.color);
            }
        }
    }