add Atomes Factory
This commit is contained in:
parent
2c93918e51
commit
bc2b9e02fd
8
Assets/script.meta
Normal file
8
Assets/script.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc73bef18aceb4a42a863be1de163d6f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
49
Assets/script/AtomeFactory.cs
Normal file
49
Assets/script/AtomeFactory.cs
Normal file
@ -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<string, AtomeInformation> AtomeDictionary;
|
||||
|
||||
public AtomeFactory(TextAsset jsonFile){
|
||||
AtomeFactory.instance = this;
|
||||
AtomeDictionary = new Dictionary<string, AtomeInformation>();
|
||||
atomeInJson = JsonUtility.FromJson<AtomesInformation>(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;
|
||||
}
|
||||
|
||||
}
|
11
Assets/script/AtomeFactory.cs.meta
Normal file
11
Assets/script/AtomeFactory.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 455447ed8d2676a4ba2d5cf8247bd83c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
Assets/script/AtomeInformation.cs
Normal file
37
Assets/script/AtomeInformation.cs
Normal file
@ -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;
|
||||
}
|
11
Assets/script/AtomeInformation.cs.meta
Normal file
11
Assets/script/AtomeInformation.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2ff888d2e46a254ebb339c8dd3ed083
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
364
Assets/script/atomes.json
Normal file
364
Assets/script/atomes.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
7
Assets/script/atomes.json.meta
Normal file
7
Assets/script/atomes.json.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab8f44086e6af6f48a38b7d7d595e9a2
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/script/testing.cs
Normal file
14
Assets/script/testing.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
11
Assets/script/testing.cs.meta
Normal file
11
Assets/script/testing.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5d6e8f60d6677c45afc8dcf01ed4fa1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1
QCAR/somedata16
Normal file
1
QCAR/somedata16
Normal file
@ -0,0 +1 @@
|
||||
AAABmY7g9UmlfucNZM2mK1+zBTca7O7gdAXUc9FcH4yUbYfsFOfH72rVb0qPESQq/9HBlqfD04SyJF6jtD6oQDsZxFAYgmMCBkOzNr/C/s4mdV37Qw5Nm9GqecPYpccvAWOqH/VAtFBp5ksgnAnVhuHUqh0NmvpixXq82Meo/bg7usPAWSDsQt/6kR89nttLOknq/Rt+SN8E91Txj6nsYZH8gsxrgC9MYPO0koHuIvfeLk0wcqrMzxZawaNLp6CNWgUYDXWIWW1AtB9dY5p56nnk/Yd4MyRevYDtcWdXCdiam48zdO470AuA8DkAFHOttVURidwRkVKq4z40E6J+5V3NqDg=
|
Loading…
x
Reference in New Issue
Block a user