Ejemplo n.º 1
0
        protected override void Initialize()
        {
            IsMouseVisible = true;

            // Initialize the lighting system
            penumbra.Initialize();
            penumbra.AmbientColor = new Color(new Vector3(0.7f));
            //penumbra.Debug = true;

            // Our world for the physics body
            world = new World(Vector2.Zero);

            // Initialize the physics debug view
            PhysicsDebugView = new DebugViewXNA(world);
            PhysicsDebugView.LoadContent(GraphicsDevice, Content);
            PhysicsDebugView.RemoveFlags(DebugViewFlags.Controllers);
            PhysicsDebugView.RemoveFlags(DebugViewFlags.Joint);
            PhysicsDebugView.RemoveFlags(DebugViewFlags.Shape);
            PhysicsDebugView.DefaultShapeColor = new Color(255, 255, 0);

            graphics.PreferredBackBufferWidth  = 1280;
            graphics.PreferredBackBufferHeight = 720;

            graphics.SynchronizeWithVerticalRetrace = true;
            IsFixedTimeStep = false;
            base.Initialize();
        }
        public override void LoadContent()
        {
            base.LoadContent();

            //We enable diagnostics to show get values for our performance counters.
            Settings.EnableDiagnostics = true;

            if (World == null)
            {
                World = new World(Vector2.Zero);
            }
            else
            {
                World.Clear();
            }

            if (DebugView == null)
            {
                DebugView = new DebugViewXNA(World);
                DebugView.RemoveFlags(DebugViewFlags.Shape);
                DebugView.RemoveFlags(DebugViewFlags.Joint);
                DebugView.DefaultShapeColor = Color.White;
                DebugView.SleepingShapeColor = Color.LightGray;
                DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content);
            }

            if (Camera == null)
            {
                Camera = new Camera2D(ScreenManager.GraphicsDevice);
            }
            else
            {
                Camera.ResetCamera();
            }

            if (PauseMenu == null)
            {
                PauseMenu = new PauseScreen(this);
            }

            // Loading may take a while... so prevent the game from "catching up" once we finished loading
            ScreenManager.Game.ResetElapsedTime();
        }
Ejemplo n.º 3
0
        public EggGameScreen(Game1 game)
            : base(game, game.Camera.Clone())
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);

            _eggtastic = game;

            Clips = new Dictionary<string, Clip>();
            Enemies = new List<EnemyEntity>();
            Eggs = new List<EggEntity>();
            QueuedForDisposal = new List<CharacterEntity>();
            QueuedForCreation = new List<CharacterEntity>();

            ScreenSizeDefault = new Vector2(1280, 720);

            GraphicsDevice = game.GraphicsDevice;
            Viewport = GraphicsDevice.Viewport;
            ScreenCenter = new Vector2(ScreenSizeDefault.X / 2f, ScreenSizeDefault.Y / 2f);
            Content = game.Content;

            gameFont = Content.Load<SpriteFont>("GameFont");

            #if !ANDROID
            BackgroundMusic =
                Content.Load<Song>("background-music");
            MediaPlayer.Play(BackgroundMusic);
            MediaPlayer.Volume = 0.5f;
            #endif

            Corners = new Vertices(4);
            Corners.Add(new Vector2(0f));                                           // top-left
            Corners.Add(new Vector2(ScreenSizeDefault.X, 0f));                     // top-right
            Corners.Add(new Vector2(ScreenSizeDefault.X, ScreenSizeDefault.Y));   // bottom-right
            Corners.Add(new Vector2(0f, ScreenSizeDefault.Y));                     // bottom-left

            projection =
                Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(ScreenSizeDefault.X),
                                                   ConvertUnits.ToSimUnits(ScreenSizeDefault.Y), 0f, 0f, 1f);

            World = new World(new Vector2(0, 0));
            DebugView = new DebugViewXNA(World);
            DebugView.RemoveFlags(DebugViewFlags.Shape);
            DebugView.DefaultShapeColor = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;
            DebugView.LoadContent(GraphicsDevice, Content);

            if (Tweak.SHOW_PHYSICS_ON_START)
                EnableOrDisableFlag(DebugViewFlags.Shape);
            Tweak.Init();

            InitialiseClips();

            _enemySpawner = new EnemySpawner(this, Clips["enemy"]);

            // World is 1 screen high, N screens wide
            _border = new Border(World, new Vector2(ScreenSizeDefault.X * PLAY_AREA_WIDTH_IN_SCREENS, ScreenSizeDefault.Y));

            InitialiseLevel();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _world = new World(new Vector2(0,0));

            _debugView = new DebugViewXNA(_world);

               // default is shape, controller, joints
               // we just want shapes to display
               _debugView.RemoveFlags(DebugViewFlags.Controllers);
               _debugView.RemoveFlags(DebugViewFlags.Joint);

               _debugView.LoadContent(GraphicsDevice, Content);

               //_debugView.LoadContent(GraphicsDevice, Content);

             // Create and position our floor
               _floor = BodyFactory.CreateRectangle(
            _world,
            ConvertUnits.ToSimUnits(480),
            ConvertUnits.ToSimUnits(50),
            10f);
            _floor.Position = ConvertUnits.ToSimUnits(300,400);
            _floor.IsStatic = true;
            _floor.Restitution = 0.2f;
            _floor.Friction = 0.2f;

                          box = BodyFactory.CreateRectangle(
               _world,
               ConvertUnits.ToSimUnits(100),
               ConvertUnits.ToSimUnits(100),
               10f,
               new Vector2(ConvertUnits.ToSimUnits(300), ConvertUnits.ToSimUnits(0)));

               box.BodyType = BodyType.Dynamic;
               box.Restitution = 0.2f;
               box.Friction = 0.2f;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // for debug view
            DebugView = new DebugViewXNA(physicsSystem.world);
            DebugView.DefaultShapeColor = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;
            DebugView.AppendFlags(DebugViewFlags.ContactPoints);
            DebugView.AppendFlags(DebugViewFlags.DebugPanel);
            DebugView.RemoveFlags(DebugViewFlags.Joint);
            DebugView.LoadContent(GraphicsDevice, Content);

            // for splitscreen
            SetUpSplitScreen();

            entityManager = new EntityManager();
            representationManager = new RepresentationManager(Content);
            controllerManager = new ControllerManager();

            LevelMap levelMap = Content.Load<LevelMap>("simplelevelmap");
            map = new Map(physicsSystem.world, levelMap, entityManager, representationManager, controllerManager);
            mapRepresentation = new MapRepresentation(map);
            mapRepresentation.LoadContent(Content);
            representationManager.Add(mapRepresentation);

            GameVariables.LevelHeight = map.LevelMap.Height;
            GameVariables.EnemyRespawnDelay = 10f;
            GameVariables.CamCulling = new Vector2(640 * 0.5f, 360 * 0.5f);

            // create the players
            int numPlayers = GameVariables.NumPlayers;
            CreatePlayer((int)PlayerIndex.One);
            if (numPlayers > 1)
            {
                CreatePlayer((int)PlayerIndex.Two);
            }
            if (numPlayers > 2)
            {
                CreatePlayer((int)PlayerIndex.Three);
            }
            if (numPlayers > 3)
            {
                CreatePlayer((int)PlayerIndex.Four);
            }

            map.SetUpTiles();

            // test for a slanted platform
            /*
            Vector2 position = new Vector2(180, 270);
            Vertices vertices = new Vertices();
            vertices.Add(ConvertUnits.ToSimUnits(new Vector2(290, 480)));
            vertices.Add(ConvertUnits.ToSimUnits(new Vector2(578, 384)));
            vertices.Add(ConvertUnits.ToSimUnits(new Vector2(578, 480)));
            Body body = BodyFactory.CreatePolygon(physicsSystem.world, vertices, 1f);
            body.BodyType = BodyType.Static;
            body.Restitution = 0f;
            body.Friction = 0.5f;
            body.CollisionCategories = GameConstants.PlatformCollisionCategory;
             */

            // test for a thin platform
            //Vector2 position = new Vector2(300, 400);
            /*
            Body body = BodyFactory.CreateEdge(physicsSystem.world, ConvertUnits.ToSimUnits(new Vector2(300, 400)), ConvertUnits.ToSimUnits(new Vector2(500, 400)));
            //StaticPhysicsObject physicsObject = new StaticPhysicsObject(this, physicsSystem.world, position, 64, 1);
            //Body body = physicsObject.body;
            body.BodyType = BodyType.Static;
            body.Restitution = 0f;
            body.Friction = 0.5f;
            body.CollisionCategories = GameConstants.PlatformCollisionCategory;
             */
            //oneWayTile = new OneWayGroundTile(physicsSystem.world, position, 64);
            /*
            Vector2 startPosition = new Vector2(268, 400);
            Vector2 endPosition = new Vector2(332, 400);
            Body body = BodyFactory.CreateEdge(physicsSystem.world, ConvertUnits.ToSimUnits(startPosition), ConvertUnits.ToSimUnits(endPosition));
            body.BodyType = BodyType.Static;
            body.Restitution = 0f;
            body.Friction = 0.5f;
             */

            // set player spawn positions from map
            List<Player> players = entityManager.Players;
            foreach (Player player in players)
            {
                player.SpawnPosition = map.PlayerSpawn;
            }

            // spawn the living entities
            entityManager.SpawnLivingEntities();

            tmpTex = Content.Load<Texture2D>("blank");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            _debugView = new DebugViewXNA(_world);
            _debugView.LoadContent(GraphicsDevice, Content);
            _debugView.RemoveFlags(DebugViewFlags.Controllers);
               _debugView.RemoveFlags(DebugViewFlags.Joint);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            _fpscounter = new FPScounter(this);
            Mouse.SetPosition(400, 400);
            _cursor = new Cursor(this);

            _introsong = Content.Load<Song>(".\\Audio\\INTRO");

            //--------------------------------------
            //Game STarts here!!!
            //--------------------------------------

            if (Globals.SkipIntro)
            {
               StartPlayingLevel();
            }
            else
            {
                StartTheGame();
            }
        }
Ejemplo n.º 7
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // Show the physics shape or hide it
            if (Keyboard.GetState().IsKeyDown(Keys.F2) && oldKeys.IsKeyUp(Keys.F2))
            {
                showshapes = !showshapes;

                if (showshapes == true)
                {
                    PhysicsDebugView.AppendFlags(DebugViewFlags.Shape);
                }
                else
                {
                    PhysicsDebugView.RemoveFlags(DebugViewFlags.Shape);
                }
            }

            // Animate light position
            _light.Position =
                new Vector2(400f, 240f) + // Offset origin
                new Vector2(              // Position around origin
                    (float)Math.Cos(gameTime.TotalGameTime.TotalSeconds),
                    (float)Math.Sin(gameTime.TotalGameTime.TotalSeconds)) * 240f;

            // The rotation and the position of all Hulls will be updated
            // according to the physics body rotation and position
            foreach (Hull h in tBodyHull)
            {
                h.Rotation = tBody.Rotation;
                h.Position = ConvertUnits.ToDisplayUnits(tBody.Position);
            }

            // Get the mouse position
            Vector2 position = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);

            // If left mouse button clicked then create a fixture for physics manipulation
            if (Mouse.GetState().LeftButton == ButtonState.Pressed && _fixedMouseJoint == null)
            {
                Fixture savedFixture = world.TestPoint(ConvertUnits.ToSimUnits(position));
                if (savedFixture != null)
                {
                    Body body = savedFixture.Body;
                    _fixedMouseJoint          = new FixedMouseJoint(body, ConvertUnits.ToSimUnits(position));
                    _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                    world.AddJoint(_fixedMouseJoint);
                    body.Awake = true;
                }
            }
            // If left mouse button releases then remove the fixture from the world
            if (Mouse.GetState().LeftButton == ButtonState.Released && _fixedMouseJoint != null)
            {
                world.RemoveJoint(_fixedMouseJoint);
                _fixedMouseJoint = null;
            }
            if (_fixedMouseJoint != null)
            {
                _fixedMouseJoint.WorldAnchorB = ConvertUnits.ToSimUnits(position);
            }

            // We update the world
            world.Step((float)gameTime.ElapsedGameTime.TotalMilliseconds * 0.001f);

            // Update the keypress
            oldKeys = Keyboard.GetState();
            base.Update(gameTime);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Create New World with gravity of 10 units, downward.
            MyWorld = new World(Vector2.UnitY * 10);
            bird = Content.Load<Texture2D>("AngryRedBird");
            floor = Content.Load<Texture2D>("blank");

            //camera

            DebugView = new DebugViewXNA(MyWorld);
            DebugView.AppendFlags(DebugViewFlags.Shape);
            DebugView.RemoveFlags(DebugViewFlags.Joint);
            DebugView.DefaultShapeColor = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;
            DebugView.LoadContent(GraphicsDevice, Content);
            Camera = new Camera2D(GraphicsDevice);

            //Create Floor
            FloorBody = BodyFactory.CreateBody(MyWorld);
            Fixture floorFixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(480), ConvertUnits.ToSimUnits(10), 10, Vector2.Zero, FloorBody);
            floorFixture.Restitution = 0.5f;        //Bounceability
            floorFixture.Friction = 0.5f;           //Friction
            FloorBody = floorFixture.Body;          //Get Body from Fixture
            FloorBody.IsStatic = true;              //Floor must be stationary object

            //Create Box, (Note:Different way from above code, just to show it otherwise there is no difference)
            HeroBird = BodyFactory.CreateBody(MyWorld);
            FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(50), ConvertUnits.ToSimUnits(50), 10, Vector2.Zero, HeroBird);
            foreach (Fixture fixture in HeroBird.FixtureList)
            {
                fixture.Restitution = 0.5f;
                fixture.Friction = 0.5f;
            }
            HeroBird.BodyType = BodyType.Dynamic;

            //Place floor object to bottom of the screen.
            FloorBody.Position = ConvertUnits.ToSimUnits(new Vector2(240, 700));

            //Place Box on screen, somewhere
            HeroBird.Position = ConvertUnits.ToSimUnits(new Vector2(240, 25));
        }
Ejemplo n.º 9
0
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                base.Activate(instancePreserved);

                //We enable diagnostics to show get values for our performance counters.
                FarseerPhysics.Settings.EnableDiagnostics = true;

                if (World == null)
                {
                    World = new World(Vector2.Zero);
                }
                else
                {
                    World.Clear();
                }

                if (DebugView == null)
                {
                    if (!Axios.Settings.ScreenSaver)
                    {
                        ContentManager man = new ContentManager(this.ScreenManager.Game.Services, "Content");
                        DebugView = new DebugViewXNA(World);
                        DebugView.RemoveFlags(DebugViewFlags.Shape);
                        DebugView.RemoveFlags(DebugViewFlags.Joint);
                        DebugView.DefaultShapeColor = Color.White;
                        DebugView.SleepingShapeColor = Color.LightGray;
                        DebugView.LoadContent(ScreenManager.GraphicsDevice, man);
                    }
                }

                if (Camera == null)
                {
                    Camera = new Camera2D(ScreenManager.GraphicsDevice);
                }
                else
                {
                    Camera.ResetCamera();
                }

                // Loading may take a while... so prevent the game from "catching up" once we finished loading
                ScreenManager.Game.ResetElapsedTime();
            }
        }
Ejemplo n.º 10
0
 private void InitDebug()
 {
     _debugView = new DebugViewXNA(World);
     _debugView.RemoveFlags(DebugViewFlags.Shape);
     _debugView.RemoveFlags(DebugViewFlags.Joint);
     _debugView.DefaultShapeColor = Color.White;
     _debugView.SleepingShapeColor = Color.LightGray;
     _debugView.LoadContent(GraphicsDevice, Game1.contentManager);
 }
Ejemplo n.º 11
0
        public virtual void LoadContent(GraphicsDeviceManager dMan, ContentManager cm)
        {
            this.graphics = dMan;
            this.Content = cm;

            // load the map
            mMapLoader.loadMap(Content);

            _font = Content.Load<SpriteFont>("font");
            #if DEBUG
            debugView = new DebugViewXNA(mWorld);
            debugView.AppendFlags(DebugViewFlags.DebugPanel);
            debugView.DefaultShapeColor = Color.White;
            debugView.SleepingShapeColor = Color.LightGray;
            debugView.RemoveFlags(DebugViewFlags.Controllers);
            //debugView.RemoveFlags(DebugViewFlags.Joint);

            debugView.LoadContent(graphics.GraphicsDevice, Content);
            #endif
        }
Ejemplo n.º 12
0
        public void LoadContent(GraphicsDeviceManager graphics, ContentManager Content)
        {
            this.graphics = graphics;
            this.Content = Content;

            // Initialize camera controls
            _view = Matrix.Identity *
                        Matrix.CreateScale(_cameraZoom);
            _cameraPosition = Vector2.Zero;
            _screenCenter = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2f,
                                                graphics.GraphicsDevice.Viewport.Height / 2f);
            _font = Content.Load<SpriteFont>("font");

            // load players
            mPlayer1.loadShip(Content, graphics);

            // load the map
            mMapLoader.loadMap(Content);

            #if DEBUG
            debugView = new DebugViewXNA(mWorld);
            debugView.AppendFlags(DebugViewFlags.DebugPanel);
            debugView.DefaultShapeColor = Color.White;
            debugView.SleepingShapeColor = Color.LightGray;
            debugView.RemoveFlags(DebugViewFlags.Controllers);
            debugView.RemoveFlags(DebugViewFlags.Joint);

            debugView.LoadContent(graphics.GraphicsDevice, Content);
            #endif
        }
Ejemplo n.º 13
0
        public override void LoadContent()
        {
            base.LoadContent();

            string json = System.IO.File.ReadAllText("Levels\\" + mLevelID + ".txt");

            List<object> output = JsonParser.Parse(json);
            Hashtable level = (Hashtable)output[0];

            //Level Name
            mLevelName = (string)level["name"];

            //Gravity
            mGravity = new Vector2((float)((List<object>)level["Gravity"])[0], (float)((List<object>)level["Gravity"])[1]);

            //Starting Positions
            foreach(List<object> pos in (List<object>)level["starting_positions"])
            {
                mStartingPositions.Add(mStartingPositions.Count, new Vector2((float)pos[0], (float)pos[1]));
            }

            //Create the camera
            mCamera = new Camera2D(ScreenManager.GraphicsDevice);

            //Create the world
            mWorld = new World(mGravity);

            //Save starting poition index
            mStartingPositionIndex = 0;

            //Save starting position
            mStartingPosition = mStartingPositions[mStartingPositionIndex];

            //Get the content manager
            mContentManager = new ContentManager(ScreenManager.Game.Services, "Content");

            //Create the player
            mPlayer = new Player(mWorld, this, mContentManager, Color.White, mStartingPosition);
            mCamera.EnableTracking = true;
            mCamera.EnablePositionTracking = true;
            mCamera.TrackingBody = mPlayer.CamBody;
            mCamera.Jump2Target();

            //Create a test PC
            mTestPC = new PC(mWorld, this, mContentManager, Color.White, mStartingPosition);

            //Create level objects
            foreach(object dobj in (List<object>)level["Objects"])
            {
                Hashtable dict = (Hashtable)dobj;

                if (dict["Type"].Equals("Body"))
                {
                    Body nBody;

                    Hashtable properties = (Hashtable)dict["Properties"];

                    string SpriteClass = (string)properties["SpriteClass"];

                    if (SpriteClass != "" && SpriteClass != null)
                    {
                        nBody = BodyFactory.CreateBody(mWorld, new Vector2((float)((List<object>)properties["Position"])[0], (float)((List<object>)properties["Position"])[1]));
                    }
                    else
                    {
                        nBody = BodyFactory.CreateBody(mWorld, new Vector2((float)((List<object>)properties["Position"])[0], (float)((List<object>)properties["Position"])[1]));
                    }

                    string nTextureName = (string)properties["SpriteTexture"];
                    MaterialType nMaterialType = (MaterialType)Enum.Parse(typeof(MaterialType), (string)properties["MaterialType"]);
                    Color nColor = (Color)Color.White.GetType().GetProperty((string)properties["Color"]).GetValue(null, null);

                    nBody.Position = new Vector2((float)((List<object>)properties["Position"])[0], (float)((List<object>)properties["Position"])[1]);
                    nBody.Rotation = (float)properties["Rotation"];
                    nBody.BodyType = (BodyType)Enum.Parse(typeof(BodyType), (string)properties["BodyType"]);
                    nBody.IsBullet = (bool)properties["IsBullet"];
                    nBody.IsSensor = (bool)properties["IsSensor"];
                    nBody.IsStatic = (bool)properties["IsStatic"];

                    nBody.Mass = (float)properties["Mass"];

                    nBody.Inertia = (float)properties["Inertia"];
                    nBody.Friction = (float)properties["Friction"];
                    nBody.Restitution = (float)properties["Restitution"];
                    nBody.LinearDamping = (float)properties["LinearDamping"];
                    nBody.AngularDamping = (float)properties["AngularDamping"];
                    nBody.FixedRotation = (bool)properties["FixedRotation"];

                    nBody.Awake = (bool)properties["Awake"];
                    nBody.Enabled = (bool)properties["Enabled"];
                    nBody.IgnoreCCD = (bool)properties["IgnoreCCD"];
                    nBody.IgnoreGravity = (bool)properties["IgnoreGravity"];
                    nBody.SleepingAllowed = (bool)properties["SleepingAllowed"];

                    foreach(object fobj in (List<object>)dict["Fixtures"])
                    {
                        Hashtable fixture = (Hashtable)fobj;

                        if(fixture["Shape"].Equals("Rectangle"))
                        {
                            FixtureFactory.AttachRectangle((float)fixture["Width"], (float)fixture["Height"], (float)fixture["Density"], new Vector2((float)((List<object>)fixture["Offset"])[0], (float)((List<object>)fixture["Offset"])[1]), nBody);
                        }
                        else if(fixture["Shape"].Equals("Circle"))
                        {
                            FixtureFactory.AttachCircle((float)fixture["Radius"], (float)fixture["Density"], nBody, new Vector2((float)((List<object>)fixture["Offset"])[0], (float)((List<object>)fixture["Offset"])[1]));
                        }
                        else if(fixture["Shape"].Equals("Ellipse"))
                        {
                            FixtureFactory.AttachEllipse((float)fixture["xRadius"], (float)fixture["yRadius"], (int)fixture["Edges"], (float)fixture["Density"], nBody);
                        }

                    }

                    AddObject(nBody, nMaterialType, nColor, nTextureName);
                }
                else if (dict["Type"].Equals("Fixture"))
                {
                    Hashtable properties = (Hashtable)dict["Properties"];

                    Body nBody = null;

                    if(properties["Shape"].Equals("Rectangle"))
                    {
                        nBody = BodyFactory.CreateRectangle(mWorld, (float)properties["Width"], (float)properties["Height"], (float)properties["Density"]);
                    }
                    else if(properties["Shape"].Equals("Circle"))
                    {
                        nBody = BodyFactory.CreateCircle(mWorld, (float)properties["Radius"], (float)properties["Density"]);
                    }
                    else if(properties["Shape"].Equals("Ellipse"))
                    {
                        nBody = BodyFactory.CreateEllipse(mWorld, (float)properties["xRadius"], (float)properties["yRadius"], (int)properties["Edges"], (float)properties["Density"]);
                    }

                    string SpriteClass = (string)properties["SpriteClass"];
                    string nTextureName = (string)properties["SpriteTexture"];
                    MaterialType nMaterialType = (MaterialType)Enum.Parse(typeof(MaterialType), (string)properties["MaterialType"]);
                    Color nColor = (Color)Color.White.GetType().GetProperty((string)properties["Color"]).GetValue(null, null);

                    nBody.Position = new Vector2((float)((List<object>)properties["Position"])[0], (float)((List<object>)properties["Position"])[1]);
                    nBody.Rotation = (float)properties["Rotation"];
                    nBody.BodyType = (BodyType)Enum.Parse(typeof(BodyType), (string)properties["BodyType"]);
                    nBody.IsBullet = (bool)properties["IsBullet"];
                    nBody.IsSensor = (bool)properties["IsSensor"];
                    nBody.IsStatic = (bool)properties["IsStatic"];

                    nBody.Mass = (float)properties["Mass"];

                    nBody.Inertia = (float)properties["Inertia"];
                    nBody.Friction = (float)properties["Friction"];
                    nBody.Restitution = (float)properties["Restitution"];
                    nBody.LinearDamping = (float)properties["LinearDamping"];
                    nBody.AngularDamping = (float)properties["AngularDamping"];
                    nBody.FixedRotation = (bool)properties["FixedRotation"];

                    nBody.Awake = (bool)properties["Awake"];
                    nBody.Enabled = (bool)properties["Enabled"];
                    nBody.IgnoreCCD = (bool)properties["IgnoreCCD"];
                    nBody.IgnoreGravity = (bool)properties["IgnoreGravity"];
                    nBody.SleepingAllowed = (bool)properties["SleepingAllowed"];

                    AddObject(nBody, nMaterialType, nColor, nTextureName);
                }
                else if ((dict["Type"].Equals("Custom")))
                {
                    Hashtable properties = (Hashtable)dict["Properties"];
                    BaseSprite nSprite;

                    string SpriteClass = (string)properties["SpriteClass"];
                    Vector2 nPos = new Vector2((float)((List<object>)properties["Position"])[0], (float)((List<object>)properties["Position"])[1]);
                    if (SpriteClass == "LevelPortal")
                    {
                        nSprite = new LevelPortal(mWorld, this, mContentManager, Color.White, nPos, LevelPortalCollision, (Hashtable)properties["Config"]);
                    }
                    else
                    {
                        nSprite = null;
                    }

                    AddSpecial(nSprite);
                }
            }

            //Attach the debug view
            DebugView = new DebugViewXNA(mWorld);
            DebugView.RemoveFlags(DebugViewFlags.Shape);
            DebugView.RemoveFlags(DebugViewFlags.Joint);
            DebugView.DefaultShapeColor = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;
            DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content);

            //Reset time elapsed to account for loading time
            ScreenManager.Game.ResetElapsedTime();
        }