private void CancelConnection()
    {
        TerminalBlocks tb = this.transform.parent.GetComponent <TerminalBlocks> ();

        if (tb != null)
        {
            tb.SetNextBlock(null, connectionDir);
        }
        GameObject gObj = ConnectionManager.GetOtherSide(this.transform.parent.GetComponent <RectTransform> (), connectionDir);

        if (gObj != null)
        {
            TerminalEntryConnection ep = gObj.GetComponent <TerminalEntryConnection> ();
            if (ep != null)
            {
                if (ConnectionManager.DeleteThisConnection(this.transform.parent.GetComponent <RectTransform> (), connectionDir))
                {
                    isEmpty    = true;
                    changed    = true;
                    ep.isEmpty = true;
                    ep.changed = true;
                }
            }
        }
    }
Example #2
0
 // Update is called once per frame
 private void Update()
 {
     if (isDeselected)
     {
         Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
         if (hit.collider != null)
         {
             TerminalEntryConnection rt = hit.transform.GetComponent <TerminalEntryConnection> ();
             if (rt != null)
             {
                 if (rt.transform.parent != null)
                 {
                     rt.isEmpty = false;
                     rt.changed = true;
                     TerminalBlocks tb2 = rt.transform.parent.GetComponent <TerminalBlocks> ();
                     TerminalBlocks tb  = ConnectionManager.GetOtherSide(this.GetComponent <RectTransform> (), ConnectionPoint.ConnectionDirection.West).transform.parent.GetComponent <TerminalBlocks> ();
                     Debug.Log(tb);
                     if (tb2 != null && tb != null)
                     {
                         tb.SetNextBlock(tb2, TerminalConnectionManager.connectionDirections[0]);
                     }
                     ConnectionManager.ChangeTarget(this.GetComponent <RectTransform> (), rt.transform.parent.GetComponent <RectTransform> ());
                     Destroy(this.gameObject);
                     return;
                 }
             }
         }
         CancelConnection();
         Destroy(this.gameObject);
     }
 }