Пример #1
0
    /**
     * Checks to see if the current muscle is valid (attached to two joints) and if so
     * adds it to the list of muscles.
     */
    private void PlaceCurrentMuscle()
    {
        if (currentMuscle == null)
        {
            return;
        }

        if (currentMuscle.endingJoint == null || GetHoveringObject <Bone>(bones) == null)
        {
            // The connection has no connected ending -> Destroy
            Destroy(currentMuscle.gameObject);
        }
        else
        {
            // Validate the muscle doesn't exist already
            foreach (Muscle muscle in muscles)
            {
                if (muscle.Equals(currentMuscle))
                {
                    Destroy(currentMuscle.gameObject);
                    currentMuscle = null;
                    return;
                }
            }

            currentMuscle.ConnectToJoints();
            currentMuscle.AddCollider();
            muscles.Add(currentMuscle);

            ResetCurrentCreatureName();             // The creature was modified
        }

        currentMuscle = null;
    }
Пример #2
0
        /// <summary>
        /// Checks to see if the current muscle is valid (attached to two joints) and if so
        /// adds it to the list of muscles.
        /// </summary>
        /// <returns>Returns whether the current muscle was placed</returns>
        public bool PlaceCurrentMuscle()
        {
            if (currentMuscle == null)
            {
                return(false);
            }

            if (currentMuscle.endingBone == null)
            {
                // The connection has no connected ending -> Destroy
                UnityEngine.Object.Destroy(currentMuscle.gameObject);
                currentMuscle = null;
                return(false);
            }
            else
            {
                // Validate the muscle doesn't exist already
                foreach (Muscle muscle in muscles)
                {
                    if (muscle.Equals(currentMuscle))
                    {
                        UnityEngine.Object.Destroy(currentMuscle.gameObject);
                        currentMuscle = null;
                        return(false);
                    }
                }

                currentMuscle.ConnectToJoints();
                currentMuscle.AddCollider();
                muscles.Add(currentMuscle);
                currentMuscle = null;
                // The creature was modified
                return(true);
            }
        }