Exemplo n.º 1
0
    public void btnObstacle()
    {
        if (noeud != null)
        {
            Renderer rend = noeud.GetComponent <Renderer>();
            rend.material.color = Color.black;
            Noeud n = noeud.GetComponent <Noeud>();
            n.setLibre(false);
            obstacles.Add(noeud);
            if (noeud == noeudDepart)
            {
                noeudDepart = null;
            }
            if (noeud == noeudArrivee)
            {
                noeudArrivee = null;
            }
            noeud = null;
        }
        UnitSelectionComponent selection = gameObject.GetComponent <UnitSelectionComponent>();
        List <Transform>       selected  = selection.getSelectedObjects();

        foreach (Transform nd in selected)
        {
            Renderer rend = nd.GetComponent <Renderer>();
            rend.material.color = Color.black;
            Noeud n = nd.GetComponent <Noeud>();
            n.setLibre(false);
            obstacles.Add(nd);
            if (nd == noeudDepart)
            {
                noeudDepart = null;
            }
            if (nd == noeudArrivee)
            {
                noeudArrivee = null;
            }
        }
        selection.clearSelections();
    }
    public void BtnUnblockPath()
    {
        if (node != null)
        {
            // Set selected node to white.
            Renderer rend = node.GetComponent <Renderer>();
            rend.material.color = Color.white;

            // Set selected not to walkable.
            Node n = node.GetComponent <Node>();
            n.SetWalkable(true);

            // Remove selected node from the block path list.
            blockPath.Remove(node);

            node = null;
        }

        // For selection grid system.
        UnitSelectionComponent selection = gameObject.GetComponent <UnitSelectionComponent>();
        List <Transform>       selected  = selection.getSelectedObjects();

        foreach (Transform nd in selected)
        {
            // Set selected node to white.
            Renderer rend = nd.GetComponent <Renderer>();
            rend.material.color = Color.white;

            // Set selected not to walkable.
            Node n = nd.GetComponent <Node>();
            n.SetWalkable(true);

            // Remove selected node from the block path list.
            blockPath.Remove(nd);
        }

        selection.clearSelections();
    }
Exemplo n.º 3
0
    public void btnEnleveObstacle()
    {
        if (noeud != null)
        {
            Renderer rend = noeud.GetComponent <Renderer>();
            rend.material.color = Color.white;
            Noeud n = noeud.GetComponent <Noeud>();
            n.setLibre(true);
            obstacles.Remove(noeud);
            noeud = null;
        }
        UnitSelectionComponent selection = gameObject.GetComponent <UnitSelectionComponent>();
        List <Transform>       selected  = selection.getSelectedObjects();

        foreach (Transform nd in selected)
        {
            Renderer rend = nd.GetComponent <Renderer>();
            rend.material.color = Color.white;
            Noeud n = nd.GetComponent <Noeud>();
            n.setLibre(true);
            obstacles.Remove(nd);
        }
        selection.clearSelections();
    }
    public void BtnBlockPath()
    {
        if (node != null)
        {
            // Render the selected node to black.
            Renderer rend = node.GetComponent <Renderer>();
            rend.material.color = Color.black;

            // Set selected node to not walkable
            Node n = node.GetComponent <Node>();
            n.SetWalkable(false);

            // Add the node to the block path list.
            blockPath.Add(node);

            // If the block path is start node, we remove start node.
            if (node == startNode)
            {
                startNode = null;
            }

            // If the block path is end node, we remove end node.
            if (node == endNode)
            {
                endNode = null;
            }

            node = null;
        }

        // For selection grid system.
        UnitSelectionComponent selection = gameObject.GetComponent <UnitSelectionComponent>();
        List <Transform>       selected  = selection.getSelectedObjects();

        foreach (Transform nd in selected)
        {
            // Render the selected node to black.
            Renderer rend = nd.GetComponent <Renderer>();
            rend.material.color = Color.black;

            // Set selected node to not walkable
            Node n = nd.GetComponent <Node>();
            n.SetWalkable(false);

            // Add the node to the block path list.
            blockPath.Add(nd);

            // If the block path is start node, we remove start node.
            if (nd == startNode)
            {
                startNode = null;
            }

            // If the block path is end node, we remove end node.
            if (nd == endNode)
            {
                endNode = null;
            }
        }

        selection.clearSelections();
    }