Example #1
0
 public static void UnLoadScene(SquidScene oldScene)
 {
     if (!_scenesToUnload.Contains(oldScene))
     {
         _scenesToUnload.Add(oldScene);
     }
 }
Example #2
0
        /// <summary>
        /// Loads the given filename into a scene and returns it.
        /// </summary>
        /// <param name="filename">The filename of the scene</param>
        /// <param name="loadMaterials">Should load materials</param>
        /// <remarks>If false is passed to load materials they are not loaded from the content manager into the texture object. This is for the editor</remarks>
        public static SquidScene LoadScene(string filename, bool loadMaterials)
        {
            if (!filename.EndsWith(".squidscene"))
            {
                filename += ".squidscene";
            }

            string _filename = Path.GetFullPath(filename);

            if (!File.Exists(_filename))
            {
                throw new FileNotFoundException("File Not Found: " + filename);
            }
            SquidScene scene = Serialization.SceneSerializer.DeSerializeScene(filename, "");

            scene.WillRenderNotActive = false;
            Scenes.Add(scene);
            if (_activeScene == null)
            {
                _activeScene = scene;
            }

            if (loadMaterials == true)
            {
                InitializeScene(scene);
            }
            scene.Enabled             = true;
            scene.WillRenderNotActive = true;

            return(scene);
        }
Example #3
0
        protected override void Draw(GameTime gameTime)
        {
            _elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (DrawingManager.IgnoreClearBeforeRendering == false)
            {
                this.GraphicsDevice.Clear(this.DefaultClearColor);
            }

            if (SceneManager.ActiveScene != null)
            {
                if (SceneManager.Scenes.Count > 1)
                {
                    for (int i = 0; i < SceneManager.Scenes.Count; i++)
                    {
                        SquidScene item = SceneManager.Scenes[i];

                        if (item != SceneManager.ActiveScene && item.WillRenderNotActive)
                        {
                            SquidCore.DrawSquidEngineScene(graphics.GraphicsDevice, _elapsed, item);
                        }
                    }
                }
                if (SceneManager.ActiveScene._hasBeenUpdatedOnce == true)
                {
                    SquidCore.DrawSquidEngineScene(graphics.GraphicsDevice, _elapsed, SceneManager.ActiveScene);
                }
                SquidCore.RenderSquidEngine();
            }

            //for (int y = 0; y < SceneManager.ActiveScene._spatialGrid.Rows; y++)
            //{
            //    for (int x = 0; x < SceneManager.ActiveScene._spatialGrid.Cols; x++)
            //    {
            //        Drawing.DebugShapes.DrawLine(
            //            new Vector2(x * SceneManager.ActiveScene._spatialGrid.CellSize,
            //                        0),
            //            new Vector2(x * SceneManager.ActiveScene._spatialGrid.CellSize,
            //                        SceneManager.ActiveScene._spatialGrid.SceneHeight),
            //            Color.White);

            //    }
            //    Drawing.DebugShapes.DrawLine(
            //            new Vector2(0,
            //                y * SceneManager.ActiveScene._spatialGrid.CellSize),
            //            new Vector2(SceneManager.ActiveScene._spatialGrid.SceneWidth,
            //                y * SceneManager.ActiveScene._spatialGrid.CellSize),
            //            Color.White);
            //}



            base.Draw(gameTime);
        }
Example #4
0
        private static void InitializeScene(SquidScene _scene)
        {
            _scene.InitializeContent(Game.Instance.Services);
            // Create a default full sized camera
            Camera camera = new Camera();

            camera.Position = Vector2.Zero;
            camera.Update(1 / 60f);
            _scene.ActiveCameras.Add(camera);

            // Load Materials
            foreach (Material _material in _scene.Materials)
            {
                _material.Texture = _scene._content.Load <Texture2D>(_material.Filename.Substring(0, _material.Filename.Length - 4));
                _material.Scope   = AssetScope.Local;
            }
            // Load Fonts
            foreach (SquidFont _font in _scene.Fonts)
            {
                _font.Font = _scene._content.Load <SpriteFont>(_font.Filename.Replace(".spritefont", ""));
            }
                        #if !XNATOUCH
            foreach (SquidEffect _effect in _scene.Effects)
            {
                if (_effect.Effects != null)
                {
                    continue;
                }
                // removing ".fx" from the name
                string name = _effect.Filename.Substring(0, _effect.Filename.Length - 3);
                _effect.Load(GlobalDataHolder.ContentManager, new string[] { name });
            }
#endif
            //Load Scene Components
            foreach (SquidSceneComponent _comp in _scene.SceneComponents)
            {
                _comp.SetOwner(_scene);
                _comp.OnRegister();
            }
            //Register Scene Items
            for (int i = 0; i < _scene.SceneItems.Count; i++)
            {
                SceneItem item = _scene.SceneItems[i];
                item.SceneParent = _scene;
                if (item.IsRegistered == false)
                {
                    item.OnRegister();
                }
            }
        }
Example #5
0
        public static SquidScene AddBlankScene()
        {
            SquidScene _newScene = new SquidScene();
            Camera     _camera   = new Camera();

            _newScene.ActiveCameras.Add(_camera);

            Scenes.Add(_newScene);
            _newScene._content = new ContentManager(Game.Instance.Services);
            if (_activeScene == null)
            {
                _activeScene = _newScene;
            }
            return(_newScene);
        }
Example #6
0
 /// <summary>
 /// Queues Up The Drawable Items to Draw to the screen
 /// </summary>
 /// <param name="device">The GraphicsDevice to use</param>
 /// <param name="elapsed">The elapsed gametime since the last draw</param>
 /// <param name="scene">The SquidScene to draw</param>
 public static void DrawSquidEngineScene(GraphicsDevice device, float elapsed, SquidScene scene)
 {
     SquidProfiler.StartProfiling(SquidProfilerNames.ICE_CORE_DRAW);
     foreach (SceneItem _item in scene.SceneItems)
     {
         if (_item.IsTemplate == true)
         {
             continue;
         }
         _item.Draw(elapsed);
     }
     SquidProfiler.StopProfiling(SquidProfilerNames.ICE_CORE_DRAW);
 }