Пример #1
0
        private void Load()
        {
            if (!mHasFinished)
            {
                IsLoading = true;
                if (mThreaded)
                {
#if XBOX360
                    Thread.CurrentThread.SetProcessorAffinity(5);
#endif
                }

                MethodInfo servicesLoadMethod = null;
                object[]   args = null;
                object     loadedObject;

                if (!string.IsNullOrEmpty(mContentManagerName))
                {
#if !XBOX360
                    servicesLoadMethod = typeof(FlatRedBallServices).GetMethod("Load", new Type[2] {
                        typeof(String), typeof(String)
                    });
#endif

                    args    = new object[2];
                    args[1] = mContentManagerName;
                }

                else
                {
#if !XBOX360
                    servicesLoadMethod = typeof(FlatRedBallServices).GetMethod("Load", new Type[1] {
                        typeof(String)
                    });
#endif
                    args = new object[1];
                }

#if !XBOX360
                foreach (KeyValuePair <string, Type> pair in mBatchContents)
                {
                    args[0]      = pair.Key;
                    loadedObject = servicesLoadMethod.MakeGenericMethod(pair.Value).Invoke(null, args);

                    if (pair.Value == typeof(FlatRedBall.Scene) || pair.Value == typeof(EmitterList))
                    {
                        mCloneables.Add(pair.Key + pair.Value.Name, loadedObject);
                    }
                }
#else
                foreach (KeyValuePair <string, Type> pair in mBatchContents)
                {
                    args[0]      = pair.Key;
                    loadedObject = null;

                    if (pair.Value == typeof(FlatRedBall.Scene))
                    {
                        loadedObject = FlatRedBallServices.Load <FlatRedBall.Scene>((string)args[0], (string)args[1]);
                    }

                    else if (pair.Value == typeof(EmitterList))
                    {
                        loadedObject = FlatRedBallServices.Load <EmitterList>((string)args[0], (string)args[1]);
                    }

                    else if (pair.Value == typeof(Microsoft.Xna.Framework.Graphics.Texture2D))
                    {
                        loadedObject = FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>((string)args[0], (string)args[1]);
                    }

/*
 *                  else if (pair.Value == typeof(System.Drawing.Image))
 *                  {
 *                      loadedObject = FlatRedBallServices.Load<System.Drawing.Image>((string)args[0], (string)args[1]);
 *                  }
 *
 *                  else if (pair.Value == typeof(FlatRedBall.Graphics.Texture.BitmapList))
 *                  {
 *                      loadedObject = FlatRedBallServices.Load<FlatRedBall.Graphics.Texture.BitmapList>((string)args[0], (string)args[1]);
 *                  }
 */
                    else if (pair.Value == typeof(Microsoft.Xna.Framework.Graphics.Effect))
                    {
                        loadedObject = FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Effect>((string)args[0], (string)args[1]);
                    }

                    else if (pair.Value == typeof(FlatRedBall.AI.Pathfinding.NodeNetwork))
                    {
                        loadedObject = FlatRedBallServices.Load <FlatRedBall.AI.Pathfinding.NodeNetwork>((string)args[0], (string)args[1]);
                    }

                    else if (pair.Value == typeof(FlatRedBall.Math.Geometry.ShapeCollection))
                    {
                        loadedObject = FlatRedBallServices.Load <FlatRedBall.Math.Geometry.ShapeCollection>((string)args[0], (string)args[1]);
                    }

                    else if (pair.Value == typeof(FlatRedBall.Math.PositionedObjectList <FlatRedBall.Math.Geometry.Polygon>))
                    {
                        loadedObject = FlatRedBallServices.Load <FlatRedBall.Math.PositionedObjectList <FlatRedBall.Math.Geometry.Polygon> >((string)args[0], (string)args[1]);
                    }

                    else if (pair.Value == typeof(FlatRedBall.Graphics.Animation.AnimationChainList))
                    {
                        loadedObject = FlatRedBallServices.Load <FlatRedBall.Graphics.Animation.AnimationChainList>((string)args[0], (string)args[1]);
                    }

                    else if (pair.Value == typeof(FlatRedBall.Gui.GuiSkin))
                    {
                        loadedObject = FlatRedBallServices.Load <FlatRedBall.Gui.GuiSkin>((string)args[0], (string)args[1]);
                    }

                    else if (pair.Value == typeof(FlatRedBall.IO.Csv.RuntimeCsvRepresentation))
                    {
                        loadedObject = FlatRedBallServices.Load <FlatRedBall.IO.Csv.RuntimeCsvRepresentation>((string)args[0], (string)args[1]);
                    }

                    if (pair.Value == typeof(FlatRedBall.Scene) || pair.Value == typeof(EmitterList))
                    {
                        mCloneables.Add(pair.Key + pair.Value.Name, loadedObject);
                    }
                }
#endif


                mDictionary  = FlatRedBallServices.GetDisposableDictionary(mContentManagerName);
                mHasFinished = true;
                IsLoading    = false;
                if (mThreaded)
                {
                    mOnFinish();
                    //  mLoadThread.Abort();
                }
            }
        }