Exemplo n.º 1
0
    public void spawnNukleons(Nuclide nuclide)
    {
        resetAll();

        var spawnDistance = Mathf.Sqrt((SpherePrefab.transform.localScale.x * 10 * nuclide.NucleonCount) / (4 * Mathf.PI));

        Size = Data.SphereScaleElectron.x * (nuclide.ProtonCount + 5) + spawnDistance;

        if (transform.localPosition.y < Size * 2 + ArenaBoundaries.Thickness)
        {
            transform.localPosition = new Vector3(transform.localPosition.x, Size * 2 + ArenaBoundaries.Thickness, transform.localPosition.z);
        }

        for (int i = 0; i < nuclide.NucleonCount + nuclide.ProtonCount; i++)
        {
            if (i < nuclide.NeutronCount)
            {
                spawnNeutron(spawnDistance);
            }
            else if (i < nuclide.NucleonCount)
            {
                spawnProton(spawnDistance);
            }
            else
            {
                spawnElectron((50 - Mathf.Pow(getPrincipalQuantumNumber(i - nuclide.NucleonCount + 1), 1.5f)) * ((i - nuclide.NucleonCount + 2) / 2f == (i - nuclide.NucleonCount + 2) / 2 ? -1 : 1), Data.SphereScaleElectron.x * (i - nuclide.NucleonCount + 4) + spawnDistance, getElectronRotationAxis(i - nuclide.NucleonCount + 1));
            }
        }
    }
Exemplo n.º 2
0
    public void ProcessDecayChain(Nuclide nuclide, Vector3 pos, float time, bool deleteOuterNucleons)
    {
        var nps = AddNuclide(pos);

        nps.ChangeNuclideType(nuclide);
        StartCoroutine("decayChainCoroutine", new DecayChainArguments(nps, pos, time, deleteOuterNucleons));
    }
Exemplo n.º 3
0
        public void TestNuclide_GetLongTable()
        {
            int ix = 0;

            foreach (string actualASCII in Nuclide.GetLongTable())
            {
                Assert.AreEqual(expectedASCII[ix], actualASCII);
                ++ix;
            }
        }
Exemplo n.º 4
0
 public void TestNuclide_CheckMethods()
 {
     Assert.AreEqual(Nuclide.Table.Count - 1, Nuclide.GetElements().Count());
     Assert.IsTrue(Nuclide.GetLongTable().Count() >= 7);
     Assert.AreEqual("Kalium", Nuclide.Table[19].GetName("de"));
     Assert.AreEqual("Yodo", Nuclide.Table[53].GetName(new CultureInfo("es")));
     Assert.AreEqual("Sulfur", Nuclide.Table[16].GetName(new CultureInfo("en")));
     Assert.AreEqual("Sulphur", Nuclide.Table[16].GetName(new CultureInfo("en-GB")));
     Assert.AreEqual("Caesium", Nuclide.Table[55].GetName(new CultureInfo("en")));
     Assert.AreEqual("Cesium", Nuclide.Table[55].GetName(new CultureInfo("en-US")));
 }
Exemplo n.º 5
0
        /// <summary>
        /// async load a library from file
        /// </summary>
        /// <param name="file">The path to the file</param>
        /// <returns></returns>
        public override async Task LoadLibraryAsync(string file)
        {
            //if the file dosen't exist
            if (!File.Exists(file))
            {
                return;
            }

            if (lib == null)
            {
                InitilizeLib();
            }

            //read the file
            camfile.ReadFile(file);

            //get the data from the file async
            Task <Nuclide[]> nucTask = Task.Run(() => camfile.GetNuclides().ToArray());

            //parse the nuclides
            Nuclide[] nucs = await nucTask;

            foreach (Nuclide nuc in nucs)
            {
                DataRow nucRow = lib.Tables["MATCHEDNUCLIDES"].NewRow();
                nucRow["ID"]             = nuc.Index;
                nucRow["NAME"]           = nuc.Name.Trim();
                nucRow["HALF_LIFE"]      = nuc.HalfLife;
                nucRow["HALF_LIFE_UNIT"] = nuc.HalfLifeUnit.Trim();
                lib.Tables["MATCHEDNUCLIDES"].Rows.Add(nucRow);
            }
            //parse the lines
            Line[] lines = camfile.Lines.ToArray();
            int    ln    = 0;

            foreach (Line line in lines)
            {
                DataRow nucRow = lib.Tables["MATCHEDLINES"].NewRow();
                //check if the name has changed, if so reset the line number

                //check for bad lines
                Nuclide nuc = nucs.Where(r => r.Index == line.NuclideIndex).FirstOrDefault();

                nucRow["NAME"]       = nuc.Name;
                nucRow["LINENUMBER"] = ln;
                nucRow["ENERGY"]     = line.Energy;
                nucRow["ENERGYUNC"]  = line.EnergyUncertainty;
                nucRow["YIELD"]      = line.Abundance;
                nucRow["YIELDUNC"]   = line.AbundanceUncertainty;
                nucRow["ISKEY"]      = line.IsKeyLine;
                lib.Tables["MATCHEDLINES"].Rows.Add(nucRow);
                ln++;
            }
        }
Exemplo n.º 6
0
 public void Deactivate(bool startDecayChain)
 {
     if (startDecayChain)
     {
         var pos       = new Vector3(InputX.text != "" ? (InputX.text.StartsWith("-") ? (InputX.text.Length == 1 ? 0F : -float.Parse(InputX.text.Substring(1))) : float.Parse(InputX.text)) : 0F, InputY.text != "" ? (InputY.text.StartsWith("-") ? (InputY.text.Length == 1 ? 0F : -float.Parse(InputY.text.Substring(1))) : float.Parse(InputY.text)) : 0F, InputZ.text != "" ? (InputZ.text.StartsWith("-") ? (InputZ.text.Length == 1 ? 0F : -float.Parse(InputZ.text.Substring(1))) : float.Parse(InputZ.text)) : 0F);
         var decayTime = InputDecayTime.text != "" ? (float.Parse(InputDecayTime.text) < 0 ? 0F : float.Parse(InputDecayTime.text)) : 0F;
         var nuclide   = new Nuclide(InputProtons.text != "" ? (int.Parse(InputProtons.text) < 0 ? 0 : int.Parse(InputProtons.text)) : 0, InputNeutrons.text != "" ? (int.Parse(InputNeutrons.text) < 0 ? 0 : int.Parse(InputNeutrons.text)) : 0);
         cfdpanel.ProcessDecayChain(nuclide, pos, decayTime, !ToggleDeleteOuterNucleons.isOn);
     }
     if (callOnDeactivate != null)
     {
         callOnDeactivate.Invoke(this);
     }
 }
Exemplo n.º 7
0
 private void ResetAll(bool respawn = false)
 {
     foreach (var nukleon in nucleons)
     {
         Destroy(nukleon);
     }
     nucleons           = new List <GameObject>();
     outerDecayNucleons = new Nuclide(0, 0);
     Gamestate          = GameState.Normal;
     if (respawn)
     {
         SpawnNukleons(Nuclide);
     }
 }
Exemplo n.º 8
0
        public void TestNuclide_GetBySymbol()
        {
            Nuclide actual1 = Nuclide.Table.FirstOrDefault(x => x.Symbol == "W");

            Assert.AreEqual(74, actual1.Z);

            Nuclide actual2 = Nuclide.GetBySymbol("W");

            Assert.AreEqual(74, actual2.Z);

            Nuclide actual3 = Nuclide.GetBySymbol("Xy");

            Assert.IsNull(actual3);
        }
Exemplo n.º 9
0
        public void TestNuclide_CheckAll()
        {
            int expected = 0;

            foreach (Nuclide nuc in Nuclide.Table)
            {
                foreach (Isotope iso in nuc.Isotopes)
                {
                    Assert.AreEqual(nuc.Z, iso.Z);
                    ++expected;
                }
            }

            Assert.AreEqual(expected, Nuclide.GetIsotopes().Count() + 1);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Returns the Nuclide Number from the Atomic Number.
        /// </summary>
        /// <returns></returns>
        public virtual int GetNuclideNumber()
        {
            for (var i = 0; i < Nuclide.Length; ++i)
            {
                if (char.IsNumber(Nuclide[i]))
                {
                    continue;
                }

                var numberString = Nuclide.Substring(0, i);
                var nuclideValue = int.Parse(numberString);
                return(nuclideValue);
            }

            return(-1);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Write the data to a CAM file
        /// </summary>
        private void WriteDataToFile()
        {
            //check if there are things to even write
            if (lib.Tables["MATCHEDNUCLIDES"].Rows.Count < 1 && lib.Tables["MATCHEDLINES"].Rows.Count < 1)
            {
                return;
            }

            //clear the file first
            if (File.Exists(file))
            {
                File.Delete(file);
            }

            foreach (DataRow nuclide in lib.Tables["MATCHEDNUCLIDES"].Rows)
            {
                DataRow[] nucLines = lib.Tables["MATCHEDLINES"].Select("NAME = '" + nuclide["NAME"] + "'", "ENERGY ASC");
                //always do the lines first
                foreach (DataRow nucLine in nucLines)
                {
                    Line line = new Line
                    {
                        Abundance            = (double)nucLine["YIELD"],
                        Energy               = (double)nucLine["ENERGY"],
                        EnergyUncertainty    = nucLine["ENERGYUNC"] == DBNull.Value ? GetUncertainty((double)nucLine["ENERGY"]) : (double)nucLine["ENERGYUNC"],
                        AbundanceUncertainty = nucLine["YIELDUNC"] == DBNull.Value ? GetUncertainty((double)nucLine["YIELD"]) : (double)nucLine["YIELDUNC"],
                        IsKeyLine            = (bool)nucLine["ISKEY"],
                        NuclideIndex         = (int)(short)nuclide["ID"]
                    };
                    //add the line
                    camfile.AddLine(line);
                }
                //now do the nuclide
                Nuclide nuc = new Nuclide
                {
                    Name                = ((string)nuclide["NAME"]).Trim(),
                    HalfLife            = (double)nuclide["HALF_LIFE"],
                    HalfLifeUnit        = ((string)nuclide["HALF_LIFE_UNIT"]).Trim(),
                    HalfLifeUncertainty = GetUncertainty((double)nuclide["HALF_LIFE"]),
                    Index               = (int)(short)nuclide["ID"]
                };
                //add the nuclide
                camfile.AddNuclide(nuc);
            }
            camfile.CreateFile(file);
        }
Exemplo n.º 12
0
    public void Deactivate(Nuclide nuclide = null)
    {
        this.gameObject.SetActive(false);
        if (nuclide != null && call != null)
        {
            call.Invoke(nuclide.ProtonCount, nuclide.NeutronCount);
        }

        zoom = 0;
        Panel.transform.localPosition = Vector3.zero;
        foreach (var btn in nuclidebuttons)
        {
            var script = btn.GetComponent <NuclideButtonScript>();
            btn.transform.localPosition = new Vector3((float)(script.nuclide.NucleonCount - 0.5) * baseWidth * (zoom + 1), (float)(script.nuclide.ProtonCount + 0.5) * baseHeight * (zoom + 1), 0);
            btn.GetComponent <RectTransform>().sizeDelta = new Vector2(baseWidth * (zoom + 1), baseHeight * (zoom + 1));
        }
    }
Exemplo n.º 13
0
    private void SpawnNukleons(Nuclide nuclide)
    {
        ResetAll();

        spawnDistance = CalculateSpawnDistance(nuclide.NucleonCount);

        for (int i = 0; i < nuclide.NucleonCount; i++)
        {
            var obj           = Instantiate(Sphere);
            var nukleonscript = obj.GetComponent <NukleonScript>();
            nukleonscript.massPoint = MassPointNormal;
            if (i < nuclide.NeutronCount)
            {
                obj.GetComponent <Renderer>().material = MatN;
                nukleonscript.nucleonType = NukleonScript.NucleonType.Neutron;
                nukleonscript.fakeType    = NukleonScript.NucleonType.Neutron;
            }
            else
            {
                obj.GetComponent <Renderer>().material = MatZ;
                nukleonscript.nucleonType = NukleonScript.NucleonType.Proton;
                nukleonscript.fakeType    = NukleonScript.NucleonType.Proton;
            }

            nukleonscript.fast = false;

            obj.transform.SetParent(transform, false);

            var vec = new Vector3((float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f);
            vec.Normalize();

            vec *= spawnDistance;
            obj.transform.localPosition = vec + MassPointNormal;

            nucleons.Add(obj);
        }
    }
Exemplo n.º 14
0
 public void ResetNormal(bool removeNeutron = true)
 {
     if (Gamestate == GameState.Fission && removeNeutron)
     {
         nucleons.Where(n => n.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron).Take(1).ToList().ForEach(n => { nucleons.Remove(n); Destroy(n); });
     }
     foreach (var nukleon in nucleons)
     {
         nukleon.GetComponent <NukleonScript>().massPoint = MassPointNormal;
         if (nukleon.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron)
         {
             nukleon.GetComponent <Renderer>().material = MatN;
         }
         if (nukleon.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Proton)
         {
             nukleon.GetComponent <Renderer>().material = MatZ;
         }
         nukleon.GetComponent <NukleonScript>().fakeType = nukleon.GetComponent <NukleonScript>().nucleonType;
     }
     CalculateNuclideCombination(true);
     outerDecayNucleons = new Nuclide(0, 0);
     Gamestate          = GameState.Normal;
     spawnDistance      = CalculateSpawnDistance(Nuclide.NucleonCount);
 }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            var culture = new CultureInfo(args.Length == 0 ? "en" : args[0]);

            Console.WriteLine("; z,symbol,name,period,group,category,discoveryYear,discoveryIndex,stableCount,stabilityIndex,block,occurrenceCode,lifeCode,stateCode,melt,boil,weight");
            foreach (var nuc in Nuclide.Table)
            {
                Console.WriteLine(nuc.ToFixedWidthString(culture));
            }

            Console.WriteLine();
            Console.WriteLine("; decayModeCode,decayModeSymbol,decayModeName");
            for (var ix = 0; ix < Nuclide.DecayModeSymbols.Count; ++ix)
            {
                Console.WriteLine($"{Nuclide.DecayModeCodes[ix]} {Nuclide.DecayModeSymbols[ix],-5}{Nuclide.DecayModeNames[culture.TwoLetterISOLanguageName][ix]}");
            }

            Console.WriteLine();
            Console.WriteLine("; z,symbol,z,occurrenceCode,stabilityIndex,decayModeCode,productZ,productSymbol,productA");
            foreach (var nuc in Nuclide.Table)
            {
                foreach (var iso in nuc.Isotopes)
                {
                    var part1 = $"{nuc.Z,3} {nuc.Symbol,-3}{iso.A,3}";
                    if (iso.DecayMode == Decay.None)
                    {
                        Console.WriteLine(part1);
                    }
                    else
                    {
                        var orgChar = iso.Occurrence == Origin.Synthetic ? ' ' : Nuclide.OccurrenceCodes[(int)iso.Occurrence];
                        foreach (var decayIndex in iso.GetDecayIndexes())
                        {
                            var productZ = iso.Transmute(decayIndex, out int productA);
                            Console.WriteLine($"{part1} {orgChar}{iso.StabilityIndex}{Nuclide.DecayModeCodes[decayIndex]} {productZ,3} {Nuclide.Table[productZ].Symbol,-3}{productA,3}");
                        }
                    }
                }
            }

            Console.WriteLine();
            Console.WriteLine("; z,symbol,a,abundance,occurrenceCode,decayModeCodes,halflife");
            foreach (var nuc in Nuclide.Table)
            {
                double total = 0.0;
                foreach (var iso in nuc.Isotopes)
                {
                    Console.WriteLine($"{nuc.Z,3} {nuc.Symbol,-3}{iso.ToFixedWidthString(culture)}");
                    if (iso.IsNatural)
                    {
                        total += iso.Abundance.Value;
                    }
                }
                //if ((total >= 0.1 && total <= 99.1) || total > 100.1)
                //    Console.WriteLine ("*** total = " + total);
            }

            Console.WriteLine();
            Console.WriteLine("; languageCode,totalDiffs");
            var langHits = new Dictionary <string, int>();

            foreach (var nuc in Nuclide.Table)
            {
                foreach (var kv in nuc.NameMap)
                {
                    langHits.TryGetValue(kv.Key, out int v);
                    langHits[kv.Key] = v + 1;
                }
            }
            foreach (var lg in langHits)
            {
                Console.WriteLine($"{lg.Key,-5}{lg.Value,4}");
            }

            Console.WriteLine();
            foreach (var lx in Nuclide.GetLongTable())
            {
                Console.WriteLine(lx);
            }
        }
Exemplo n.º 16
0
 public void TestIsotope_Nuclide_ArgumentOutOfRange()
 {
     var     badIsotope = new Isotope(200, 400, 0.0);
     Nuclide _          = badIsotope.Nuclide;
 }
Exemplo n.º 17
0
    private bool CreateDecay(string type)
    {
        if (type == null || type.Equals(string.Empty))
        {
            this.ResetNormal();
            outerDecayNucleons = new Nuclide(0, 0);
            return(false);
        }
        else
        {
            if (Gamestate == GameState.Decay)
            {
                this.ResetNormal();
            }

            if (Nuclide.IsNuclideString(type.ToLower()))
            {
                var nuclide = Nuclide.FromString(type.ToLower());
                if (this.Nuclide.NeutronCount <= nuclide.NeutronCount && this.Nuclide.ProtonCount <= nuclide.ProtonCount)
                {
                    return(false);
                }

                var position = new Vector3((float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f);
                position.Normalize();
                position *= MassPointAlpha.magnitude;

                var neutrons = nucleons.FindAll(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().massPoint == MassPointNormal);
                neutrons.Sort(new PositionDistanceComparer(position));
                foreach (var sphere in neutrons.Take(nuclide.NeutronCount))
                {
                    sphere.GetComponent <NukleonScript>().massPoint = position;
                }

                var protons = nucleons.FindAll(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().massPoint == MassPointNormal);
                protons.Sort(new PositionDistanceComparer(position));
                foreach (var sphere in protons.Take(nuclide.ProtonCount))
                {
                    sphere.GetComponent <NukleonScript>().massPoint = position;
                }
            }
            else if (Regex.IsMatch(type.ToLower(), "(it|fe|f)"))
            {
                return(false);
            }
            else if (type.ToLower().Equals("sf"))
            {
                return(false);
            }
            else
            {
                int pos        = 0;
                int multiplier = 1;

                if (Regex.IsMatch(type.ToLower(), "^(\\d+)"))
                {
                    var match = Regex.Match(type.ToLower(), "^(\\d+)");
                    multiplier = int.Parse(match.Value);
                    pos       += match.Length;
                }

                while (pos < type.ToLower().Length)
                {
                    var sub = type.Substring(pos);
                    //print("Substring: " + sub);

                    //print((sub.StartsWith("e") || sub.StartsWith("b+")) + "|" + sub.StartsWith("a") + "|" + sub.StartsWith("b-") + "|" + sub.StartsWith("n") + "|" + sub.StartsWith("p"));

                    if (sub.StartsWith("e") || sub.StartsWith("b+"))
                    {
                        if (nucleons.Count(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().massPoint == MassPointNormal) < multiplier)
                        {
                            return(false);
                        }

                        var protons = nucleons.FindAll(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().massPoint == MassPointNormal);
                        protons.Sort(new MassPointDistanceComparer());
                        foreach (var proton in protons.Take(multiplier))
                        {
                            proton.GetComponent <Renderer>().material      = MatN;
                            proton.GetComponent <NukleonScript>().fakeType = NukleonScript.NucleonType.Neutron;
                        }

                        pos += sub.StartsWith("e") ? 1 : 2;
                    }
                    else if (sub.StartsWith("a"))
                    {
                        if (nucleons.Count(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().massPoint == MassPointNormal) <= 2 * multiplier && nucleons.Count(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().massPoint == MassPointNormal) <= 2 * multiplier)
                        {
                            return(false);
                        }

                        for (int i = 0; i < multiplier; i++)
                        {
                            var position = new Vector3((float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f);
                            position.Normalize();
                            position *= MassPointAlpha.magnitude;

                            var neutrons = nucleons.FindAll(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().massPoint == MassPointNormal);
                            neutrons.Sort(new PositionDistanceComparer(position));
                            foreach (var sphere in neutrons.Take(2))
                            {
                                sphere.GetComponent <NukleonScript>().massPoint = position;
                            }

                            var protons = nucleons.FindAll(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().massPoint == MassPointNormal);
                            protons.Sort(new PositionDistanceComparer(position));
                            foreach (var sphere in protons.Take(2))
                            {
                                sphere.GetComponent <NukleonScript>().massPoint = position;
                            }
                        }

                        pos++;
                    }
                    else if (sub.StartsWith("b-"))
                    {
                        if (nucleons.Count(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().massPoint == MassPointNormal) < multiplier)
                        {
                            return(false);
                        }

                        var neutrons = nucleons.FindAll(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().massPoint == MassPointNormal);
                        neutrons.Sort(new MassPointDistanceComparer());
                        foreach (var neutron in neutrons.Take(multiplier))
                        {
                            neutron.GetComponent <Renderer>().material      = MatZ;
                            neutron.GetComponent <NukleonScript>().fakeType = NukleonScript.NucleonType.Proton;
                        }

                        pos += 2;
                    }
                    else if (sub.StartsWith("n"))
                    {
                        if (nucleons.Count(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().massPoint == MassPointNormal) < multiplier)
                        {
                            return(false);
                        }

                        for (int i = 0; i < multiplier; i++)
                        {
                            var position = new Vector3((float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f);
                            position.Normalize();
                            position *= MassPointNeutron.magnitude;

                            var neutrons = nucleons.FindAll(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Neutron && go.GetComponent <NukleonScript>().massPoint == MassPointNormal);
                            neutrons.Sort(new PositionDistanceComparer(position));
                            neutrons[0].GetComponent <NukleonScript>().massPoint = position;
                        }

                        pos++;
                    }
                    else if (sub.StartsWith("p"))
                    {
                        if (nucleons.Count(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().massPoint == MassPointNormal) < multiplier)
                        {
                            return(false);
                        }

                        for (int i = 0; i < multiplier; i++)
                        {
                            var position = new Vector3((float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f);
                            position.Normalize();
                            position *= MassPointProton.magnitude;

                            var protons = nucleons.FindAll(go => go.GetComponent <NukleonScript>().nucleonType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().fakeType == NukleonScript.NucleonType.Proton && go.GetComponent <NukleonScript>().massPoint == MassPointNormal);
                            protons.Sort(new PositionDistanceComparer(position));
                            protons[0].GetComponent <NukleonScript>().massPoint = position;
                        }

                        pos++;
                    }
                    else
                    {
                        pos++;
                    }
                }
            }

            CalculateShownInnerNuclide();

            return(true);
        }
    }
Exemplo n.º 18
0
 public void ChangeNuclideType(Nuclide nuclide)
 {
     inputN.text = nuclide.NeutronCount.ToString();
     inputP.text = nuclide.ProtonCount.ToString();
 }