Example #1
0
 // Loads the map from a text file.
 protected override void LoadMapFromText()
 {
     if (seed == null)
     {
         if (textFilePath == null)
         {
             ErrorManager.ErrorBackToMenu(-1);
         }
         else if (!File.Exists(textFilePath))
         {
             ErrorManager.ErrorBackToMenu(-1);
         }
         else
         {
             try {
                 ConvertToMatrix(File.ReadAllLines(@textFilePath));
             } catch (Exception) {
                 ErrorManager.ErrorBackToMenu(-1);
             }
         }
     }
     else
     {
         ConvertToMatrix(seed.Split(new string[] { "\n", "\r\n" },
                                    StringSplitOptions.RemoveEmptyEntries));
     }
 }
Example #2
0
    // Menages errors going back to the main menu.
    protected void ManageError(Error error, string errorMessage)
    {
        switch (error)
        {
        case Error.SOFT_ERROR:
            Debug.LogError("Unexpected soft error. " + errorMessage);
            break;

        case Error.HARD_ERROR:
            ErrorManager.ErrorBackToMenu(errorMessage);
            break;

        case Error.RETRY_ERROR:
            Debug.LogError("Unexpected  error. " + errorMessage + " The scene will be " +
                           "reloaded.");
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            break;
        }
    }
Example #3
0
    public static void ManageError(Error error, int errorCode)
    {
        switch (error)
        {
        case Error.SOFT_ERROR:
            Debug.LogError("Unexpected soft error with code " + errorCode + ".");
            GeneratorUIManager.Instance.showDialogErrorBox("Unexpected soft error with code " + errorCode + ".");
            break;

        case Error.HARD_ERROR:
            ErrorManager.ErrorBackToMenu(errorCode);
            break;

        case Error.RETRY_ERROR:
            Debug.LogError("Unexpected error with code " + errorCode + ". The scene will be" +
                           " reloaded.");
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            break;
        }
    }
Example #4
0
 // Shows the loading animation and loads.
 void Loading()
 {
     loadingText.text = "Loading";
     OpenSection(loading);
     if (currentGeneration == 2)
     {
         loadingText.text = "Validating the map";
         int errorCode = currentIsMultilevel ?
                         MapValidate.ValidateMLMap(ParameterManager.Instance.MapDNA) :
                         MapValidate.ValidateMap(ParameterManager.Instance.MapDNA);
         if (errorCode == 0)
         {
             Load(currentScene);
         }
         else
         {
             ParameterManager.Instance.BackgroundRotation = backgroundScript.GetRotation();
             ErrorManager.ErrorBackToMenu(errorCode);
         }
     }
     else if (currentGeneration == 3)
     {
         loadingText.text = "Validating the map";
         int errorCode = currentIsMultilevel ?
                         MapValidate.ValidateGeneticMLMap(ParameterManager.Instance.MapDNA) :
                         MapValidate.ValidateGeneticMap(ParameterManager.Instance.MapDNA);
         if (errorCode == 0)
         {
             Load(currentScene);
         }
         else
         {
             ParameterManager.Instance.BackgroundRotation = backgroundScript.GetRotation();
             ErrorManager.ErrorBackToMenu(errorCode);
         }
     }
     else
     {
         Load(currentScene);
     }
 }