Ejemplo n.º 1
0
 public void AddNodeBridge(NodeBridge nodeBridge)
 {
     if (!_nodeBridges.Contains(nodeBridge))
     {
         _nodeBridges.Add(nodeBridge);
     }
 }
    /**
     * Creates a bridge between two platformNodes
     * @param offset    the midway point between the nodes
     * @param targetNode    the node which the player's "selected node" connects with
     */
    public void MakeBridgeConnection(Vector3 offset, ShootableNode targetNode)
    {
        GameObject go = Instantiate(NodeLinks.instance.platformPrefab, transform.position + (offset * 0.5f),
                                    Quaternion.identity);

        go.transform.right = offset;

        NodeBridge nodeBridge = go.GetComponent <NodeBridge>();
        float      xSize      = Vector3.Distance(transform.position, targetNode.transform.position);

        nodeBridge.spriteRenderer.size = new Vector2(xSize, nodeBridge.spriteRenderer.size.y);
        nodeBridge.boxCollider.size    = nodeBridge.spriteRenderer.size;

        nodeBridge.parentNodes[0] = this;
        nodeBridge.parentNodes[1] = targetNode;

        inUse            = true;
        targetNode.inUse = true;

        Player.instance.selectedNode = null;
    }
Ejemplo n.º 3
0
 public void NodeLinkDragStarted(NodeLink nodeLink)
 {
     if (_state == State.Idle)
     {
         if (!nodeLink.HasBridges)
         {
             // Connect one side of bridge
             _state = State.ConnectingNodeLinks;
             NodeBridge newBridge = CreateNewBridgeObject();
             if (nodeLink.IsOutNode)
             {
                 newBridge.SetStartNodeLink(nodeLink);
             }
             else
             {
                 newBridge.SetEndNodeLink(nodeLink);
             }
             _currentNodeBridges.Add(newBridge);
         }
         else
         {
             // Disconnect one side of bridge
             _state = State.ConnectingNodeLinks;
             _currentNodeBridges = new List <NodeBridge>(nodeLink.Bridges);
             for (int i = 0; i < _currentNodeBridges.Count; i++)
             {
                 if (!nodeLink.IsOutNode)
                 {
                     _currentNodeBridges[i].RemoveEndNodeLink();
                 }
                 else
                 {
                     _currentNodeBridges[i].RemoveStartNodeLink();
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 public void RemoveNodeBridge(NodeBridge nodeBridge)
 {
     _nodeBridges.Remove(nodeBridge);
 }