static float SetQuantityInABond(BondTypes bond, ElementData bonding_atom, GameObject current_atom) //TODO:Ezt kitenni statikus osztályba { ChemistAtomModell current_atom_modell = current_atom.GetComponent <ChemistAtomModell>(); if (bond.Equals(BondTypes.Covalent)) { //TODO:Megcsinálni a kovalens kötéshez return(LoadPeriodicTable.table[current_atom_modell.Index].valence - current_atom_modell.CovalentConectedAtomPc / (float)bonding_atom.valence); } else if (bond.Equals(BondTypes.Ionic)) { int current_atom_valence_electrons = current_atom.GetComponent <ChemistAtomModell>().ElectronCount; int bonding_atom_last_shell_index = bonding_atom.shells.Length; if (current_atom_valence_electrons < 8 && current_atom_valence_electrons > 0) { return((8 - current_atom_modell.ElectronCount) / (float)bonding_atom.shells[bonding_atom_last_shell_index - 1]); } else { return(0); } } else if (bond.Equals(BondTypes.Metalic)) { //TODO:Megcsinálni ide a fémes kötéshez tartozó cuccost } return(0); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hitInfo; atom = GetClickedObject(out hitInfo); if (atom != null) { _mouseState = true; } } if (Input.GetMouseButtonUp(0)) { _mouseState = false; } if (_mouseState) { ChemistAtomModell atom_modell = atom.GetComponent <ChemistAtomModell>(); if (atom.transform.parent == null) { LoadElementsToList.RefreshButtonDatas(LoadPeriodicTable.table[atom_modell.Index]); } else { LoadElementsToList.RefreshButtonData(atom); } } }
private void CopyElectronsToOtherAtom(ChemistAtomModell from, ChemistAtomModell to) { for (int i = 0; i < from.ElectronCount; i++) { to.AddElectron(from[i]); to.LastElectron().transform.SetParent(to.transform); } for (int i = from.ElectronCount - 1; i >= 0; i--) { from.RemoveElectron(from[i]); } }
public bool CreateBond(GameObject satom, GameObject catom) { ChemistAtomModell s_atom_modell = satom.GetComponent <ChemistAtomModell>(); ChemistAtomModell c_atom_modell = catom.GetComponent <ChemistAtomModell>(); if (bonds == null) { bonds = Utility.FindObjectsWithTag(this.gameObject.transform, "c_bond_tube");//itt 0 lesz a listában } for (int i = 0; i < bonds.Count; i++) { if (bonds[i].transform.childCount == 1)//azaz csak a side atom van benne { for (int j = 0; j < s_atom_modell.CovalentBoundNumber; j++) { s_atom_modell[j].transform.SetParent(bonds[i].transform); c_atom_modell[i + j].transform.SetParent(bonds[i].transform); } return(true); } } return(true); }
private void OnTriggerEnter(Collider other) { int otherAtomNumber; int thisAtomNumber; ChemistAtomModell other_atom = other.gameObject.GetComponent <ChemistAtomModell>(); other.gameObject.GetComponent <DragAndDropAtom>().DropMouse(); this.gameObject.GetComponent <DragAndDropAtom>().DropMouse(); if (other_atom.Bond.Equals(BondTypes.Ionic) && (this.Bond.Equals(BondTypes.Ionic) || this.Bond.Equals(BondTypes.None)) && !other_atom.is_in_a_bond && this.ElectronCount > 0 && other_atom.ElectronCount > 0) { otherAtomNumber = other_atom.Index; thisAtomNumber = this.Index; if (LoadPeriodicTable.table[otherAtomNumber].electronnegativity > LoadPeriodicTable.table[thisAtomNumber].electronnegativity) { if (other_atom.ElectronCount < 8) { CopyElectronsToOtherAtom(this, other_atom); other_atom.changeElectrons = true; this.is_in_a_bond = true; other_atom.is_in_a_bond = true; this.CreateIon(other.gameObject, this.gameObject); LoadElementsToList.RefreshButtonData(other.gameObject); } } else { if (this.ElectronCount < 8) { CopyElectronsToOtherAtom(other_atom, this); this.changeElectrons = true; this.is_in_a_bond = true; other_atom.is_in_a_bond = true; this.CreateIon(other.gameObject, this.gameObject); LoadElementsToList.RefreshButtonData(this.gameObject); } } } else if (other_atom.Bond.Equals(BondTypes.Covalent) && (this.Bond.Equals(BondTypes.Covalent) || this.Bond.Equals(BondTypes.None)) && !other_atom.is_in_a_bond && !other_atom.is_side_atom && !this.is_side_atom) { otherAtomNumber = other_atom.Index; thisAtomNumber = this.Index; int otherAtomValence = LoadPeriodicTable.table[otherAtomNumber].valence; int otherAtomLastShellNumber = other_atom.LastShellPopulation; int thisAtomValence = LoadPeriodicTable.table[thisAtomNumber].valence; int thisAtomLastShellNumber = this.LastShellPopulation; if (other_atom.CovalentConectedAtomPc < otherAtomValence) { if (otherAtomNumber == thisAtomNumber)//ha ugyanazokat akrjuk összerakni { CreateMolecula(other.gameObject, this.gameObject, otherAtomValence, otherAtomLastShellNumber, thisAtomValence); LoadElementsToList.RefreshButtonData(other.gameObject); } else if (otherAtomValence > thisAtomValence)//ha a másik atom tud több atomhoz kapcsolódni, ő lesz a modell közepén { CreateMolecula(other.gameObject, this.gameObject, otherAtomValence, otherAtomLastShellNumber, thisAtomValence); LoadElementsToList.RefreshButtonData(other.gameObject); } else//ha nem akkor pedig ez { CreateMolecula(this.gameObject, other.gameObject, thisAtomValence, thisAtomLastShellNumber, otherAtomValence); LoadElementsToList.RefreshButtonData(this.gameObject); } } } else if (other_atom.Bond.Equals(BondTypes.Metalic) && (this.Bond.Equals(BondTypes.Metalic) || this.Bond.Equals(BondTypes.None)) && !other_atom.is_in_a_bond) { CreateMetal(other.gameObject, this.gameObject, other_atom.index + 1, this.index + 1); this.is_in_a_bond = true; other_atom.is_in_a_bond = true; for (int i = 0; i < this.valenceElectrons.Count; i++) { this.valenceElectrons[i].SetActive(false); } for (int i = 0; i < other_atom.ElectronCount; i++) { other_atom[i].SetActive(false); } this.changeElectrons = true; other_atom.changeElectrons = true; } }