Пример #1
0
    public bool AddConnection(Node newCon)
    {
        // check if we already have this connection, we don't want to double up
        foreach (NavConnectionData data in connections)
        {
            if (data.node == newCon)
            {
                return(false);
            }
        }

        // copy connection array
        NavConnectionData newData = new NavConnectionData(newCon);

        newData.UpdateDistanceFromNode(this);
        connections.AddLast(newData);
        return(true);
    }
Пример #2
0
    public void RemoveConnection(Node oldCon)
    {
        if (connections.Count == 0)
        {
            return;
        }
        bool didFindNode            = false;
        NavConnectionData foundData = new NavConnectionData();

        // find the connection
        foreach (NavConnectionData con in connections)
        {
            if (con.node == oldCon)
            {
                foundData   = con;
                didFindNode = true;
            }
        }
        // remove the connection
        if (didFindNode == true)
        {
            connections.Remove(foundData);
        }
    }