Пример #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();
    }
Пример #2
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();
    }