Exemple #1
0
        public async Task <String> PutGarden(Jardin jardin)
        {
            http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(Constantes.BEARER, Constantes.TOKEN_ADMIN_PROP);
            var stringInput = await http.PutAsJsonAsync(Constantes.API_GARDENS + jardin.NumGarden, jardin);

            return(stringInput.ReasonPhrase);
        }
        public async Task PostJardinAsync(Jardin jardin)
        {
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                GardenController service = new GardenController();
                var createGarden         = await service.PostGarden(jardin);

                if (createGarden.Equals("Created"))
                {
                    navigationService.NavigateTo("Acceuil");
                    NewJardin = new Jardin();
                }
                else
                {
                    MessageDialog messageDialog = new MessageDialog(Constantes.MESSAGE_ERREUR)
                    {
                        Title = Constantes.TITRE_ERREUR
                    };
                    var res = await messageDialog.ShowAsync();
                }
            }
            else
            {
                MessageDialog messageDialog = new MessageDialog(Constantes.MESSAGE_ERREUR_CONNEXION)
                {
                    Title = Constantes.TITRE_ERREUR_CONNECTION
                };
                var res = messageDialog.ShowAsync();
            }
        }
Exemple #3
0
 //constante en moins pour test
 public Jardin jardin2()
 {
     Jardin jardin = new Jardin();
     jardin.Add(new Element(-3, 2, "tulipe", "moyen", "rose", "a"));
     jardin.Add(new Element(2, 3, "rose", "petit", "blanc", null));
     return jardin;
 }
    //restore un jardin depuis une sauvegarde
    public void setJardin(Jardin newJardin)
    {
        _jardin = newJardin;

        GameObject[] plane = GameObject.FindGameObjectsWithTag("Tile");

        foreach (GameObject gameTile in plane) // Loop through List with foreach.
        {
            //clean de l'ancien jardin
            Tiles tuile = gameTile.GetComponent<Tiles>();
            if (tuile.getFlower())
            {
                tuile.getFlower().destroyFlower();
                Debug.Log("tuile(" + tuile.x + "," + tuile.y + ") destroy flower");
            }
            //ajout d'une fleur si jamais il y en a une à ces coordonnées
            Element elem = _jardin.existFlowerOnTile(tuile.x, tuile.y);
            if (elem != null)
            {
                Debug.Log(" elem x: " + elem.GetX() + " elem_y " + elem.GetY() + " non null!");
                _flower = gameTile.AddComponent<Flower>();
                _flower.setFlowerFromElem(elem);
                tuile.setFlower(_flower);
                tuile.attributeFlower();
            }

        }
    }
    //restore un jardin depuis une sauvegarde
    public void setJardin(Jardin newJardin)
    {
        _jardin = newJardin;

        GameObject[] plane = GameObject.FindGameObjectsWithTag("Tile");

        foreach (GameObject gameTile in plane) // Loop through List with foreach.
        {
            //clean de l'ancien jardin
            Tiles tuile = gameTile.GetComponent <Tiles>();
            if (tuile.getFlower())
            {
                tuile.getFlower().destroyFlower();
                Debug.Log("tuile(" + tuile.x + "," + tuile.y + ") destroy flower");
            }
            //ajout d'une fleur si jamais il y en a une à ces coordonnées
            Element elem = _jardin.existFlowerOnTile(tuile.x, tuile.y);
            if (elem != null)
            {
                Debug.Log(" elem x: " + elem.GetX() + " elem_y " + elem.GetY() + " non null!");
                _flower = gameTile.AddComponent <Flower>();
                _flower.setFlowerFromElem(elem);
                tuile.setFlower(_flower);
                tuile.attributeFlower();
            }
        }
    }
Exemple #6
0
    //constante en moins pour test
    public Jardin jardin2()
    {
        Jardin jardin = new Jardin();

        jardin.Add(new Element(-3, 2, "tulipe", "moyen", "rose", "a"));
        jardin.Add(new Element(2, 3, "rose", "petit", "blanc", null));
        return(jardin);
    }
Exemple #7
0
 public Communicate(string python, Jardin jardin)
 {
     //création du lien avec le script python
     engine = Python.CreateEngine();
     script = engine.CreateScriptSourceFromFile(python);
     scope = engine.CreateScope();
     this.jardin = jardin;
 }
Exemple #8
0
 public Communicate(string python, Jardin jardin)
 {
     //création du lien avec le script python
     engine      = Python.CreateEngine();
     script      = engine.CreateScriptSourceFromFile(python);
     scope       = engine.CreateScope();
     this.jardin = jardin;
 }
Exemple #9
0
    public void VerifFormule()
    {
        iField = focusHandler.getCurrentFormule();
        output = focusHandler.getCurrentVerif();

        if (string.IsNullOrEmpty(iField.text))
        {
            return;
        }
        try
        {
            Formule     formule = FormuleFactory.parse(iField.text);
            Jardin      jardin  = terrainHandler.getJardin();
            Communicate comm    = new Communicate(SCRIPT_PYTHON, jardin);
            foreach (Element el in jardin.GetElements())
            {
                Debug.Log(el);
            }


            //lance le script
            comm.GetSource().Execute(comm.GetScope());
            object pythonForm = comm.HandleForm(formule);
            Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul");
            object pythonJardin = unity_my_interp_formul(jardin);
            Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form");
            var res = unity_eval_one_form(pythonJardin, pythonForm);
            Debug.Log("res=" + res);

            //Affiche résultat
            if ((bool)res == true)
            {
                output.color = Color.green;
                output.text  = "Vrai";
            }
            else
            {
                output.color = Color.red;
                output.text  = "Faux";
            }
        }
        catch (ParserLogException)
        {
            output.color = Color.red;
            output.text  = "Erreur";
            Debug.Log("Erreur formule");
        }
        catch (ValueErrorException)
        {
            output.color = new Color32(255, 128, 0, 255);
            output.text  = "Var libre";
        }
        catch (Exception)
        {
            output.color = Color.red;
            output.text  = "Erreur imprévue";
        }
    }
Exemple #10
0
 public Jardin jardin1()
 {
     Jardin jardin = new Jardin();
     jardin.Add(new Element(-3,2,"tulipe","moyen","rose","a"));
     jardin.Add(new Element(2,3,"rose","petit","blanc",null));
     jardin.Add(new Element(-2,-1,"rose","grand","rouge",null));
     jardin.Add(new Element(2,1,"paquerette","moyen","blanc","d"));
     return jardin;
 }
 // Use this for initialization
 void Start()
 {
     _jardin             = new Jardin();    //initialisation d'un jardin vide
     mode                = ToggleType.View; //le mode est en défault au départ
     lastMode            = mode;
     _flower             = null;
     _previousGameObject = null;
     buttonClean.onClick.AddListener(cleanJardin);
 }
Exemple #12
0
    public Jardin jardin1()
    {
        Jardin jardin = new Jardin();

        jardin.Add(new Element(-3, 2, "tulipe", "moyen", "rose", "a"));
        jardin.Add(new Element(2, 3, "rose", "petit", "blanc", null));
        jardin.Add(new Element(-2, -1, "rose", "grand", "rouge", null));
        jardin.Add(new Element(2, 1, "paquerette", "moyen", "blanc", "d"));
        return(jardin);
    }
Exemple #13
0
    void Start()
    {
        FormuleTest ft     = new FormuleTest();
        Jardin      jardin = jardin2();
        Communicate comm   = new Communicate("psar_python.py", jardin);

        //lance le script
        comm.GetSource().Execute(comm.GetScope());

        ft.test_formules(comm, jardin);
    }
Exemple #14
0
        static void Main(string[] args)
        {
            Soleil s = new Soleil();

            // cas bidirectionnel!

            Jardin monJardinAMoi = new Jardin();

            Plante p = new Plante(10, new Soleil(), monJardinAMoi);

            monJardinAMoi.AddPlante(p);
        }
Exemple #15
0
        public void crearJardin(string _nombre, string _direccion, int _estadoJardin)
        {
            ORMDataContext orm    = new ORMDataContext();
            Jardin         jardin = new Jardin();

            jardin.nombre     = _nombre;
            jardin.direccion  = _direccion;
            jardin.idEstado   = _estadoJardin;
            jardin.habilitado = 1;
            orm.Jardin.InsertOnSubmit(jardin);
            orm.SubmitChanges();
        }
Exemple #16
0
        public void eliminarJardin(int _idJardin)
        {
            ORMDataContext orm    = new ORMDataContext();
            Jardin         jardin = (from j in orm.Jardin
                                     where j.idJardin == _idJardin
                                     select j).FirstOrDefault();

            if (jardin == null)
            {
                throw new Exception("Hubo un error al procesar la solicitud");
            }
            jardin.habilitado = 0;
            orm.SubmitChanges();
        }
Exemple #17
0
 public void destroyFlower(Jardin jardin)
 {
     _x = -42;
     _y = -42;
     if (objToSpawn)
     {
         Destroy(objToSpawn);
     }
     if (Element != null)
     {
         jardin.Remove(Element);
         Element = null;
     }
 }
        /// <summary>
        /// Precarga de datos para testeo
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            this.jardin = new Jardin(100);
            bool pudo = this.jardin + new Arbusto("Arbusto 1", 10);

            pudo = this.jardin + new Arbusto("Arbusto 2", 15);
            pudo = this.jardin + new Rosal("Rosa 1", 20, Rosal.Color.Amarilla);
            pudo = this.jardin + new Rosal("Rosa clásica", 25);
            pudo = this.jardin + new Banano("Banano ecuador", 30, "ECU001");
            if (!(this.jardin + new Banano("No carga", 1, "ARG028")))
            {
                Console.WriteLine("ERROR!");
            }
        }
Exemple #19
0
    public void crearJardin(GameObject ficha, int numeroEdificiosAdyacentes, int numeroIndustriasAdyacentes)
    {
        this.ficha = Instantiate(ficha, new Vector3(posX, 1f, posZ), transform.rotation);

        Jardin jardin = ficha.GetComponent <Jardin>();

        jardin.setLogica(instanciaLogica);

        jardin.setNumeroEdificiosAdyacentes(numeroEdificiosAdyacentes);

        jardin.setNumeroIndustriasAdyacentes(numeroIndustriasAdyacentes);

        this.ocupada = true;
    }
Exemple #20
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.jardin = new Jardin(100);
            bool pudo = this.jardin + new Arbusto("Arbusto 1", 10);

            pudo = this.jardin + new Arbusto("Arbusto 2", 15);
            pudo = this.jardin + new Rosal("Rosa 1", 20, Rosal.Color.Amarilla);
            pudo = this.jardin + new Rosal("Rosa clásica", 25);
            pudo = this.jardin + new Banano("Banano ecuador", 30, "ECU001");
            if (!(this.jardin + new Banano("No carga", 1, "ARG028")))
            {
                MessageBox.Show("ERROR!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #21
0
        static void Main(string[] args)
        {
            Jardin jardin = new Jardin(100);

            bool pudo = jardin + new Arbusto("Arbusto 1", 10);

            pudo = jardin + new Arbusto("Arbusto 2", 15);
            pudo = jardin + new Rosal("Rosa 1", 20, Rosal.Color.Amarrilla);
            pudo = jardin + new Rosal("Rosa clásica", 25);
            pudo = jardin + new Banano("Banano ecuador", 30, "ECU001");
            if (!(jardin + new Banano("No carga", 1, "ARG028")))
            {
                Console.WriteLine("ERROR!");
            }
        }
Exemple #22
0
        private void FrmJardin_Load(object sender, EventArgs e)
        {
            //         Reemplazar el Console.WriteLine
            //por un Message Box con ícono de error y sólo el botón OK
            this.jardin = new Jardin(100);
            bool pudo = this.jardin + new Arbusto("Arbusto 1", 10);

            pudo = this.jardin + new Arbusto("Arbusto 2", 15);
            pudo = this.jardin + new Rosal("Rosa 1", 20, Rosal.Color.Amarilla);
            pudo = this.jardin + new Rosal("Rosa clásica", 25);
            pudo = this.jardin + new Banano("Banano ecuador", 30, "ECU001");
            if (!(this.jardin + new Banano("No carga", 1, "ARG028")))
            {
                MessageBox.Show("Una planta no se pudo agregar :(", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #23
0
    void save()
    {
        /*JARDIN*/
        Jardin jardin = terrainHandler.getJardin();
        string path   = fName.text;

        if (path.Length == 0)
        {
            /* Invalid path */
            Debug.Log("Invalid path");
            return;
        }

        try
        {
            StreamWriter sw = new StreamWriter(@path);

            /*Write formules */
            sw.WriteLine("#FORMULES");
            for (int i = 1; i <= NB_FORMULE; i++)
            {
                InputField iField = (InputField)GameObject.Find(FORMULE_PATH + "Form_" + i).GetComponent <InputField>();
                if (iField.text.Length == 0)
                {
                    continue;
                }
                sw.WriteLine(iField.text);
            }

            /*Write jardin*/
            sw.WriteLine("#JARDIN");
            foreach (Element elem in jardin.GetElements())
            {
                sw.WriteLine(elem.ToString());
            }

            Debug.Log("sauvegarder dans : " + path);
            sw.Close();
            ClosePanel();
        }
        catch (Exception)
        {
            Debug.Log("Error while writing file path=" + path);
            fName.text = "Dossier \"" + path + "\" introuvable !";
            return;
        }
    }
Exemple #24
0
        static void Main(string[] args)
        {
            Jardin jardin = new Jardin(20);

            Arbusto arbusto = new Arbusto("Pepito", 5);
            Banano  b1      = new Banano("Leo", 7, "12345");
            Banano  b2      = new Banano("Ailen", 6, "34567");
            Rosal   r1      = new Rosal("Pepita", 10, Rosal.Color.Azul);

            if (jardin + arbusto)
            {
                Console.WriteLine(jardin.ToString());
            }
            else
            {
                Console.WriteLine(" No hay mas espacio");
            }

            if (jardin + b1)
            {
                Console.WriteLine(jardin.ToString());
            }
            else
            {
                Console.WriteLine(" No hay mas espacio");
            }

            if (jardin + b2)
            {
                Console.WriteLine(jardin.ToString());
            }
            else
            {
                Console.WriteLine(" No hay mas espacio");
            }

            if (jardin + r1)
            {
                Console.WriteLine(jardin.ToString());
            }
            else
            {
                Console.WriteLine(" No hay mas espacio");
            }

            Console.ReadKey();
        }
Exemple #25
0
        public void editarJardin(int _idJardin, string _nombre, string _direccion, int _estadoJardin)
        {
            ORMDataContext orm    = new ORMDataContext();
            Jardin         jardin = (from j in orm.Jardin
                                     where j.idJardin == _idJardin
                                     select j).FirstOrDefault();

            if (jardin == null)
            {
                throw new Exception("Hubo un error al procesar la solicitud");
            }
            jardin.nombre    = _nombre;
            jardin.direccion = _direccion;
            jardin.idEstado  = _estadoJardin;
            if (_estadoJardin == 24)
            {
                jardin.habilitado = 0;
            }
            orm.SubmitChanges();
        }
Exemple #26
0
        /// <summary>
        /// Load del formulario y carga de datos.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void FrmJardin_Load(object sender, EventArgs e)
        {
            this.MaximizeBox = false;
            this.MinimizeBox = false;

            this.StartPosition   = FormStartPosition.CenterScreen;
            this.Text            = "Jardin";
            this.BackColor       = Color.DarkGreen;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.jardin          = new Jardin(100);
            bool pudo = this.jardin + new Arbusto("Arbusto 1", 10);

            pudo = this.jardin + new Arbusto("Arbusto 2", 15);
            pudo = this.jardin + new Rosal("Rosa 1", 20, Rosal.Color.Amarilla);
            pudo = this.jardin + new Rosal("Rosa clásica", 25);
            pudo = this.jardin + new Banano("Banano ecuador", 30, "ECU001");
            if (!(this.jardin + new Banano("No carga", 1, "ARG028")))
            {
                MessageBox.Show("ERROR!");
            }
        }
Exemple #27
0
    public void test_one_form(String form, int name, Communicate comm, Jardin jardin)
    {
        Debug.Log("====================" + "f" + name + "====================");
        Formule f = FormuleFactory.parse(form);

        try
        {
            object pythonForm = comm.HandleForm(f);
            Debug.Log(name + " = " + pythonForm.ToString());

            Func<Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable<Func<Jardin, object>>("unity_my_interp_formul");
            object pythonJardin = unity_my_interp_formul(jardin);
            Func<object, object, object> unity_eval_one_form = comm.GetScope().GetVariable<Func<object, object, object>>("unity_eval_one_form");

            Debug.Log("f" + name + " = " + unity_eval_one_form(pythonJardin, pythonForm));
            Debug.Log("===========================================================");
        }
        catch (CommException c)
        {
            Debug.Log(c);
        }
    }
Exemple #28
0
    public void test_one_form(String form, int name, Communicate comm, Jardin jardin)
    {
        Debug.Log("====================" + "f" + name + "====================");
        Formule f = FormuleFactory.parse(form);

        try
        {
            object pythonForm = comm.HandleForm(f);
            Debug.Log(name + " = " + pythonForm.ToString());

            Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul");
            object pythonJardin = unity_my_interp_formul(jardin);
            Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form");

            Debug.Log("f" + name + " = " + unity_eval_one_form(pythonJardin, pythonForm));
            Debug.Log("===========================================================");
        }
        catch (CommException c)
        {
            Debug.Log(c);
        }
    }
Exemple #29
0
    public void test_formules(Communicate comm, Jardin jardin)
    {
        String[] formuleTab = new string[]
        {
            "Rose(d)",
            "∀xRose(x)",
            "∃xRose(x)",
            "∀x(est_blanc(x) ⇒ ∃y(plus_petit_que(x,y) ∧ a_l_est_de(y,x)))",
            "∀x(a_l_est(x) ∨ a_l_ouest(x) ∨ au_sud(x) ∨ au_nord(x))",
            "(∀x(est_grand(x) ⇒ est_rouge(x)) ∧ ¬∃x(est_blanc(x) ∧ ∃y(est_rouge(y) ∧ au_sud_de(x,y))))",
            "∃x(est_rouge(x) ∧ au_nord_de(x,d))",
            "∃x((Rose(x) ∧ est_rouge(x)) ∧ (∀y((Rose(y) ∧ est_rouge(y)) ⇒ au_sud_de(x, y))))"
        };

        List <Formule> formules = new List <Formule>();
        int            i        = 1;

        foreach (String str in formuleTab)
        {
            test_one_form(str, i, comm, jardin);
            i++;
        }
    }
Exemple #30
0
    public void test_formules(Communicate comm, Jardin jardin)
    {
        String[] formuleTab = new string[]
            {
                "Rose(d)",
                "∀xRose(x)",
                "∃xRose(x)",
                "∀x(est_blanc(x) ⇒ ∃y(plus_petit_que(x,y) ∧ a_l_est_de(y,x)))",
                "∀x(a_l_est(x) ∨ a_l_ouest(x) ∨ au_sud(x) ∨ au_nord(x))",
                "(∀x(est_grand(x) ⇒ est_rouge(x)) ∧ ¬∃x(est_blanc(x) ∧ ∃y(est_rouge(y) ∧ au_sud_de(x,y))))",
                "∃x(est_rouge(x) ∧ au_nord_de(x,d))",
                "∃x((Rose(x) ∧ est_rouge(x)) ∧ (∀y((Rose(y) ∧ est_rouge(y)) ⇒ au_sud_de(x, y))))"

            };

        List<Formule> formules = new List<Formule>();
        int i = 1;
        foreach (String str in formuleTab)
        {
            test_one_form(str, i, comm, jardin);
            i++;
        }
    }
Exemple #31
0
    void open()
    {
        string path = fName.options.ToArray()[fName.value].text;

        if (path.Length == 0)
        {
            /* Invalid path */
            Debug.Log("Invalid path");
            return;
        }

        try
        {
            StreamReader sr = new StreamReader(@path);
            string line = "";
            int formCpt = 1;
            InputField iField;
            Jardin jardin = new Jardin();

            //Lecture des eventuelles commentaire en amont
            while (line != "#FORMULES" && !sr.EndOfStream)
            {
                line = sr.ReadLine();
            }

            if (sr.EndOfStream)
            {
                sr.Close();
                ClosePanel();
                return;
            }
            //Lecture formules
            line = sr.ReadLine();
            while(line != "#JARDIN" && !sr.EndOfStream)
            {
                iField = (InputField)GameObject.Find(FORMULE_PATH + "Form_" + formCpt).GetComponent<InputField>();
                iField.text = line;
                formCpt++;
                if(formCpt > NB_FORMULE)
                {
                    break;
                }
                line = sr.ReadLine();
            }

            if (sr.EndOfStream)
            {
                sr.Close();
                ClosePanel();
                return;
            }
            //Lecture jardin
            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                string[] splitted = line.Split();
                jardin.Add(Int32.Parse(splitted[0]), Int32.Parse(splitted[1]),
                    splitted[2], splitted[3], splitted[4],
                    splitted[5].Length == 0 ? null : splitted[5]);
            }
            terrainHandler.setJardin(jardin);

            sr.Close();
            ClosePanel();
        }
        catch (Exception)
        {
            Debug.Log("Error while opening file path=" + path);
            return;
        }
    }
Exemple #32
0
 /// <summary>
 /// Sobrecarga de constructor.
 /// </summary>
 /// <param name="jardin"></param>
 public FrmJardin(Jardin jardin) : this()
 {
 }
Exemple #33
0
 public void SetJardin(Jardin jardin)
 {
     this.jardin = jardin;
 }
 public CreationJardinViewModel(INavigationService navigationService)
 {
     this.navigationService = navigationService;
     NewJardin = new Jardin();
 }
Exemple #35
0
 public void SetJardin(Jardin jardin)
 {
     this.jardin = jardin;
 }
 // Use this for initialization
 void Start()
 {
     _jardin = new Jardin();    //initialisation d'un jardin vide
     mode = ToggleType.View;  //le mode est en défault au départ
     lastMode = mode;
     _flower = null;
     _previousGameObject = null;
     buttonClean.onClick.AddListener(cleanJardin);
 }
Exemple #37
0
    public void VerifFormule()
    {
        Jardin      jardin = terrainHandler.getJardin();
        Communicate comm   = new Communicate(SCRIPT_PYTHON, jardin);

        //lance le script
        comm.GetSource().Execute(comm.GetScope());
        for (int i = 1; i <= NB_FORMULE; i++)
        {
            iField = (InputField)GameObject.Find(PATH + "Form_" + i).GetComponent <InputField>();
            output = (Text)GameObject.Find(PATH + "VerifPan_" + i + "/verif_resultat_" + i).GetComponent <Text>();

            if (iField.text == "")
            {
                continue;
            }
            try
            {
                Formule formule = FormuleFactory.parse(iField.text);


                foreach (Element el in jardin.GetElements())
                {
                    Debug.Log(el);
                }

                object pythonForm = comm.HandleForm(formule);
                Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul");
                object pythonJardin = unity_my_interp_formul(jardin);
                Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form");
                var res = unity_eval_one_form(pythonJardin, pythonForm);

                //Affiche résultat
                if ((bool)res == true)
                {
                    output.color = Color.green;
                    output.text  = "Vrai";
                }
                else
                {
                    output.color = Color.red;
                    output.text  = "Faux";
                }
            }
            catch (ParserLogException)
            {
                output.color = Color.red;
                output.text  = "Erreur";
                Debug.Log("Erreur formule");
            }
            catch (ValueErrorException)
            {
                output.color = new Color32(255, 128, 0, 255);
                output.text  = "Var libre";
            }
            catch (Exception)
            {
                output.color = Color.red;
                output.text  = "Erreur imprévue";
            }
        }
    }
Exemple #38
0
    void open()
    {
        string path = fName.options.ToArray()[fName.value].text;

        if (path.Length == 0)
        {
            /* Invalid path */
            Debug.Log("Invalid path");
            return;
        }

        try
        {
            StreamReader sr      = new StreamReader(@path);
            string       line    = "";
            int          formCpt = 1;
            InputField   iField;
            Jardin       jardin = new Jardin();

            //Lecture des eventuelles commentaire en amont
            while (line != "#FORMULES" && !sr.EndOfStream)
            {
                line = sr.ReadLine();
            }

            if (sr.EndOfStream)
            {
                sr.Close();
                ClosePanel();
                return;
            }
            //Lecture formules
            line = sr.ReadLine();
            while (line != "#JARDIN" && !sr.EndOfStream)
            {
                iField      = (InputField)GameObject.Find(FORMULE_PATH + "Form_" + formCpt).GetComponent <InputField>();
                iField.text = line;
                formCpt++;
                if (formCpt > NB_FORMULE)
                {
                    break;
                }
                line = sr.ReadLine();
            }

            if (sr.EndOfStream)
            {
                sr.Close();
                ClosePanel();
                return;
            }
            //Lecture jardin
            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                string[] splitted = line.Split();
                jardin.Add(Int32.Parse(splitted[0]), Int32.Parse(splitted[1]),
                           splitted[2], splitted[3], splitted[4],
                           splitted[5].Length == 0 ? null : splitted[5]);
            }
            terrainHandler.setJardin(jardin);

            sr.Close();
            ClosePanel();
        }
        catch (Exception)
        {
            Debug.Log("Error while opening file path=" + path);
            return;
        }
    }