// 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); } } }
void DestroyAtom(GameObject atom) { if (atom != null) { Destroy(atom); } LoadElementsToList.RefreshButtonData(null); }
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; } }