Esempio n. 1
0
 private void Update()
 {
     if (atom.Element != null)
     {
         Isotope isotope = atom.Element.GetIsotope(atom.Nucleus.Mass);
         if (isotope != null)
         {
             formalNameUI.text = atom.Element.Name + "-" + atom.Nucleus.Mass;
             stableUI.text     = isotope.Stable ? "Stable" : "Radioactive";
         }
         else
         {
             formalNameUI.text = "Not Isotope";
             stableUI.text     = "Radioactive";
         }
         typeUI.text   = atom.Element.Type.ToString().Replace('_', ' ');
         typeImg.color = ElementTypeUtil.ColorFromType(atom.Element.Type);
     }
     else
     {
         formalNameUI.text = "";
         stableUI.text     = "";
         typeUI.text       = "";
         typeImg.color     = Color.black;
     }
 }
Esempio n. 2
0
 public Element(string name, string abbreviation, int atomicNumber, ElementType type, BlockType block, Isotope[] isotopes = null)
 {
     Name         = name;
     Abbreviation = abbreviation;
     AtomicNumber = atomicNumber;
     Type         = type;
     Block        = block;
     Isotopes     = isotopes;
     Common       = FindCommon();
 }
Esempio n. 3
0
        /// <summary>
        /// Set the atom to the most common form of an element
        /// </summary>
        /// <param name="protonCount">atomic number of the element to set</param>
        public void ForceToCommon(int protonCount)
        {
            //temporarily remove ingteractivity to force particles
            bool wasInteractable = interactable;

            interactable = false;

            //add or remove neutrons to match atomic number
            int protonDiff = protonCount - Nucleus.ProtonCount;

            workbench.NewAutoProton(protonDiff);
            Nucleus.TrimProtons(-protonDiff);

            //get the most common stable form of the element
            Element element = Elements.GetElement(protonCount);

            if (element != null)
            {
                //set the min and max isotope mass
                Nucleus.MassMax = element.MaxIsotope;
                Nucleus.MassMin = element.MinIsotope;

                Isotope common = element.Common;
                if (common != null)
                {
                    //add or remove neutrons to match mass
                    int neutronDiff = (common.Mass - protonCount) - Nucleus.NeutronCount;
                    workbench.NewAutoNeutron(neutronDiff);
                    Nucleus.TrimNeutrons(-neutronDiff);
                }
            }

            //add or remove shells to match element period
            while (shells.Count < Elements.GetShells(protonCount))
            {
                AddShell();
            }

            while (shells.Count > Elements.GetShells(protonCount))
            {
                RemoveShell();
            }

            //add or remove electrons to match charge
            int electronDiff = protonCount - ElectronCount;

            workbench.NewAutoElectron(electronDiff);
            OuterShell.TrimElectrons(-electronDiff);

            interactable = wasInteractable; //revert interactable state

            AdjustScale();
        }
Esempio n. 4
0
        private void Update()
        {
            //get the element
            Element = Elements.GetElement(Nucleus.ProtonCount);

            if (Element != null)
            {
                //set nucleus shake based on Isotope stability
                Isotope isotope = Element.GetIsotope(Nucleus.Mass);
                Nucleus.Shake = isotope != null ? !isotope.Stable : true;

                //set the min and max isotope mass
                Nucleus.MassMax = Element.MaxIsotope;
                Nucleus.MassMin = Element.MinIsotope;

                //Auto add Neutrons to make valid Isotope
                if (Nucleus.Mass < Element.MinIsotope)
                {
                    workbench.NewAutoNeutron();
                }

                //Auto remove Neutrons to make valid Isotope
                if (Nucleus.Mass > Element.MaxIsotope)
                {
                    Nucleus.TrimNeutrons();
                }
            }
            else
            {
                Nucleus.MassMax = 0;
                Nucleus.TrimNeutrons();
            }

            //add or remove shells to match element period
            while (shells.Count < Elements.GetShells(Nucleus.ProtonCount))
            {
                AddShell();
                AdjustScale();
            }

            while (shells.Count > Elements.GetShells(Nucleus.ProtonCount))
            {
                RemoveShell();
                AdjustScale();
            }
        }
Esempio n. 5
0
 private void Update()
 {
     if (atom.Element != null && Settings.SHAKE)
     {
         //check for radioactive isotope, and not already playing
         Isotope isotope = atom.Element.GetIsotope(atom.Nucleus.Mass);
         if (isotope != null && !isotope.Stable)
         {
             //make sure source isn't already looping
             if (!sources[0].isPlaying)
             {
                 sources[0].Play();
             }
         }
         else
         {
             sources[0].Stop();
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// gets the most common isotope of the element
        /// </summary>
        /// <returns></returns>
        private Isotope FindCommon()
        {
            Isotope common = null;

            //find the stable isotope with the greatest abundance
            foreach (Isotope isotope in Isotopes)
            {
                if (isotope.Stable && (common == null || isotope.Abundance > common.Abundance))
                {
                    common = isotope;
                }
            }

            //no stable isotopes, use middle isotope
            if (common == null)
            {
                //round up
                int isotopeIndex = Mathf.CeilToInt((MaxIsotope - MinIsotope) / 2.0f);
                common = Isotopes[isotopeIndex];
            }

            return(common);
        }