Exemplo n.º 1
0
        public TestGame()
        {
            TestScene scene = new TestScene();
            SetScene(scene);

            LoadScene();
        }
Exemplo n.º 2
0
        public void LoadLevel()
        {
            Stopwatch w = new Stopwatch();
            w.Start();

            var resources = new List<Resource>();
            var bufferCache = new Dictionary<string, int[]>();

            if (Scene != null)
            {
              	resources = Scene.Resources.ToList();
                bufferCache = Scene.MeshBufferCache;

                Scene.Dispose(false);

            }

            _endingGame = false;

            var scene = new TestScene();
            scene.OnTick += scene_OnTick;

            SetScene(scene);

            using (var textStreamReader = new StreamReader(this.GetType().Assembly.GetManifestResourceStream(string.Format("iGL.TestGame.Resources.level1_{0}.igl", _level))))
            {
                var sceneData = textStreamReader.ReadToEnd();
                _currentSceneXML = sceneData;

                PopulateScene(sceneData, resources, bufferCache);

                TotalStarCount = Scene.GameObjects.Where(g => g is Star).Count();
                StarsCollected = 0;

            }

            _slingShotBall = scene.GameObjects.First(g => g is SlingshotBallFarseer2D) as SlingshotBallFarseer2D;

               /* while (true)
            {
                var flare = new StarFlare();

                Scene.AddGameObject(flare);

                flare.PlayAnimation();

                Scene.DisposeGameObject(flare);

                //Scene.AddTimer(new Timer() { Action = () => Scene.DisposeGameObject(flare), Interval = TimeSpan.FromSeconds(0.2), Mode = Timer.TimerMode.Once });
                //Scene.Tick(0.01f);
            }*/

            w.Stop();
            Debug.WriteLine("Loadlevel:" + w.Elapsed.TotalMilliseconds);
        }