Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkeletonBody"/> class.
        /// </summary>
        /// <param name="bodyInfo"><see cref="SkeletonBodyInfo"/> to create the <see cref="SkeletonBody"/> from.</param>
        /// <exception cref="ArgumentNullException"><paramref name="bodyInfo" /> is <c>null</c>.</exception>
        public SkeletonBody(SkeletonBodyInfo bodyInfo)
        {
            if (bodyInfo == null)
                throw new ArgumentNullException("bodyInfo");

            // Store the BodyInfo object reference
            _bodyInfo = bodyInfo;

            // Create the BodyItems array
            BodyItems = new SkeletonBodyItem[bodyInfo.Items.Length];

            // Create the individual BodyItems
            for (var i = 0; i < BodyItems.Length; i++)
            {
                BodyItems[i] = new SkeletonBodyItem(bodyInfo.Items[i]);
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkeletonBody"/> class.
        /// </summary>
        /// <param name="bodyInfo"><see cref="SkeletonBodyInfo"/> to create the <see cref="SkeletonBody"/> from.</param>
        /// <exception cref="ArgumentNullException"><paramref name="bodyInfo" /> is <c>null</c>.</exception>
        public SkeletonBody(SkeletonBodyInfo bodyInfo)
        {
            if (bodyInfo == null)
            {
                throw new ArgumentNullException("bodyInfo");
            }

            // Store the BodyInfo object reference
            _bodyInfo = bodyInfo;

            // Create the BodyItems array
            BodyItems = new SkeletonBodyItem[bodyInfo.Items.Length];

            // Create the individual BodyItems
            for (var i = 0; i < BodyItems.Length; i++)
            {
                BodyItems[i] = new SkeletonBodyItem(bodyInfo.Items[i]);
            }
        }
Пример #3
0
        /// <summary>
        /// Loads a SkeletonBodyInfo from the given FilePath. Assumes the loading is from the ContentPaths.Dev.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <returns>The loaded SkeletonBodyInfo, or null if the SkeletonBodyInfo failed to load.</returns>
        public static SkeletonBodyInfo LoadSkeletonBodyInfo(string filePath)
        {
            var bodyName = Path.GetFileNameWithoutExtension(filePath);
            var realFilePath = SkeletonBodyInfo.GetFilePath(bodyName, ContentPaths.Dev);

            // Make sure the file exists
            if (!File.Exists(realFilePath))
            {
                const string errmsg = "Failed to load SkeletonBodyInfo `{0}` from `{1}` - file does not exist.";
                var err = string.Format(errmsg, bodyName, filePath);
                MessageBox.Show(err);
                return null;
            }

            // Try to load the skeleton
            SkeletonBodyInfo ret;
            try
            {
                ret = new SkeletonBodyInfo(bodyName, ContentPaths.Dev);
            }
            catch (Exception ex)
            {
                const string errmsg = "Failed to load SkeletonBodyInfo `{0}` from `{1}`:{2}{3})";
                var err = string.Format(errmsg, bodyName, filePath, Environment.NewLine, ex);
                MessageBox.Show(err);
                return null;
            }

            return ret;
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkeletonBody"/> class.
 /// </summary>
 /// <param name="bodyInfo"><see cref="SkeletonBodyInfo"/> to create the <see cref="SkeletonBody"/> from.</param>
 /// <param name="skeleton"><see cref="Skeleton"/> to attach to.</param>
 public SkeletonBody(SkeletonBodyInfo bodyInfo, Skeleton skeleton) : this(bodyInfo)
 {
     Attach(skeleton);
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkeletonBody"/> class.
 /// </summary>
 /// <param name="bodyInfo"><see cref="SkeletonBodyInfo"/> to create the <see cref="SkeletonBody"/> from.</param>
 /// <param name="skeleton"><see cref="Skeleton"/> to attach to.</param>
 public SkeletonBody(SkeletonBodyInfo bodyInfo, Skeleton skeleton) : this(bodyInfo)
 {
     Attach(skeleton);
 }