Example #1
0
 public void UseScene(string scene)
 {
     gameObjectContainer.Reset();
     gameObjectsNoRigidBody.Clear();
     Model = new Model(scene);
     Model.Objects.ForEach(AddGameObject);
 }
Example #2
0
            public void Reset()
            {
                gameObjectContainer.Reset();
                gameObjectsNoRigidBody.Clear();
                PlayerLastLocation = Constants.MARIO_DEFAULT_LOCATION;

                AddGameObject(new VirtualPlane(0f, Constants.SCREEN_HEIGHT - 1));
                AddGameObject(new VirtualWall(0f, 0f));
                AddGameObject(new VirtualWall(Constants.SCREEN_WIDTH - Constants.VIRTUAL_WALL_WIDTH, 0f));

                var levelData = new JavaScriptSerializer().Deserialize <LevelData>(ReadAllText(Constants.DATA_FILES_PATH + Constants.LEVEL_DATA_PREFIX + level + Constants.DATA_FILE_TYPE));

                HasPlayer = levelData.HasPlayer;
                if (HasPlayer)
                {
                    AddGameObject(player);
                }
                levelData.Objects.ForEach(o =>
                {
                    AddGameObject(o.ToGameObject());
                });
                levelData.Objects = null;

                var sceneEndBound = 0f;

                gameObjectContainer.ForEachVisible(o => sceneEndBound = sceneEndBound.Max(o.RigidBody.Bound.Right));
                var endWall = new VirtualWall(sceneEndBound - Constants.SCREEN_WIDTH / 2, 0f)
                {
                    IsLocationAbsolute = false
                };

                AddGameObject(endWall);
            }