Пример #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="resource">model resource</param>
        public GameModel(GameResourceModel resource)
            : base()
        {
            if (resource == null)
                throw new ArgumentNullException("resource");

            BindModel(resource.ModelData);
        }
Пример #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="resource">model resource</param>
 public GameWorld(GameResourceModel resource)
     : base(resource) {}
Пример #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="resource">model resource</param>         
 public GameAnimateModel(GameResourceModel resource)
     : base(resource) {}
Пример #4
0
        /// <summary>
        /// loads a resource file in the content folder.
        /// </summary>
        /// <typeparam name="T">resource type (i.e. Model or Texture2D)</typeparam>
        /// <param name="key">resource key name</param>
        /// <param name="filePath">resource file name</param>
        /// <returns>resource element</returns>
        public GameResourceBase LoadContent <T>(string key, string filePath)
        {
            if (FrameworkCore.Game.GraphicsDevice == null)
            {
                throw new InvalidOperationException("No graphics device.");
            }

            GameResourceBase resource = FindResourceByKey(key);

            if (resource != null)
            {
                return(resource);
            }

            //  loads a resource by content manager
            T obj = contentManager.Load <T>(filePath);

            if (obj == null)
            {
                throw new ArgumentException("Fail to load content (" + key +
                                            " : " + filePath + ")");
            }

            if (obj is Texture2D)
            {
                resource = new GameResourceTexture2D(key, filePath,
                                                     obj as Texture2D);
            }
            else if (obj is Model)
            {
                resource = new GameResourceModel(key, filePath, obj as Model);
            }
            else if (obj is AnimationSequence)
            {
                resource = new GameResourceAnimation(key, filePath,
                                                     obj as AnimationSequence);
            }
            else if (obj is SpriteFont)
            {
                resource = new GameResourceFont(key, filePath, obj as SpriteFont);
            }
            else if (obj is Effect)
            {
                resource = new GameResourceEffect(key, filePath, obj as Effect);
            }
            else
            {
                throw new NotSupportedException("Not supported the resource");
            }

            if (debugTrace)
            {
                System.Diagnostics.Debug.WriteLine(
                    string.Format("Load Resource : {0} ({1})",
                                  filePath, resource.ToString()));
            }

            if (AddResource(resource))
            {
                return(resource);
            }

            return(null);
        }
Пример #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="resource">model resource</param>
 public GameSkybox(GameResourceModel resource)
     : base(resource) {}