示例#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);
            }
        }