Ejemplo n.º 1
0
    public void LoadFromSpecifiedFilePath()
    {
        _patternLoader = GetComponent <PatternLoader>();
        try
        {
            Pattern pattern = _patternLoader.LoadPatternFromFile(FilePath);

            ClearExistingItems();

            Bounds.localScale = new Vector3(pattern.Length, Bounds.localScale.y, Bounds.localScale.z);

            foreach (SpawnEvent spawnEvent in pattern.SpawnEvents)
            {
                Transform     t  = ObjectFactory.Instance.Instantiate(spawnEvent.ObjectName);
                ParallaxLayer pl = GameObject.Find(spawnEvent.Parent).GetComponent <ParallaxLayer>();
                t.SetParent(pl.transform);
                t.position = new Vector3(AdjustForBounds(spawnEvent.Distance, true), spawnEvent.YPosition + t.parent.position.y);
            }
        }
        catch (Exception e)
        {
            Debug.LogError("Failed to load pattern");
            Debug.Log(e.Message);
        }
    }
Ejemplo n.º 2
0
    void LoadPatterns(string sectionName, ref List <Pattern> list)
    {
        list = new List <Pattern>();

        string[] files = Directory.GetFiles("Assets/Data/Patterns/" + sectionName);

        foreach (string file in files)
        {
            if (file.EndsWith(".xml"))
            {
                list.Add(_patternLoader.LoadPatternFromFile(file));
            }
        }
    }