Ejemplo n.º 1
0
    public void PrepareWaves()
    {
        //gives the path
        string filePath = ProjectPaths.RESOURCES_MAP_SETTINGS + MapTypes.GetName(typeof(MapTypes), _mapType) + ".txt";

        Debug.Log(filePath);
        //reads the lines in the path
        string[] rows = File.ReadAllLines(filePath);

        //iterates through all the lines
        int breakPoint = 0;

        for (int i = 0; i < rows.Length; i++)
        {
            //saves the point where the symbol is
            if (rows[i].Contains("#"))
            {
                breakPoint = i + 1;
                break;
            }
        }

        //create empty array with required size
        string[] waves = new string[rows.Length - breakPoint];

        //copy this array to the other array
        Array.Copy(rows, breakPoint, waves, 0, rows.Length - breakPoint);


        //each wave in waves, turn into two ints
        //maybe use a string.somefunction() to separate the numbers?
        //add to List<Vector2Int>();
        foreach (string wave in waves)
        {
            string[] enemyCounts = wave.Split(' ');
            //Debug.Log(enemyCounts[0]);
            //Debug.Log(enemyCounts[1]);
            EnemyCount enemyCount = new EnemyCount(Convert.ToInt32(enemyCounts[0]), Convert.ToInt32(enemyCounts[1]));
            WaveList.Add(enemyCount);
        }
    }