예제 #1
0
        void OnDisable()
        {
            CUE cue = CUE.GetInstance();

            // Remove molecule form MoleculeManager
            cue.Molecules.Remove(this);
        }
예제 #2
0
        void OnEnable()
        {
            CUE cue = CUE.GetInstance();

            // Register molecule to MoleculeManager
            cue.Molecules.Add(this);
        }
예제 #3
0
        void FixedUpdate()
        {
            //
            // When in reaction, add attraction force to the location of the reaction
            //

            ReactionPrep r = ReactionPrep;

            if (r != null && r.Active)
            {
                Vector3 destination = r.GetExpectedReactionLocation();

                Vector3 force = Vector3.Normalize(destination - Position);

                rigidbody.AddForce(force, ForceMode.Acceleration);

                //Debug.Log(force);
            }

            //
            // Collide with compartment wall
            //

            CUE cue = CUE.GetInstance();

            cue.CheckCompartmentCollision(this);
        }
예제 #4
0
        /// <summary>
        /// Assigns a reaction prep, that indicates that the molecule is involved in a reaction.
        /// The MoleculeManager is updated.
        /// </summary>
        /// <param name="reactionPrep">Reaction prep.</param>
        public void AssignReactionPrep(ReactionPrep reactionPrep)
        {
            this.reactionPrep = reactionPrep;

            CUE cue = CUE.GetInstance();

            cue.Molecules.AssignReactionPrep(this);
        }
예제 #5
0
        void OnMouseDown()
        {
            // select molecule
            CUE cue = CUE.GetInstance();

            cue.ReactionManager.SelectedMolecule = this;
            cue.ScriptManager.GetOrAddScript <CellUnity.View.MoleculeSelectScript> ().enabled = true;
        }
예제 #6
0
        /// <summary>
        /// Releases the reaction prep. Called when a planned reaction is not performed (e.g. when
        /// not enough molecules available or an reaction occurs). ReactionPrep is set to null again.
        /// </summary>
        public void ReleaseReactionPrep()
        {
            if (this.reactionPrep != null)
            {
                this.reactionPrep = null;

                CUE cue = CUE.GetInstance();
                cue.Molecules.ReleaseReactionPrep(this);
            }
        }
예제 #7
0
        /// <summary>
        /// Clears the reaction prep after the reaction was performed. The molecule is
        /// removed from the MoleculeManager. Molecule must be deleted after calling this method
        /// </summary>
        public void ClearReactionPrep()
        {
            if (this.reactionPrep != null)
            {
                CUE cue = CUE.GetInstance();
                cue.Molecules.ClearReactionPrep(this);

                this.reactionPrep = null;
            }
        }
예제 #8
0
        /// <summary>
        /// Delete this species.
        /// All molecules associated with this species are removed. The prefab is also deleted.
        /// </summary>
        public void Delete()
        {
            CUE cue = CUE.GetInstance();

            cue.RemoveMolecules(this);

            if (PrefabPath != null)
            {
                AssetDatabase.DeleteAsset(PrefabPath);
            }
        }
예제 #9
0
        void OnCollisionStay(Collision collision)
        {
            Molecule otherMolecule = collision.gameObject.GetComponent <Molecule> ();

            // Detect if collision is with molecule
            if (otherMolecule != null)
            {
                CUE cue = CUE.GetInstance();

                // let the reaction manager handle the collision
                cue.ReactionManager.Collision(this, otherMolecule);
            }
        }
예제 #10
0
파일: CUE.cs 프로젝트: hartaranus/CellUnity
        /// <summary>
        /// Gets the environment instance. If not available, it is loaded from
        /// "Assets/Resources/CUE.asset". If the asset not exists, it is created.
        /// </summary>
        /// <returns>The instance.</returns>
        public static CUE GetInstance()
        {
            if (instance == null)
            {
                Debug.Log("try load CUE...");

                Object asset = Resources.Load("CUE");
                Debug.Log("loaded: " + (asset == null ? "null" : asset.ToString()));
                CUE loadedCue = asset as CUE;
                if (loadedCue == null)
                {
                    Debug.Log("creating new CUE...");
                    CUE cue = ScriptableObject.CreateInstance <CUE>();
                    UnityEditor.AssetDatabase.CreateAsset(cue, "Assets/Resources/CUE.asset");
                    //UnityEditor.AssetDatabase.AddObjectToAsset(cue, "Assets/Resources/CUE.asset");
                    UnityEditor.AssetDatabase.SaveAssets();
                }
            }

            return(instance);
        }