Exemplo n.º 1
0
        public void LoadGameObjects()
        {
            visibleObjects.Clear();
            animatedObjects.Clear();
            activeObjects.Clear();

            // Load the objects that carry across levels
            player = LevelManager.Instance.Player;
            pickedObject = LevelManager.Instance.PickedObject;
            //if( pickedObject != null )
            //    pickedObject.Load();

            // Load ambient soud if any
            if (LevelManager.Instance.CurrentLevel.ambientSound != null)
            {
                if( StateManager.Instance.CheckDependencies( LevelManager.Instance.CurrentLevel.ambientSound.dependencies ) )
                {
                    ResourceManager.Instance.LoadSound(LevelManager.Instance.CurrentLevel.ambientSound.name, true);
                    SoundManager.PlayAmbientSound();
                    /*
                    ambientSound = content.Load<SoundEffect>(LevelManager.Instance.CurrentLevel.ambientSound.name);
                    ambientSoundInstance = ambientSound.CreateInstance();
                    ambientSoundInstance.IsLooped = LevelManager.Instance.CurrentLevel.ambientSound.looping;
                    ambientSoundInstance.Play();*/
                }
            }

            // Load the level texture
            //ResourceManager.Instance.LoadLevelTexture(LevelManager.Instance.CurrentLevel.texture);

            // Load the background
            visibleObjects.Add(LevelManager.Instance.CurrentLevel.backgroundTexture);

            // Load the objects
            foreach (GameObject io in LevelManager.Instance.CurrentLevel.gameObjects) {
                if (StateManager.Instance.CheckDependencies(io.dependencies)) {
                    if (io.interaction != null)
                    {
                        activeObjects.Add(io);
                        // load interaction sounds
                        if (io.interaction.sound != null)
                            ResourceManager.Instance.LoadSound(io.interaction.sound.name);
                    }
                    if (io.sprite != null) {
                        if (io.sprite.GetType() == typeof(Calendar))
                        {
                            calendar = (Calendar)io.sprite;
                            calendar.Initialize(StateManager.Instance.GetCurrentGameDate(), ScreenManager.Font);
                        }
                        else
                        {
                            io.sprite.Load();
                            visibleObjects.Add(io.sprite);

                            if (io.sprite.GetType() == typeof(AnimatedSprite))
                            {
                                animatedObjects.Add((AnimatedSprite)io.sprite);
                                ((AnimatedSprite)io.sprite).ActiveAnimations.Clear();
                                foreach (FrameSet ap in ((AnimatedSprite)io.sprite).animations)
                                    if (StateManager.Instance.CheckDependencies(ap.dependencies))
                                        ((AnimatedSprite)io.sprite).ActiveAnimations[ap.name] = ap.frames;
                                ((AnimatedSprite)io.sprite).Init();
                            }
                        }
                    }
                }
            }
        }
        public void LoadGameObjects()
        {
            visibleObjects.Clear();
            animatedObjects.Clear();
            activeObjects.Clear();

            // Load ambient soud if any
            if (LevelManager.Instance.CurrentLevel.ambientSound != null)
            {
                if (StateManager.Instance.CheckDependencies(LevelManager.Instance.CurrentLevel.ambientSound.dependencies))
                {
                    ResourceManager.Instance.LoadSound(LevelManager.Instance.CurrentLevel.ambientSound.name, true);
                    SoundManager.PlayAmbientSound();
                }
            }
            // Load the background
            visibleObjects.Add(LevelManager.Instance.CurrentLevel.backgroundTexture);

            // Load the objects
            foreach (GameObject io in LevelManager.Instance.CurrentLevel.gameObjects)
            {
                if (StateManager.Instance.CheckDependencies(io.dependencies))
                {
                    if (io.interaction != null)
                    {
                        activeObjects.Add(io);
                    }
                    if (io.sprite != null)
                    {
                        if (io.sprite.GetType() == typeof(Calendar))
                        {
                            calendar = (Calendar)io.sprite;
                            calendar.Initialize(StateManager.Instance.GetCurrentGameDate(), ScreenManager.Font);
                        }
                        else
                        {
                            io.sprite.Load();
                            visibleObjects.Add(io.sprite);

                            if (io.sprite.GetType() == typeof(AnimatedSprite))
                            {
                                animatedObjects.Add((AnimatedSprite)io.sprite);
                                ((AnimatedSprite)io.sprite).ActiveAnimations.Clear();
                                foreach (FrameSet ap in ((AnimatedSprite)io.sprite).animations)
                                    if (StateManager.Instance.CheckDependencies(ap.dependencies))
                                        ((AnimatedSprite)io.sprite).ActiveAnimations[ap.name] = ap.frames;
                            }
                        }
                    }
                }
            }
        }