Exemple #1
0
        /// <summary>
        /// Conntects the child mount point to the parent
        /// </summary>
        /// <param name="rParentPoint">Parent mount point</param>
        /// <param name="rChild">GameObject representing the child</param>
        /// <param name="rChildPointName">String representing the child mount point name</param>
        /// <returns>Boolean used to determine if the connection was made</returns>
        public bool ConnectMountPoints(MountPoint rParentPoint, GameObject rChild, string rChildPointName)
        {
            if (rChild == null)
            {
                return(false);
            }
            if (rParentPoint == null)
            {
                return(false);
            }

            MountPoint  lChildMP     = null;
            MountPoints lChildMPList = rChild.GetComponent <MountPoints>();

            if (lChildMPList != null)
            {
                lChildMP = lChildMPList.GetMountPoint(rChildPointName);
            }
            else
            {
                Mount lParentMount = rChild.GetComponent <Mount>();
                if (lParentMount != null)
                {
                    lChildMP = lParentMount.Point;
                }
            }

            // If there is no child, get out
            if (lChildMP == null)
            {
                return(false);
            }

            // Finally, connect the objects
            return(ConnectMountPoints(rParentPoint, lChildMP));
        }