Beispiel #1
0
    public void RetirerNoeud(NoeudFleuve nf)
    {
        if (grapheNoeuds.Contains(nf))
        {
            if (grapheNoeuds.Count > 2)
            {
                int index = RecupererIndexSpline(nf.transform.position);
                List <NoeudFleuve> noeudsADeselectionner = grapheNoeuds.GetRange(index, grapheNoeuds.Count - index);
                int portee = grapheNoeuds.Count;
                grapheNoeuds.RemoveRange(index, grapheNoeuds.Count - index);

                if (index > 1)
                {
                    for (int i = index; i < portee; i++)
                    {
                        spline.RemovePointAt(index);
                    }

                    foreach (NoeudFleuve noefl in noeudsADeselectionner)
                    {
                        noefl.EstSelectionne(false);
                    }
                }
            }
        }
    }
Beispiel #2
0
    public void GenererFleuve(MappeSysteme.Mappe mappe)
    {
        Fleuve[] listeFleuves = new Fleuve[mappe.listeFleuves.Count];

        for (int i = 0; i < mappe.listeFleuves.Count; i++)
        {
            GameObject nvFleuve = Instantiate(fleuvePrefab);
            nvFleuve.name   = "Fleuve" + i;
            listeFleuves[i] = nvFleuve.GetComponent <Fleuve>();
            listeFleuves[i].Init();

            char[]   separateurs          = new char[] { mappe.separateurNouedFleuve };
            string[] listeCodeNoeudFleuve = mappe.listeFleuves[i].Split(separateurs, System.StringSplitOptions.RemoveEmptyEntries);

            for (int j = 0; j < listeCodeNoeudFleuve.Length; j++)
            {
                NoeudFleuve nf = RetrouverNoeudFleuve(listeCodeNoeudFleuve[j]);

                if (nf)
                {
                    listeFleuves[i].AjouterNoeud(nf);
                }
            }
        }
    }
Beispiel #3
0
    public void AjouterNoeud(NoeudFleuve nf)
    {
        grapheNoeuds.Add(nf);
        nf.EstSelectionne(true);

        if (grapheNoeuds.Count == 2)
        {
            transform.position = Vector3.zero;
            for (int i = 0; i < grapheNoeuds.Count; i++)
            {
                Vector3 positionNoeud = grapheNoeuds[i].transform.position;
                positionNoeud.z = profondeur;

                spline.InsertPointAt(i, positionNoeud);
                spline.RemovePointAt(i + 1);
            }
        }
        else if (grapheNoeuds.Count > 2)
        {
            Vector3 positionNoeud = grapheNoeuds[grapheNoeuds.Count - 1].transform.position;
            positionNoeud.z = profondeur;
            spline.InsertPointAt(spline.GetPointCount(), positionNoeud);
            //print(spline.GetPointCount());
        }
    }
Beispiel #4
0
    private NoeudFleuve[,] RecupDamierFleuve()
    {
        NoeudFleuve[,] damier = new NoeudFleuve[colonnes, lignes];
        NoeudFleuve[] damierRef = GetComponentsInChildren <NoeudFleuve>();


        int index = 0;

        for (int y = 0; y < lignes; y++)
        {
            for (int x = 0; x < colonnes; x++)
            {
                damier[x, y] = damierRef[index];
                damierRef[index].transform.SetSiblingIndex(index);

                index++;
            }
        }


        return(damier);
    }
Beispiel #5
0
    private void DessinerFleuve()
    {
        if (modeFleuve)
        {
            foreach (GameObject go in Selection.gameObjects)
            {
                if (go.CompareTag("NoeudFleuve"))
                {
                    NoeudFleuve nf = go.GetComponent <NoeudFleuve>();

                    if (fleuveSelectionne.grapheNoeuds.Contains(nf))
                    {
                        fleuveSelectionne.RetirerNoeud(nf);
                    }
                    else
                    {
                        fleuveSelectionne.AjouterNoeud(nf);
                    }
                }
                Selection.objects = new Object[0];
            }
        }
    }