Ejemplo n.º 1
0
 public void SetEntityB(BlueprintEntity b, BlueprintEntityPin anchorB)
 {
     this.b            = b;
     this.anchorB      = anchorB;
     _anchorBTransform = anchorB.transform;
     _rectB            = anchorB.GetComponent <RectTransform>();
     _rectParentB      = _anchorBTransform.parent.GetComponent <RectTransform>();
 }
Ejemplo n.º 2
0
 public void SetEntityA(BlueprintEntity a, BlueprintEntityPin anchorA)
 {
     this.a            = a;
     this.anchorA      = anchorA;
     _anchorATransform = anchorA.transform;
     _rectA            = anchorA.GetComponent <RectTransform>();
     _rectParentA      = _anchorATransform.parent.GetComponent <RectTransform>();
 }
Ejemplo n.º 3
0
    public bool DropToConnector(BlueprintEntityPin oppositionPin)
    {
        var connector = BlueprintConnector.current;

        // if having a same pin type at two head, remove them.
        if (pinType == BlueprintEntityPinType.In)
        {
            if (connector.b != null)
            {
                Destroy(connector.gameObject);
                BlueprintConnector.current = null;
                return(false);
            }
            connector.SetEntityB(entity, this);
        }
        else
        {
            if (connector.a != null)
            {
                Destroy(connector.gameObject);
                BlueprintConnector.current = null;
                return(false);
            }
            connector.SetEntityA(entity, this);
        }
        // create block connector
        var blockConnector = connector.CreateBlockConnector();

        if (dropToConnectorCallback != null)
        {
            dropToConnectorCallback.Invoke(blockConnector);
        }
        if (oppositionPin.dropToConnectorCallback != null)
        {
            oppositionPin.dropToConnectorCallback.Invoke(blockConnector);
        }
        Debug.Log(blockConnector.a);
        Debug.Log(blockConnector.b);
        oppositionPin.blueprintConnector
              = blueprintConnector
              = connector;
        BlueprintConnector.current = null;
        return(true);
    }
Ejemplo n.º 4
0
    public void OnEndDrag(PointerEventData eventData)
    {
        // detect an appropriate pin as oppose one
        BlueprintEntityPin detectedPin = null;

        foreach (var go in eventData.hovered)
        {
            if (go.Equals(null))
            {
                continue;
            }
            var pin = go.GetComponent <BlueprintEntityPin>();
            if (pin == null || pin.Equals(null))
            {
                continue;
            }
            if (pin.GetInstanceID() == GetInstanceID())
            {
                continue;
            }
            detectedPin = pin;
            break;
        }
        // if detected pin has been found
        if (detectedPin != null && !detectedPin.Equals(null))
        {
            BlueprintConnector.current.OnPinDragEnd(this);
            detectedPin.DropToConnector(this);
        }
        else
        {
            var currentConnector = BlueprintConnector.current;
            if (currentConnector != null && !currentConnector.Equals(null))
            {
                Destroy(currentConnector.gameObject);
            }
        }
    }
Ejemplo n.º 5
0
 public void OnPinDragEnd(BlueprintEntityPin pin)
 {
     Destroy(_connectorOverlay.gameObject);
     _connectorOverlay = null;
 }
Ejemplo n.º 6
0
 public void OnPinDrag(BlueprintEntityPin pin)
 {
     DrawEndLineByMouse(pin.pinType);
 }