Ejemplo n.º 1
0
 public Node(string name, Atome atome, GameObject sphere, Vector3 v)
 {
     Name     = name;
     Atome    = atome;
     Gobj     = sphere;
     Position = v;
 }
Ejemplo n.º 2
0
    void showMolecule(int id)
    {
        //create a sphere
        print("show molecule");
        //find molecule in list
        Vector3 origin, target;

        string[] nodes_str = moleculs[id].Formule.Split(',');

        foreach (string nodeposition_str in nodes_str)
        {
            string[] node_position_separation = nodeposition_str.Split('@');
            string   node_id_str = node_position_separation[0];
            string   node_str    = node_id_str.Split('$')[0];
            Atome    atome1      = atomes.Find(item => item.Key == node_str).Value;
            string   x           = node_position_separation[1].Split('&')[0];
            string   y           = node_position_separation[1].Split('&')[1];
            string   z           = node_position_separation[1].Split('&')[2];
            Vector3  v           = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z));
            CreateNode(node_id_str, atome1, v);
        }
        string[] edges_list_str = moleculs[id].Structure.Split(',');
        foreach (string edge_str in edges_list_str)
        {
            string[] a_to_a = edge_str.Split('-');            //separer les nodes
            Node     node1  = nodes.Find(item => item.Name == a_to_a[0]);
            Node     node2  = nodes.Find(item => item.Name == a_to_a[1]);
            CreateEdge(node1, node2);
        }
    }
Ejemplo n.º 3
0
    void CreateNode(string name, Atome atome, Vector3 v)
    {
        GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

        sphere.transform.SetParent(transform);
        sphere.transform.position = v;
        var sphereRenderer = sphere.GetComponent <Renderer>();

        sphereRenderer.material.SetColor("_Color", atome.Color);
        nodes.Add(new Node(name, atome, sphere, v));
        target = sphere.transform;
    }
Ejemplo n.º 4
0
        public static void Play()
        {
            string       txt    = System.IO.File.ReadAllText(@"C:\Yann\projets\LaChose\LaChose\resources\atomes.json", Encoding.UTF8);
            List <Atome> atomes = JsonConvert.DeserializeObject <List <Atome> >(txt);

            List <string> sequences = new List <string>()
            {
                "57", "75", "84", "07", "34", "99", "43", "57", "16", "14", "09", "53", "20", "22", "08", "07"
            };

            foreach (string s in sequences)
            {
                Atome a = atomes.FirstOrDefault(x => Convert.ToInt32(x.numero) == Convert.ToInt32(s));

                if (a != null)
                {
                    Debug.Write(a.symbole);
                }
            }

            Debug.WriteLine("");
        }
Ejemplo n.º 5
0
        public static void SearchWordInChimic()
        {
            string       atomJsonTxt = System.IO.File.ReadAllText(@"C:\Yann\projets\LaChose\LaChose\resources\atomes.json", Encoding.UTF8);
            List <Atome> atomes      = JsonConvert.DeserializeObject <List <Atome> >(atomJsonTxt);

            List <string> results   = new List <string>();
            var           dicoLines = File.ReadAllLines(@"C:\Yann\projets\LaChose\LaChose\resources\dela-fr-public.txt", Encoding.UTF8);

            foreach (string word in dicoLines)
            {
                string       workingWord = word;
                List <Atome> atomsNeeded = new List <Atome>();

                while (workingWord.Length > 0)
                {
                    //search 1 letter
                    string searchLetter = workingWord[0].ToString();

                    Atome a = atomes.FirstOrDefault(x => x.symbole.ToLower() == searchLetter.ToLower());

                    if (a != null)
                    {
                        atomsNeeded.Add(a);

                        if (workingWord.Length == 1)
                        {
                            //Mot complet
                            string info = word + " \t " + string.Join(" ", atomsNeeded.Select(x => x.symbole).ToArray()) + " \t " + string.Join(" ", atomsNeeded.Select(x => x.numero).ToArray());
                            Debug.WriteLine(info);
                            results.Add(info);
                            workingWord = ""; //on sort du while et on passe au suivant
                        }
                        else
                        {
                            workingWord = workingWord.Substring(1, workingWord.Length - 1);
                        }
                    }
                    else
                    {
                        //ya pas de résultats en 1 lettre, on tente en 2 lettres

                        if (workingWord.Length >= 2)
                        {
                            //search 2 letters
                            searchLetter = workingWord.Substring(0, 2);
                            Atome aa = atomes.FirstOrDefault(x => x.symbole.ToLower() == searchLetter.ToLower());

                            if (aa != null)
                            {
                                atomsNeeded.Add(aa);

                                if (workingWord.Length == 2)
                                {
                                    //Mot complet
                                    string info = word + " \t " + string.Join(" ", atomsNeeded.Select(x => x.symbole).ToArray()) + " \t " + string.Join(" ", atomsNeeded.Select(x => x.numero).ToArray());
                                    Debug.WriteLine(info);
                                    results.Add(info);
                                    workingWord = ""; //on sort du while et on passe au suivant
                                }
                                else
                                {
                                    workingWord = workingWord.Substring(2, workingWord.Length - 2);
                                }
                            }
                            else
                            {
                                //pas de symbole en 1 ou 2 lettres
                                workingWord = ""; //on sort du while et on passe au suivant
                            }
                        }
                        else
                        {
                            workingWord = ""; //on sort du while et on passe au suivant
                        }
                    }
                }
            }

            File.WriteAllLines(@"C:\Yann\projets\LaChose\LaChose\resources\results.txt", results, Encoding.UTF8);
        }