Merge pull request 'add Atomes Factory' (#10) from feature/AtomesFactory into develop
Reviewed-on: #10 Reviewed-by: Clement <clement@jo85.com>
This commit is contained in:
commit
807aa8c3c6
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 AtomeProps {
|
||||
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 AtomeProps 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:
|
2128
Assets/script/atomes.json
Normal file
2128
Assets/script/atomes.json
Normal file
File diff suppressed because it is too large
Load Diff
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:
|
@ -1 +1 @@
|
||||
AAABmQWapYRGu7Loo2wvgwZUGzXNOVLSaix1jbBp7+6hM1WFhjBkddUoLqWxkauNc7gcguqgEle3Gl3JhXdUv8TOSygVCeRnuokmoncR2/5V78p0F0Cfn5gBebVC39W8GQ6XkVyp75Y8d30EG+W8VKPfuse2cfavkxXpI2Nl3LSy0VRONL0XNPimQXCFL0ahAeUkOc37yrfYL9FrG7wg4Rw+k4YLs++CGJhpcKysknksOgQGrDLh9Hj9lfoKw+YWYwvTA55r6X388fA3hXuRGNehejMd4orrTqM65do7Uf0KR4eC/KXr5cmkSwN4FwRxWaGm16G0tXit+hD29lyZbT/XJ64=
|
||||
AAABmY7g9UmlfucNZM2mK1+zBTca7O7gdAXUc9FcH4yUbYfsFOfH72rVb0qPESQq/9HBlqfD04SyJF6jtD6oQDsZxFAYgmMCBkOzNr/C/s4mdV37Qw5Nm9GqecPYpccvAWOqH/VAtFBp5ksgnAnVhuHUqh0NmvpixXq82Meo/bg7usPAWSDsQt/6kR89nttLOknq/Rt+SN8E91Txj6nsYZH8gsxrgC9MYPO0koHuIvfeLk0wcqrMzxZawaNLp6CNWgUYDXWIWW1AtB9dY5p56nnk/Yd4MyRevYDtcWdXCdiam48zdO470AuA8DkAFHOttVURidwRkVKq4z40E6J+5V3NqDg=
|
Loading…
x
Reference in New Issue
Block a user