/// <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 IceScene to draw</param> public static void DrawIceCreamScene(GraphicsDevice device, float elapsed, IceScene scene) { IceProfiler.StartProfiling(IceProfilerNames.ICE_CORE_DRAW); foreach (SceneItem _item in scene.SceneItems) { if (_item.IsTemplate == true) { continue; } _item.Draw(elapsed); } IceProfiler.StopProfiling(IceProfilerNames.ICE_CORE_DRAW); }
public static IceScene AddBlankScene() { IceScene _newScene = new IceScene(); 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; }
public static void UnLoadScene(IceScene oldScene) { oldScene.Unload(); oldScene.ContentManager.Unload(); oldScene.ContentManager.Dispose(); Scenes.Remove(oldScene); if (oldScene == ActiveScene) ActiveScene = null; if (ActiveScene == null && Scenes.Count > 0) //Pick the top scene ActiveScene = Scenes[Scenes.Count - 1]; }
private static void InitializeScene(IceScene _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 (IceFont _font in _scene.Fonts) { _font.Font = _scene._content.Load<SpriteFont>(_font.Filename.Replace(".spritefont", "")); } #if !XNATOUCH foreach (IceEffect _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 (IceSceneComponent _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(); } } }
private void InitializeSceneItems(IceScene scene) { foreach (SceneItem _item in scene.SceneItems) { _item.SceneParent = scene; if (_item is TileGrid) { ((TileGrid)_item).LoadData(false); } //if (_item is AnimatedSprite) // ((AnimatedSprite)_item).AnimationInfo.Setup(); _item.UpdateBoundingRect(); _item.SetupLinkFuses(); } }
/// <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 IceScene LoadScene(string filename, bool loadMaterials) { if (!filename.EndsWith(".icescene")) filename += ".icescene"; string _filename = Path.GetFullPath(filename); if (!File.Exists(_filename)) { throw new FileNotFoundException("File Not Found: " + filename); } IceScene 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; }
public static IceScene DeSerializeScene(String filename, String rootPath) { IceScene scene = new IceScene(); FireStatusUpdate("Loading Scene", 5); DeSerializeScene(filename, rootPath, scene); return scene; }
private static SceneItem LoadCompositeEntity(XmlNode node, SceneBase scene) { TraceLogger.TraceInfo("Beginning LoadCompositeAnimation"); _storedScene = scene as IceScene; CompositeEntity _compositeEntity = new CompositeEntity(); LoadBaseSceneItem(node, _compositeEntity); XmlNode _node = node.SelectSingleNode("CompositeEntityData"); SetProperty("SceneItemBank", _compositeEntity, _node); SetProperty("RootBone", _compositeEntity, _node); SetProperty("Animations", _compositeEntity, _node); SetIAnimationDirectorProperties(_node, _compositeEntity as IAnimationDirector); TraceLogger.TraceInfo("Ending LoadCompositeEntity"); return _compositeEntity; }
private static SceneItem LoadSceneItem(XmlNode node, IceScene scene) { SceneItem _item = null; string _type = node.Name; switch (_type) { case NodeNames.SPRITE: _item = LoadSprite(node, scene); break; case NodeNames.ANIMATEDSPRITE: _item = LoadAnimatedSprite(node, scene); break; case NodeNames.TEXTITEM: _item = LoadTextItem(node, scene); break; case NodeNames.PARTICLEEFFECT: _item = LoadParticleEffect(node, scene); break; case NodeNames.TILEGRID: _item = LoadTileGrid(node, scene); break; case NodeNames.COMPOSITEENTITY: _item = LoadCompositeEntity(node, scene); break; case NodeNames.POSTPROCESSANIMATION: _item = LoadPostProcessAnimation(node, scene); break; case NodeNames.SCENEITEM: _item = new SceneItem(); LoadBaseSceneItem(node, _item); break; default: throw new Exception("Item type \"" + _type + "\" is not supported"); } _item.Name = node.Attributes["name"].InnerText; newid++; _item.id = newid; return _item; }
internal void SetOwner(IceScene owner) { _owner = owner; }