Esempio n. 1
0
    public override void _Process(float delta)
    {
        if (hasActiveAnchor())
        {
            activeAnchor.Position = GetGlobalMousePosition();

            if (Input.IsActionJustReleased("spawn_anchor"))
            {
                if (rayCastinTerrain() || rayCastinPlayer() || rayCastinAnchor() || (startAnchor != null && startAnchor.getBracesInRange(activeAnchor.GlobalPosition).Count == 0))
                {
                    activeAnchor.destory();
                    activeAnchor = null;
                    startAnchor  = null;
                    addGoo();
                }
                else // Placing anchor into world
                {
                    if (startAnchor != null && activeAnchor != null)
                    {
                        Brace brace = newBrace(GetGlobalMousePosition());
                        startAnchor.connect(brace);
                        activeAnchor.destory();
                        activeAnchor = null;
                        startAnchor  = null;
                    }
                    else
                    {
                        activeAnchor.setActive(true);
                        activeAnchor.AddCentralForce(new Vector2(0, 0.1f));
                        anchors.Add(activeAnchor);
                        activeAnchor = null;
                    }
                }
            }
        }
        else // does not have active anchor
        {
            if (Input.IsActionJustPressed("spawn_anchor") && !rayCastinTerrain() && removeGoo())
            {
                activeAnchor = newAnchor(GetGlobalMousePosition());
                startAnchor  = getRayCastAnchor();
            }
            else if (Input.IsActionJustPressed("remove_anchor"))
            {
                Anchor anchor = getRayCastAnchor();
                if (anchor != null && hasGooSpace())
                {
                    if (anchor.removeBrace(GetGlobalMousePosition()))
                    {
                        addGoo();
                    }
                }
            }
        }
    }
Esempio n. 2
0
 public void ConnectedBraces(SC.List <Brace> connected)
 {
     if (!connected.Contains(this))
     {
         connected.Add(this);
         foreach (Connector connector in connectors)
         {
             connector.a.ConnectedBraces(connected);
             connector.b.ConnectedBraces(connected);
         }
     }
 }
Esempio n. 3
0
 public void addConnectorToList(Connector connector)
 {
     connectors.Add(connector);
 }