Exemple #1
0
        private void ValidateData(ILoaderData dataProvider, IXMLConverter xmlTransformer)
        {
            if (dataProvider == null)
            {
                throw new ArgumentNullException("DataProvider must be not null");
            }

            if (xmlTransformer == null)
            {
                throw new ArgumentNullException("XMLTransformer must be not null");
            }
        }
Exemple #2
0
    //TODO refactor this
    //Perhaps instantiation of loaders can be made inside ILoaderData scripts
    private void Start()
    {
        scene = SceneManager.GetActiveScene();

        ILoaderData data = SceneSwitcher.Singleton.sceneLoaderData;

        if (data.GetType() == typeof(NewMapLoaderData))
        {
            sceneLoader = new GameObject("New Map Loader").AddComponent <NewMapLoader>();
        }
        else if (data.GetType() == typeof(SavedMapLoaderData))
        {
            sceneLoader = new GameObject("Saved Map Loader").AddComponent <SavedMapLoader>();
        }
        else if (data.GetType() == typeof(GamePlayLoaderData))
        {
            sceneLoader = new GameObject("Gameplay scene Loader").AddComponent <GamePlaySceneLoader>();
        }
        else if (data.GetType() == typeof(NextShiftLoaderData))
        {
            sceneLoader = new GameObject("Saved game scene Loader").AddComponent <SavedGameSceneLoader>();
        }

        if (sceneLoader != null)
        {
            sceneLoader.data = SceneSwitcher.Singleton.sceneLoaderData;

            sceneLoader.processes.ForEach(x =>
            {
                processes.Add(x);
            });

            StartCoroutine(StartLoadSequence());
        }
        else
        {
            Debug.LogError("Failed to Instantiate scene loader from given loader data: " + data.GetType().ToString());
            SceneManager.LoadScene("MainMenu");
        }
    }
Exemple #3
0
        /// <summary>
        /// Exports the received data to xml format
        /// </summary>
        /// <param name="loaderData">Loader data</param>
        /// <param name="xmlConverter">Converter data to xml</param>
        /// <returns>xml document</returns>
        public XmlDocument CreateXmlWithData(ILoaderData loaderData, IXMLConverter xmlConverter)
        {
            ValidateData(loaderData, xmlConverter);

            var xmlDocument    = new XmlDocument();
            var xmlDeclaration = xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null);

            xmlDocument.AppendChild(xmlDeclaration);

            var xmlRootElement = xmlDocument.CreateElement("urlAddresses");

            List <string> data = loaderData.LoadData();
            int           i    = 0;

            foreach (var d in data)
            {
                i++;
                string xmlString;
                try
                {
                    xmlString = xmlConverter.ConvertToXml(d);
                }
                catch (Exception)
                {
                    Logger?.Info($"Data on the {i} iteration of the cycle is not valid.");
                    continue;
                }

                var xmlDocumentFragment = xmlDocument.CreateDocumentFragment();
                xmlDocumentFragment.InnerXml = xmlString;

                xmlRootElement.AppendChild(xmlDocumentFragment);
            }

            xmlDocument.AppendChild(xmlRootElement);

            return(xmlDocument);
        }
Exemple #4
0
 public void PrepareToLoadLevel(ILoaderData sceneLoaderData)
 {
     _sceneLoaderData = sceneLoaderData;
     SceneManager.LoadScene(loadingScreenScene);
 }
Exemple #5
0
 public void ToResultsScene(ILoaderData sceneLoaderData)
 {
     _sceneLoaderData = sceneLoaderData;
     SceneManager.LoadScene("ResultsScene");
 }