예제 #1
0
        public void Add(SceneBase scene, bool initializeAndLoadContent = false)
        {
            if (initializeAndLoadContent)
            {
                scene.Initialize(context);
                scene.LoadContent();
            }

            Scenes.Add(scene);
        }
예제 #2
0
        public void AddChild(SceneBase parent, SceneBase child, bool initializeAndLoadContent = false)
        {
            child.Parent = parent;

            if (initializeAndLoadContent)
            {
                child.Initialize(context);
                child.LoadContent();
            }

            parent.SceneChildren.Add(child);
        }
예제 #3
0
        private void UpdateTransition(GameTime gameTime)
        {
            var deltaTime = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (_beginTransitionFade)
            {
                if (_transitionImage.Alpha < 1.0f)
                {
                    _transitionImage.Alpha += deltaTime / 200f;
                }
                else
                {
                    _beginTransitionFade = false;
                }
            }
            else
            {
                if (_mapTransition && _mapToLoad != null)
                {
                    var mapId = _mapToLoad ?? MapManager.FirstMap;
                    MapManager.Instance.LoadMap(Content, mapId);
                    if (_mapLoadCallback != null)
                    {
                        _mapLoadCallback(mapId);
                        _mapLoadCallback = null;
                    }
                    _mapToLoad     = null;
                    _mapTransition = false;
                }

                if (!_mapTransition && _newScene != null)
                {
                    _currentScene.UnloadContent();
                    _currentScene = _newScene;
                    _currentScene.LoadContent();
                    _newScene = null;
                }

                if (_transitionImage.Alpha > 0.0f)
                {
                    _transitionImage.Alpha -= deltaTime / 200f;
                }
                else
                {
                    _transitionImage.IsVisible = false;
                    _isTransitioning           = false;
                }
            }
        }
예제 #4
0
        public void LoadContent(ContentManager Content)
        {
            this.Content = new ContentManager(Content.ServiceProvider, "Content");
            var transitionTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

            transitionTexture.SetData(new Color[] { Color.Black });
            _transitionImage           = new Sprite(transitionTexture);
            _transitionImage.Scale     = new Vector2(VirtualSize.X, VirtualSize.Y);
            _transitionImage.Alpha     = 0.0f;
            _transitionImage.IsVisible = false;
            _gameFont    = Content.Load <BitmapFont>("fonts/SneakAttack");
            _gameFontBig = Content.Load <BitmapFont>("fonts/SneakAttackBig");
            SoundManager.Initialize();
            _currentScene.LoadContent();
        }
예제 #5
0
        public void LoadContent(ContentManager Content)
        {
            this.Content = new ContentManager(Content.ServiceProvider, "Content");
            var transitionTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

            transitionTexture.SetData <Color>(new Color[] { Color.Black });
            _transitionImage           = new Sprite(transitionTexture);
            _transitionImage.Scale     = new Vector2(VirtualSize.X, VirtualSize.Y);
            _transitionImage.Alpha     = 0.0f;
            _transitionImage.IsVisible = false;
            _gameFont       = Content.Load <BitmapFont>("fonts/Alagard");
            _gameFontSmall  = Content.Load <BitmapFont>("fonts/AlagardSmall");
            _gameFontBig    = Content.Load <BitmapFont>("fonts/AlagardBig");
            ParticleManager = new ParticleManager <ParticleState>(1024 * 20, ParticleState.UpdateParticle);
            SoundManager.Initialize();
            _currentScene.LoadContent();
        }
        private void UpdateTransition(GameTime gameTime)
        {
            var dt = gameTime.ElapsedGameTime.TotalMilliseconds;

            if (_beginTransitionFade)
            {
                if (_transitionImage.Alpha < 1.0f)
                {
                    _transitionImage.Alpha += 0.1f;
                }
                else
                {
                    _beginTransitionFade = false;
                }
            }
            else
            {
                if (_newScene != null)
                {
                    _currentScene.UnloadContent();
                    _currentScene = _newScene;
                    _currentScene.LoadContent();
                    _newScene = null;
                }

                if (_transitionImage.Alpha > 0.0f)
                {
                    _transitionImage.Alpha -= 0.1f;
                }
                else
                {
                    _transitionImage.IsVisible = false;
                    _isTransitioning           = false;
                }
            }
        }