Ejemplo n.º 1
0
 internal void RegisterItems()
 {
     for (int i = 0; i < _itemsToRegister.Count; i++)
     {
         SceneItem item = _itemsToRegister[i];
         AddToSceneItems(item);
         item.OnRegister();
         _itemsToRegister.RemoveAt(i);
         i--;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Registers a sceneitem in the scene immediately.
        /// </summary>
        /// <param name="sceneItem"></param>
        public void RegisterSceneItemNow(SceneItem sceneItem)
        {
            if (sceneItem.Name.Equals(string.Empty))
            {
                throw new ArgumentException("Scene item must have a name set");
            }
            sceneItem.IsTemplate  = false;
            sceneItem.SceneParent = this;

            AddToSceneItems(sceneItem);
            sceneItem.OnRegister();
        }
Ejemplo n.º 3
0
        private static void InitializeScene(IceScene _scene)
        {
            _scene.InitializeContent(Game.Instance.Services);
            _scene.ContentManager.RootDirectory = GlobalDataHolder.ContentFolderPath;

            // 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();
                }
            }
        }