示例#1
0
    void Awake()
    {
        saveScript.Load();

        foreach (FirstDataset dataset in saveScript.dataBase.firstDB)
        {
            if (dataset.name == "Level")
            {
                level = (int)dataset.value;
            }
        }
        text.text = "Level : " + level.ToString();
    }
示例#2
0
    private List <GameObject> dataVisu = new List <GameObject>(); //List of all blocs

    //Load the XML (Button usage)
    public void LoadXML()
    {
        //Destroy all blocs if there is any
        if (dataVisu.Count != 0)
        {
            foreach (GameObject datavisu in dataVisu)
            {
                Destroy(datavisu);
            }
        }
        //Clear the list
        dataVisu.Clear();

        //Load the XML
        xmlSaveScript.Load();

        //Display the blocs
        Display();
    }
    IEnumerator SpawnWaves()
    {
        yield return(new WaitForSeconds(waitBeforeStart)); //Wait before spawning first wave

        foreach (Wave wave in waves)
        {
            GameObject enemy = Instantiate(GetEnemy(wave.toSpawn), GetSpawnPosition(wave.zoneToSpawn).position, Quaternion.identity); //Instantiate enemy in correct zone
            enemy.transform.parent = GetSpawnPosition(wave.zoneToSpawn);                                                              //Put the enemy in the zone transform
            enemy.GetComponent <EnemyControls>().DropUpgrade = wave.spawnUpgrade;
            enemy.transform.position = Vector3.zero;                                                                                  //Set the enemy position to the zone transform position
            currentEnemies.Add(enemy);                                                                                                //Add the enemy to the list
            enemy.tag = "Enemy";                                                                                                      //Set the tag of the enemies
            //If the wave need to wait before spawning the next wave
            if (wave.waitUntilDestruction)
            {
                while (currentEnemies.Count > 0)   //Check if all the enemies are destroyed
                {
                    yield return(new WaitForSeconds(0.1f));
                }
            }
            yield return(new WaitForSeconds(wave.timeBeforeSpawnNext));

            DrawBar();//Draw progress bar
        }

        while (currentEnemies.Count > 0)
        {
            yield return(new WaitForSeconds(0.1f)); //Wait for all enemies to die
        }

        //Save level
        saveSystem.Load();
        if (saveSystem.dataBase.firstDB[0].value < levelID)
        {
            saveSystem.dataBase.firstDB[0].value = levelID;
            saveSystem.Save();
        }

        //Tell that the level has ended
        isEndLevel = true;
    }
示例#4
0
 public void ResetSlider()
 {
     xmlSystem.Load();
     slider.value = xmlSystem.dataBase.firstDB[1].value;
 }