コード例 #1
0
        public void TestCountValences()
        {
            IElement testSubject = new Hydrogen();
            var      testResult  = testSubject.CountValences;

            Console.WriteLine($"{testSubject.Name} {testResult}");
            Assert.AreEqual(1, testResult);

            testSubject = new Helium();
            testResult  = testSubject.CountValences;
            Console.WriteLine($"{testSubject.Name} {testResult}");
            Assert.AreEqual(0, testResult);

            testSubject = new Oxygen();
            testResult  = testSubject.CountValences;
            Console.WriteLine($"{testSubject.Name} {testResult}");
            Assert.AreEqual(2, testResult);

            testSubject = new Nitrogen();
            testResult  = testSubject.CountValences;
            Console.WriteLine($"{testSubject.Name} {testResult}");
            Assert.AreEqual(3, testResult);

            testSubject = new Carbon();
            testResult  = testSubject.CountValences;
            Console.WriteLine($"{testSubject.Name} {testResult}");
            Assert.AreEqual(4, testResult);

            testSubject = new Silicon();
            testResult  = testSubject.CountValences;
            Console.WriteLine($"{testSubject.Name} {testResult}");
        }
コード例 #2
0
    public void check()
    {
        syc = MainSystem.instance;
        h1  = H1.GetComponent <Hydrogen>();
        h2  = H2.GetComponent <Hydrogen>();

        h1.Ox = this;
        h2.Ox = this;
    }
コード例 #3
0
ファイル: TestBonds.cs プロジェクト: nofuture-git/31g
        public void TestPolarCovalent()
        {
            var testInput00 = new Oxygen();
            var testInput01 = new Hydrogen();

            var testOutput = BondFactory.CreateBond(testInput00, testInput01).GetBond <PolarCovalent>();

            Assert.IsNotNull(testOutput);
            var dipole = testOutput.DipoleVectorSize;

            Assert.IsTrue(dipole > 0D);

            Console.WriteLine(dipole);
        }
コード例 #4
0
ファイル: Hydrogen.cs プロジェクト: tacman/Molecules
    void OnTriggerEnter(Collider other)
    {
        if (_partner == null && other.gameObject.CompareTag("Hydrogen"))
        {
            Hydrogen otherHydrogen = (Hydrogen)other.gameObject.GetComponent("Hydrogen");

            if (otherHydrogen._partner == null) // two free radicals meet and form covalent bond
            {
                bondingParticleSystem.Play();
                _partner = other.gameObject;
                otherHydrogen._partner = this.gameObject;

                // chemical bond formation suddenly pulls slightly closer together
                float deltaX = _partner.transform.position.x - this.transform.position.x;
                float deltaY = _partner.transform.position.y - this.transform.position.y;
                float deltaZ = _partner.transform.position.z - this.transform.position.z;
                this.transform.position = new Vector3(
                    this.transform.position.x + 0.25f * deltaX,
                    this.transform.position.y + 0.25f * deltaY,
                    this.transform.position.z + 0.25f * deltaZ);
                _partner.transform.position = new Vector3(
                    _partner.transform.position.x - 0.25f * deltaX,
                    _partner.transform.position.y - 0.25f * deltaY,
                    _partner.transform.position.z - 0.25f * deltaZ);

                // @todo: change the color of both.

                // create SpringJoint to implement covalent bond between these two atoms
                springJoint = this.gameObject.AddComponent <SpringJoint>();
                springJoint.connectedBody       = other.gameObject.GetComponent <Rigidbody>();
                springJoint.anchor              = new Vector3(0, 0, 0);
                springJoint.connectedAnchor     = new Vector3(0, 0, 0);
                springJoint.spring              = 10;
                springJoint.minDistance         = 0.0f;
                springJoint.maxDistance         = 0.0f;
                springJoint.tolerance           = 0.025f;
                springJoint.breakForce          = Mathf.Infinity;
                springJoint.breakTorque         = Mathf.Infinity;
                springJoint.enableCollision     = false;
                springJoint.enablePreprocessing = true;
            }
        }
        if (other.gameObject.CompareTag("Wall"))
        {
            audioSource.PlayOneShot(audioClipBallBounce, 0.25f);
        }
    }
コード例 #5
0
ファイル: ResourcePool.cs プロジェクト: bsed/Freecon-Galactic
        public ResourcePool(ResourceTypes resourceType, int numUnits, float depletedRate)
        {
            switch (resourceType)
            {
            case ResourceTypes.Bauxite:
                Resource = new Bauxite();
                break;

            case ResourceTypes.Hydrocarbons:
                Resource = new Hydrocarbons();
                break;

            case ResourceTypes.Hydrogen:
                Resource = new Hydrogen();
                break;

            case ResourceTypes.IronOre:
                Resource = new IronOre();
                break;

            case ResourceTypes.Medicine:
                Resource = new Medicine();
                break;

            case ResourceTypes.Organics:
                Resource = new Organics();
                break;

            case ResourceTypes.Silica:
                Resource = new Silica();
                break;

            case ResourceTypes.ThoriumOre:
                Resource = new ThoriumOre();
                break;

            default:
                throw new Exception("Error: " + resourceType.ToString() + " not defined in ResourcePool constructor.");
            }


            Resource.AddResource(numUnits);
            DepletedRate = depletedRate;
        }
コード例 #6
0
ファイル: TestBonds.cs プロジェクト: nofuture-git/31g
        public void TestBondFactory()
        {
            IElement testInput00 = new Sodium();
            IElement testInput01 = new Chlorine();
            var      testResult  = BondFactory.CreateBond(testInput00, testInput01);

            Assert.IsTrue(testResult is Ionic);

            testInput00 = new Hydrogen();
            testInput01 = new Hydrogen();

            testResult = BondFactory.CreateBond(testInput00, testInput01);

            Assert.IsTrue(testResult.Is(typeof(PurelyCovalent)));

            testInput00 = new Hydrogen();
            testInput01 = new Chlorine();

            testResult = BondFactory.CreateBond(testInput00, testInput01);
            Assert.IsTrue(testResult.Is(typeof(PolarCovalent)));
        }
コード例 #7
0
 void SortingItems(ref List <MyInventoryItem> items)
 {
     foreach (var item in items)
     {
         if (item.Type.TypeId == "MyObjectBuilder_Component" && Components.ContainsKey(item.Type.SubtypeId)) // Если имя сходится с тем что в словаре
         {
             Components[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_Ingot" && Ingots.ContainsKey(item.Type.SubtypeId))
         {
             Ingots[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_Ore" && Ores.ContainsKey(item.Type.SubtypeId))
         {
             Ores[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_PhysicalGunObject" && Tools.ContainsKey(item.Type.SubtypeId))
         {
             Tools[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_OxygenContainerObject" && Oxygen.ContainsKey(item.Type.SubtypeId))
         {
             Oxygen[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_GasContainerObject" && Hydrogen.ContainsKey(item.Type.SubtypeId))
         {
             Hydrogen[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_AmmoMagazine" && Ammo.ContainsKey(item.Type.SubtypeId))
         {
             Ammo[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else
         {
             Warning += $"\n[{item.Type.TypeId}/{item.Type.SubtypeId}] отсутствует в словарях";
         }
     }
 }
コード例 #8
0
        public void TestPrintElectronShellCfg_All()
        {
            IElement testSubject;;

            testSubject = new Hydrogen();
            Console.WriteLine($"Hydrogen {testSubject.PrintElectronShellCfg()}");
            testSubject = new Helium();
            Console.WriteLine($"Helium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Lithium();
            Console.WriteLine($"Lithium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Beryllium();
            Console.WriteLine($"Beryllium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Boron();
            Console.WriteLine($"Boron {testSubject.PrintElectronShellCfg()}");
            testSubject = new Carbon();
            Console.WriteLine($"Carbon {testSubject.PrintElectronShellCfg()}");
            testSubject = new Nitrogen();
            Console.WriteLine($"Nitrogen {testSubject.PrintElectronShellCfg()}");
            testSubject = new Oxygen();
            Console.WriteLine($"Oxygen {testSubject.PrintElectronShellCfg()}");
            testSubject = new Fluorine();
            Console.WriteLine($"Fluorine {testSubject.PrintElectronShellCfg()}");
            testSubject = new Neon();
            Console.WriteLine($"Neon {testSubject.PrintElectronShellCfg()}");
            testSubject = new Sodium();
            Console.WriteLine($"Sodium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Magnesium();
            Console.WriteLine($"Magnesium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Aluminum();
            Console.WriteLine($"Aluminum {testSubject.PrintElectronShellCfg()}");
            testSubject = new Silicon();
            Console.WriteLine($"Silicon {testSubject.PrintElectronShellCfg()}");
            testSubject = new Phosphorus();
            Console.WriteLine($"Phosphorus {testSubject.PrintElectronShellCfg()}");
            testSubject = new Sulfur();
            Console.WriteLine($"Sulfur {testSubject.PrintElectronShellCfg()}");
            testSubject = new Chlorine();
            Console.WriteLine($"Chlorine {testSubject.PrintElectronShellCfg()}");
            testSubject = new Argon();
            Console.WriteLine($"Argon {testSubject.PrintElectronShellCfg()}");
            testSubject = new Potassium();
            Console.WriteLine($"Potassium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Calcium();
            Console.WriteLine($"Calcium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Scandium();
            Console.WriteLine($"Scandium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Titanium();
            Console.WriteLine($"Titanium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Vanadium();
            Console.WriteLine($"Vanadium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Chromium();
            Console.WriteLine($"Chromium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Manganese();
            Console.WriteLine($"Manganese {testSubject.PrintElectronShellCfg()}");
            testSubject = new Iron();
            Console.WriteLine($"Iron {testSubject.PrintElectronShellCfg()}");
            testSubject = new Cobalt();
            Console.WriteLine($"Cobalt {testSubject.PrintElectronShellCfg()}");
            testSubject = new Nickel();
            Console.WriteLine($"Nickel {testSubject.PrintElectronShellCfg()}");
            testSubject = new Copper();
            Console.WriteLine($"Copper {testSubject.PrintElectronShellCfg()}");
            testSubject = new Zinc();
            Console.WriteLine($"Zinc {testSubject.PrintElectronShellCfg()}");
            testSubject = new Gallium();
            Console.WriteLine($"Gallium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Germanium();
            Console.WriteLine($"Germanium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Arsenic();
            Console.WriteLine($"Arsenic {testSubject.PrintElectronShellCfg()}");
            testSubject = new Selenium();
            Console.WriteLine($"Selenium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Bromine();
            Console.WriteLine($"Bromine {testSubject.PrintElectronShellCfg()}");
            testSubject = new Krypton();
            Console.WriteLine($"Krypton {testSubject.PrintElectronShellCfg()}");
            testSubject = new Rubidium();
            Console.WriteLine($"Rubidium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Strontium();
            Console.WriteLine($"Strontium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Yttrium();
            Console.WriteLine($"Yttrium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Zirconium();
            Console.WriteLine($"Zirconium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Niobium();
            Console.WriteLine($"Niobium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Molybdenum();
            Console.WriteLine($"Molybdenum {testSubject.PrintElectronShellCfg()}");
            testSubject = new Technetium();
            Console.WriteLine($"Technetium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Ruthenium();
            Console.WriteLine($"Ruthenium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Rhodium();
            Console.WriteLine($"Rhodium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Palladium();
            Console.WriteLine($"Palladium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Silver();
            Console.WriteLine($"Silver {testSubject.PrintElectronShellCfg()}");
            testSubject = new Cadmium();
            Console.WriteLine($"Cadmium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Indium();
            Console.WriteLine($"Indium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Tin();
            Console.WriteLine($"Tin {testSubject.PrintElectronShellCfg()}");
            testSubject = new Antimony();
            Console.WriteLine($"Antimony {testSubject.PrintElectronShellCfg()}");
            testSubject = new Tellurium();
            Console.WriteLine($"Tellurium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Iodine();
            Console.WriteLine($"Iodine {testSubject.PrintElectronShellCfg()}");
            testSubject = new Xenon();
            Console.WriteLine($"Xenon {testSubject.PrintElectronShellCfg()}");
            testSubject = new Cesium();
            Console.WriteLine($"Cesium {testSubject.PrintElectronShellCfg()}");
            testSubject = new Barium();
            Console.WriteLine($"Barium {testSubject.PrintElectronShellCfg()}");
        }
コード例 #9
0
    /// <summary>
    /// Process the MeshDescription data sent back from the Combiner and make it appear!
    /// </summary>
    /// <param name="hash">Instance Hash.</param>
    /// <param name="meshDescriptions">MeshDescriptions.</param>
    /// <param name="materials">Materials.</param>
    IEnumerator CreateMeshes(int hash, Hydrogen.Threading.Jobs.MeshCombiner.MeshOutput[] meshOutputs)
    {
        // Make our meshes in Unity
                for (int x = 0; x < meshOutputs.Length; x++) {
                        var meshObject = new GameObject ();

                        var newMesh = Combiner.CreateMeshObject (meshOutputs [x], true);

                        meshObject.name = newMesh.Mesh.name;
                        meshObject.AddComponent<MeshFilter> ().sharedMesh = newMesh.Mesh;
                        meshObject.AddComponent<MeshRenderer> ().sharedMaterials = newMesh.Materials;

                        if (_parentLookup.ContainsKey (hash)) {
                                meshObject.transform.parent = _parentLookup [hash];
                        }

                        meshObject.transform.position = Vector3.zero;
                        meshObject.transform.rotation = Quaternion.identity;

                        // Fake Unity Threading
                        if (x > 0 && x % ThrottleRate == 0) {
                                yield return new WaitForEndOfFrame ();
                        }
                }

                if (_parentLookup.ContainsKey (hash)) {
                        _parentLookup.Remove (hash);
                }

                // Clear previous data (for demonstration purposes)
                // It could be useful to keep some mesh data in already parsed, then you could use the RemoveMesh function
                // to remove ones that you want changed, without having to reparse mesh data.
                Combiner.ClearMeshes ();
    }
コード例 #10
0
 /// <summary>
 /// This function is called in the example after the MeshCombiner has processed the meshes, it starts a Coroutine 
 /// to create the actual meshes based on the flat data. This is the most optimal way to do this sadly as we cannot
 /// create or touch Unity based meshes outside of the main thread.
 /// </summary>
 /// <param name="hash">Instance Hash.</param>
 /// <param name="meshOutputs">.</param>
 public void ThreadCallback(int hash, Hydrogen.Threading.Jobs.MeshCombiner.MeshOutput[] meshOutputs)
 {
     // This is just a dirty way to see if we can squeeze jsut a bit more performance out of Unity when
             // making all of the meshes for us (instead of it being done in one call, we use a coroutine with a loop.
             _threadRunning = false;
             StartCoroutine (CreateMeshes (hash, meshOutputs));
 }