Ejemplo n.º 1
0
        private void CollectLevelProperties(Scene arg0, LoadSceneMode arg1)
        {
            GameObject levelCollector = GameObject.FindGameObjectWithTag("LEVEL_COLLECTOR");

            if (levelCollector == null)
            {
                if (debug)
                {
                    Debug.Log("No LevelCollector found");
                }
                //Clear the LevelHandler to avoid Leftover information from old level remaining;
                LevelHandler.Clear();
                return;
            }

            if (debug)
            {
                Debug.Log("Collecting level properties from: " + levelCollector.name);
            }

            levelCollector.SendMessage("Collect");
            LevelHandler.Start();
            SoundMechanicHandler.Initiate();
        }
Ejemplo n.º 2
0
 private void LoadScene()
 {
     LevelHandler.ShouldLoadFromSaveFile(null);
     GlobalMethods.LoadSceneAndSaveProgress(sceneToLoadIndex);
 }
Ejemplo n.º 3
0
        public static bool SaveToSaveFile()
        {
            Level level = LevelHandler.GetCurrentLevel();

            if (level == null)
            {
                Debug.Log("Cannot save, you appear to not be in a level. (Did you add a levelcollector?)");
                return(false);
            }

            if (!level.IsSavable)
            {
                Debug.Log("You cannot save in this level.");
                return(false);
            }

            SaveFile save = new SaveFile(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name, LevelHandler.GetCurrentCheckPointIndex());

            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream    ms = new MemoryStream();

            bf.Serialize(ms, save);
            byte[]     bytz = ms.ToArray();
            FileStream file = File.Create(SAVEFILE_PATH);

            file.Write(bytz, 0, bytz.Length);
            file.Close();
            Debug.Log("Saved successfully.");

            return(true);
        }
Ejemplo n.º 4
0
 public static void Initiate()
 {
     instance = new LevelHandler();
 }