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();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public PlayScreen(TransitionType transitionFrom = TransitionType.Room)
        {
            // Handle the different transition values
            transition = transitionFrom;
            switch (transition)
            {
                case TransitionType.Room:
                    TransitionOnTime = TimeSpan.FromSeconds(0.5);
                    break;

                case TransitionType.FromPast:
                    StateManager.Instance.GoToPast();
                    TransitionOnTime = TimeSpan.FromSeconds(0.5);
                    break;
                case TransitionType.FromPresent:
                    TransitionOnTime = TimeSpan.FromSeconds(0.5);
                    break;

                case TransitionType.ToPast:
                case TransitionType.ToPresent:
                    TransitionOnTime = TimeSpan.FromSeconds(2.0);
                    break;
            }
            TransitionOffTime = TimeSpan.FromSeconds(0.5);

            player = LevelManager.Instance.Player;

            // play game music
            SoundManager.PlayMusic();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Parses levels and chats XML file and stores information in memory
 /// </summary>
 public void LoadAllLevels()
 {
     if (!loaded)
     {
         //this.content = content;
         player = new Player(content);
         StateManager.Instance.AdvanceDay();
         loaded = true;
     }
 }