From bc2b9e02fdb692d56937bd37cc3d821ffb717424 Mon Sep 17 00:00:00 2001 From: Mathis Date: Fri, 12 Jan 2024 15:37:09 +0100 Subject: [PATCH] add Atomes Factory --- Assets/script.meta | 8 + Assets/script/AtomeFactory.cs | 49 ++++ Assets/script/AtomeFactory.cs.meta | 11 + Assets/script/AtomeInformation.cs | 37 +++ Assets/script/AtomeInformation.cs.meta | 11 + Assets/script/atomes.json | 364 +++++++++++++++++++++++++ Assets/script/atomes.json.meta | 7 + Assets/script/testing.cs | 14 + Assets/script/testing.cs.meta | 11 + QCAR/lh | 1 + QCAR/somedata16 | 1 + 11 files changed, 514 insertions(+) create mode 100644 Assets/script.meta create mode 100644 Assets/script/AtomeFactory.cs create mode 100644 Assets/script/AtomeFactory.cs.meta create mode 100644 Assets/script/AtomeInformation.cs create mode 100644 Assets/script/AtomeInformation.cs.meta create mode 100644 Assets/script/atomes.json create mode 100644 Assets/script/atomes.json.meta create mode 100644 Assets/script/testing.cs create mode 100644 Assets/script/testing.cs.meta create mode 100644 QCAR/lh create mode 100644 QCAR/somedata16 diff --git a/Assets/script.meta b/Assets/script.meta new file mode 100644 index 0000000..8ef40e1 --- /dev/null +++ b/Assets/script.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc73bef18aceb4a42a863be1de163d6f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/AtomeFactory.cs b/Assets/script/AtomeFactory.cs new file mode 100644 index 0000000..56e4361 --- /dev/null +++ b/Assets/script/AtomeFactory.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + + + +public class AtomeFactory : MonoBehaviour{ + + public TextAsset jsonFile; + + private static AtomeFactory instance; + + private AtomesInformation atomeInJson; + + private Dictionary AtomeDictionary; + + public AtomeFactory(TextAsset jsonFile){ + AtomeFactory.instance = this; + AtomeDictionary = new Dictionary(); + atomeInJson = JsonUtility.FromJson(jsonFile.text); + foreach (var atome in atomeInJson.atomes){ + AtomeDictionary.Add(atome.symbol, atome); + } + } + + public static AtomeFactory getInstrance(){ + if(AtomeFactory.instance == null){ + Debug.LogError("no Json file"); + } + return AtomeFactory.instance; + } + + public static AtomeFactory getInstrance(TextAsset jsonFile){ + if(AtomeFactory.instance == null){ + AtomeFactory.instance = new AtomeFactory(jsonFile); + } + return AtomeFactory.instance; + } + + public AtomeInformation createAtome(string symbol){ + if(!AtomeDictionary.ContainsKey(symbol)){ + Debug.LogError("Atome does not existe in json"); + } + AtomeInformation atome = AtomeDictionary[symbol]; + + return atome; + } + +} \ No newline at end of file diff --git a/Assets/script/AtomeFactory.cs.meta b/Assets/script/AtomeFactory.cs.meta new file mode 100644 index 0000000..42a23ca --- /dev/null +++ b/Assets/script/AtomeFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 455447ed8d2676a4ba2d5cf8247bd83c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/AtomeInformation.cs b/Assets/script/AtomeInformation.cs new file mode 100644 index 0000000..a099530 --- /dev/null +++ b/Assets/script/AtomeInformation.cs @@ -0,0 +1,37 @@ + +using System.Collections.Generic; +using System; + +[System.Serializable] +public class Properties { + public string yeardiscovered; + public string atomicmass; + public string standardstate; + public string groupblock; + public string discovered_by; + public string named_by; +} + +[System.Serializable] +public class Representation { + public string color; +} + +[System.Serializable] +public class AtomeInformation +{ + public int atomicNumber; + public string symbol; + public string name; + public int protons; + public int neutrons; + public Properties properties; + public Representation representation; +} + +[System.Serializable] +public class AtomesInformation +{ + // liste des liason entre les atoms + public AtomeInformation[] atomes; +} \ No newline at end of file diff --git a/Assets/script/AtomeInformation.cs.meta b/Assets/script/AtomeInformation.cs.meta new file mode 100644 index 0000000..6550188 --- /dev/null +++ b/Assets/script/AtomeInformation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d2ff888d2e46a254ebb339c8dd3ed083 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/atomes.json b/Assets/script/atomes.json new file mode 100644 index 0000000..1623fc7 --- /dev/null +++ b/Assets/script/atomes.json @@ -0,0 +1,364 @@ +{ + "atomes": [ + { + "atomicNumber": 1, + "symbol": "H", + "name": "Hydrogen", + "protons": 1, + "neutrons": 0, + "properties": { + "yeardiscovered": "1766", + "atomicmass": "1.008", + "standardstate": "gas", + "groupblock": "nonmetal", + "discovered_by": "Henry Cavendish", + "named_by": "Antoine Lavoisier" + }, + "representation": { + "color": "ffffff" + } + }, + { + "atomicNumber": 2, + "symbol": "He", + "name": "Helium", + "protons": 2, + "neutrons": 2, + "properties": { + "yeardiscovered": "1868", + "atomicmass": "4.0026", + "standardstate": "gas", + "groupblock": "noble gas", + "discovered_by": "Pierre Janssen, Norman Lockyer", + "named_by": null + }, + "representation": { + "color": "d9ebf7" + } + }, + { + "atomicNumber": 3, + "symbol": "Li", + "name": "Lithium", + "protons": 3, + "neutrons": 4, + "properties": { + "yeardiscovered": "1817", + "atomicmass": "6.94", + "standardstate": "solid", + "groupblock": "alkali metal", + "discovered_by": "Johan August Arfwedson", + "named_by": null + }, + "representation": { + "color": "cc80ff" + } + }, + { + "atomicNumber": 4, + "symbol": "Be", + "name": "Beryllium", + "protons": 4, + "neutrons": 5, + "properties": { + "yeardiscovered": "1798", + "atomicmass": "9.0122", + "standardstate": "solid", + "groupblock": "alkaline earth metal", + "discovered_by": "Louis Nicolas Vauquelin", + "named_by": null + }, + "representation": { + "color": "d9ffb3" + } + }, + { + "atomicNumber": 5, + "symbol": "B", + "name": "Boron", + "protons": 5, + "neutrons": 6, + "properties": { + "yeardiscovered": "1808", + "atomicmass": "10.81", + "standardstate": "solid", + "groupblock": "metalloid", + "discovered_by": "Sir Humphry Davy, Jöns Jakob Berzelius", + "named_by": null + }, + "representation": { + "color": "ff6666" + } + }, + { + "atomicNumber": 6, + "symbol": "C", + "name": "Carbon", + "protons": 6, + "neutrons": 6, + "properties": { + "yeardiscovered": "Ancient", + "atomicmass": "12.011", + "standardstate": "solid", + "groupblock": "nonmetal", + "discovered_by": "Unknown", + "named_by": null + }, + "representation": { + "color": "666666" + } + }, + { + "atomicNumber": 7, + "symbol": "N", + "name": "Nitrogen", + "protons": 7, + "neutrons": 7, + "properties": { + "yeardiscovered": "1772", + "atomicmass": "14.007", + "standardstate": "gas", + "groupblock": "nonmetal", + "discovered_by": "Daniel Rutherford", + "named_by": null + }, + "representation": { + "color": "4d4dff" + } + }, + { + "atomicNumber": 8, + "symbol": "O", + "name": "Oxygen", + "protons": 8, + "neutrons": 8, + "properties": { + "yeardiscovered": "1774", + "atomicmass": "15.999", + "standardstate": "gas", + "groupblock": "nonmetal", + "discovered_by": "Joseph Priestley", + "named_by": null + }, + "representation": { + "color": "ff4d4d" + } + }, + { + "atomicNumber": 9, + "symbol": "F", + "name": "Fluorine", + "protons": 9, + "neutrons": 10, + "properties": { + "yeardiscovered": "1670", + "atomicmass": "18.998", + "standardstate": "gas", + "groupblock": "halogen", + "discovered_by": "André-Marie Ampère", + "named_by": null + }, + "representation": { + "color": "99ffcc" + } + }, + { + "atomicNumber": 10, + "symbol": "Ne", + "name": "Neon", + "protons": 10, + "neutrons": 10, + "properties": { + "yeardiscovered": "1898", + "atomicmass": "20.180", + "standardstate": "gas", + "groupblock": "noble gas", + "discovered_by": "Sir William Ramsay, Morris Travers", + "named_by": null + }, + "representation": { + "color": "b3b3cc" + } + }, + { + "atomicNumber": 11, + "symbol": "Na", + "name": "Sodium", + "protons": 11, + "neutrons": 12, + "properties": { + "yeardiscovered": "1807", + "atomicmass": "22.990", + "standardstate": "solid", + "groupblock": "alkali metal", + "discovered_by": "Sir Humphry Davy", + "named_by": null + }, + "representation": { + "color": "ffcc99" + } + }, + { + "atomicNumber": 12, + "symbol": "Mg", + "name": "Magnesium", + "protons": 12, + "neutrons": 12, + "properties": { + "yeardiscovered": "1808", + "atomicmass": "24.305", + "standardstate": "solid", + "groupblock": "alkaline earth metal", + "discovered_by": "Sir Humphry Davy", + "named_by": null + }, + "representation": { + "color": "b3b3cc" + } + }, + { + "atomicNumber": 13, + "symbol": "Al", + "name": "Aluminum", + "protons": 13, + "neutrons": 14, + "properties": { + "yeardiscovered": "Ancient", + "atomicmass": "26.982", + "standardstate": "solid", + "groupblock": "post-transition metal", + "discovered_by": null, + "named_by": null + }, + "representation": { + "color": "999999" + } + }, + { + "atomicNumber": 14, + "symbol": "Si", + "name": "Silicon", + "protons": 14, + "neutrons": 14, + "properties": { + "yeardiscovered": "1823", + "atomicmass": "28.085", + "standardstate": "solid", + "groupblock": "metalloid", + "discovered_by": "Jöns Jakob Berzelius", + "named_by": "Thomas Thomson" + }, + "representation": { + "color": "ffcc66" + } + }, + { + "atomicNumber": 15, + "symbol": "P", + "name": "Phosphorus", + "protons": 15, + "neutrons": 16, + "properties": { + "yeardiscovered": "1669", + "atomicmass": "30.974", + "standardstate": "solid", + "groupblock": "nonmetal", + "discovered_by": "Hennig Brand", + "named_by": null + }, + "representation": { + "color": "cc6666" + } + }, + { + "atomicNumber": 16, + "symbol": "S", + "name": "Sulfur", + "protons": 16, + "neutrons": 16, + "properties": { + "yeardiscovered": "Ancient", + "atomicmass": "32.06", + "standardstate": "solid", + "groupblock": "nonmetal", + "discovered_by": null, + "named_by": null + }, + "representation": { + "color": "d9ff66" + } + }, + { + "atomicNumber": 17, + "symbol": "Cl", + "name": "Chlorine", + "protons": 17, + "neutrons": 18, + "properties": { + "yeardiscovered": "1774", + "atomicmass": "35.45", + "standardstate": "gas", + "groupblock": "halogen", + "discovered_by": "Carl Wilhelm Scheele", + "named_by": null + }, + "representation": { + "color": "66ff66" + } + }, + { + "atomicNumber": 18, + "symbol": "Ar", + "name": "Argon", + "protons": 18, + "neutrons": 22, + "properties": { + "yeardiscovered": "1894", + "atomicmass": "39.948", + "standardstate": "gas", + "groupblock": "noble gas", + "discovered_by": "Sir William Ramsay, Lord Rayleigh", + "named_by": null + }, + "representation": { + "color": "b3b3cc" + } + }, + { + "atomicNumber": 19, + "symbol": "K", + "name": "Potassium", + "protons": 19, + "neutrons": 20, + "properties": { + "yeardiscovered": "1807", + "atomicmass": "39.098", + "standardstate": "solid", + "groupblock": "alkali metal", + "discovered_by": "Sir Humphry Davy", + "named_by": null + }, + "representation": { + "color": "ff9966" + } + }, + { + "atomicNumber": 20, + "symbol": "Ca", + "name": "Calcium", + "protons": 20, + "neutrons": 20, + "properties": { + "yeardiscovered": "Ancient", + "atomicmass": "40.078", + "standardstate": "solid", + "groupblock": "alkaline earth metal", + "discovered_by": "Humphry Davy", + "named_by": null + }, + "representation": { + "color": "99ccff" + } + } + ] +} \ No newline at end of file diff --git a/Assets/script/atomes.json.meta b/Assets/script/atomes.json.meta new file mode 100644 index 0000000..a72d20f --- /dev/null +++ b/Assets/script/atomes.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ab8f44086e6af6f48a38b7d7d595e9a2 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/testing.cs b/Assets/script/testing.cs new file mode 100644 index 0000000..7fc7dfb --- /dev/null +++ b/Assets/script/testing.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + + +class AtomeFactoryTester: MonoBehaviour { + public TextAsset jsonFile; + + void Start(){ + AtomeFactory factory = AtomeFactory.getInstrance(this.jsonFile); + AtomeInformation mol = factory.createAtome("H"); + Debug.Log("sjkfos " + mol.representation.color); + } +} \ No newline at end of file diff --git a/Assets/script/testing.cs.meta b/Assets/script/testing.cs.meta new file mode 100644 index 0000000..af94aca --- /dev/null +++ b/Assets/script/testing.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a5d6e8f60d6677c45afc8dcf01ed4fa1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/QCAR/lh b/QCAR/lh new file mode 100644 index 0000000..6a3d423 --- /dev/null +++ b/QCAR/lh @@ -0,0 +1 @@ +SYa2q["b %SxYe. \ No newline at end of file diff --git a/QCAR/somedata16 b/QCAR/somedata16 new file mode 100644 index 0000000..891ff05 --- /dev/null +++ b/QCAR/somedata16 @@ -0,0 +1 @@ +AAABmY7g9UmlfucNZM2mK1+zBTca7O7gdAXUc9FcH4yUbYfsFOfH72rVb0qPESQq/9HBlqfD04SyJF6jtD6oQDsZxFAYgmMCBkOzNr/C/s4mdV37Qw5Nm9GqecPYpccvAWOqH/VAtFBp5ksgnAnVhuHUqh0NmvpixXq82Meo/bg7usPAWSDsQt/6kR89nttLOknq/Rt+SN8E91Txj6nsYZH8gsxrgC9MYPO0koHuIvfeLk0wcqrMzxZawaNLp6CNWgUYDXWIWW1AtB9dY5p56nnk/Yd4MyRevYDtcWdXCdiam48zdO470AuA8DkAFHOttVURidwRkVKq4z40E6J+5V3NqDg= \ No newline at end of file