rajout de la gestion d'animation + des factory

This commit is contained in:
2024-01-18 16:28:39 +01:00
parent 9de97ad486
commit 58782722d3
7 changed files with 1819 additions and 361 deletions

View File

@ -23,7 +23,7 @@ public class AtomeFactory : MonoBehaviour{
}
}
public static AtomeFactory getInstrance(){
public static AtomeFactory getInstrance() {
if(AtomeFactory.instance == null){
Debug.LogError("no Json file");
}

View File

@ -27,28 +27,6 @@
"boilingPoint": -183.0
}
},
{
"name": "Eau",
"formula": "H2O",
"atoms": [
{
"element": "H2",
"geometry": [0.0, 0.0, 0.0]
},
{
"element": "O",
"geometry": [1.2, 0.0, 0.0]
}
],
"bonds": [
{"atoms": [0, 1], "order": 2}
],
"properties": {
"molecularMass": 32.0,
"meltingPoint": -218.8,
"boilingPoint": -183.0
}
},
{
"name": "Dioxygène",
"formula": "O2",

View File

@ -2,8 +2,6 @@ using System;
using System.Collections.Generic;
using UnityEngine;
public class MoleculeFactory : MonoBehaviour{
public TextAsset jsonFile;
@ -76,6 +74,32 @@ public class MoleculeFactory : MonoBehaviour{
return sortie;
}
public Molecule GetMoleculeByFormula(String formula)
{
if (!hasMolecule(formula))
{
return null;
}
Molecule molecule = moleculesDictionary[formula];
return molecule;
}
public Dictionary<String, AtomeInformation> GetAtomsInfoByFormula(String formula)
{
if (!hasMolecule(formula))
{
return null;
}
Dictionary<String, AtomeInformation> dictionary = new Dictionary<string, AtomeInformation>();
Molecule molecule = moleculesDictionary[formula];
foreach (var atom in molecule.atoms)
{
dictionary.Add(atom.element, atomeFactory.createAtome(atom.element));
}
return dictionary;
}
public void setAtomFactory(AtomeFactory atomeFactory){
this.atomeFactory = atomeFactory;
}