// Update is called once per frame
    void Update()
    {
        Skin = GameObject.Find("FinalBossLaser 2 1 1 1").GetComponent <Enemybehavior>();
        //==
        if (Skin.health < 1200)
        {
            currentMaterials %= Materials.Length;
            GetComponent <Renderer>().material = Materials[currentMaterials];
        }

        if (Skin.health < 1000)
        {
            currentMaterials++;
            currentMaterials %= Materials.Length;
            GetComponent <Renderer>().material = Materials[currentMaterials];
        }

        if (Skin.health < 800)
        {
            currentMaterials++;
            currentMaterials %= Materials.Length;
            GetComponent <Renderer>().material = Materials[currentMaterials];
        }

        if (Skin.health < 600)//(health < 600 && 400 > health)
        {
            currentMaterials++;
            currentMaterials %= Materials.Length;

            GetComponent <Renderer>().material = Materials[currentMaterials];
        }

        if (Skin.health < 400)
        {
            currentMaterials++;
            currentMaterials %= Materials.Length;
            GetComponent <Renderer>().material = Materials[currentMaterials];
        }

        if (Skin.health < 200)
        {
            currentMaterials++;
            currentMaterials %= Materials.Length;
            GetComponent <Renderer>().material = Materials[currentMaterials];
        }
    }
    IEnumerator SpawnWaves()                 // erstellen eine routine
    {
        while (currentWave < waveList.Count) //Prüfung wie viele Wellen noch bevorsthenen und bei welcher wir gerade sind
        {
            /*
             * if(currentWave == waveList.Count-1)
             * {
             *  spawnComplete = true;
             * }
             */

            //Paths neue Formation
            for (int i = 0; i < waveList[currentWave].pathPrefabs.Length; i++) //spawning pathes
            {
                GameObject newPathObj = Instantiate(waveList[currentWave].pathPrefabs[i], transform.position, Quaternion.identity) as GameObject;
                Path       newPath    = newPathObj.GetComponent <Path>();
                activePathList.Add(newPath);
            }
            yield return(new WaitForSeconds(enemySpawnInterval));

            // Spawn der Virus-Schiffe
            for (int i = 0; i < waveList[currentWave].VirusAmount; i++)
            {
                GameObject    newVirus      = Instantiate(VirusPrefab, transform.position, Quaternion.identity) as GameObject; //erstellen des neues Gameobjekt und rotation
                Enemybehavior VirusBehavior = newVirus.GetComponent <Enemybehavior>();                                         // auf Enemybehavior zugreifen und übertragen damit neu erstellter Virus weiß was er machen soll

                //neue Spawn Formation
                VirusBehavior.SpawnSetup(activePathList[ZickZack()], VirusID, VirusFormation); //einbringung der Daten vom Enemybehavior (pathToFollow = path, enemyID = ID, formation = _formation
                VirusID++;

                //alte Spawn Formation
                //VirusBehavior.SpawnSetup(waveList[currentWave].path, VirusID, VirusFormation);


                spawnedEnemies.Add(newVirus);

                //weitergeben an Game Manager
                GameManager.instance.AddEnemy();

                //Warten auf nächstes Spawn (interval)
                yield return(new WaitForSeconds(enemySpawnInterval));
            }

            // Spawn der Enemy2 Schiffe

            for (int i = 0; i < waveList[currentWave].Enemy2Amount; i++)
            {
                GameObject    newEnemy2      = Instantiate(Enemy2Prefab, transform.position, Quaternion.identity) as GameObject; //erstellen des neues Gameobjekt und rotation
                Enemybehavior Enemy2Behavior = newEnemy2.GetComponent <Enemybehavior>();                                         // auf Enemybehavior zugreifen und übertragen damit neu erstellter Virus weiß was er machen soll

                Enemy2Behavior.SpawnSetup(activePathList[ZickZack()], Enemy2ID, Enemy2Formation);                                //einbringung der Daten vom Enemybehavior (pathToFollow = path, enemyID = ID, formation = _formation
                Enemy2ID++;

                //spawnedEnemies.Add(newEnemy2);

                //weitergeben an Game Manager
                //GameManager.instance.AddEnemy();

                //Warten auf nächstes Spawn (interval)
                yield return(new WaitForSeconds(enemySpawnInterval));
            }
            // for (int i = 0; i < waveList[currentWave].Enemy2Amount; i++) ----------------- Weiß nicht mehr wozu das war


            // Spawn der Boss Schiffe
            for (int i = 0; i < waveList[currentWave].BossAmount; i++)
            {
                GameObject    newBoss      = Instantiate(BossPrefab, transform.position, Quaternion.identity) as GameObject; //erstellen des neues Gameobjekt und rotation
                Enemybehavior BossBehavior = newBoss.GetComponent <Enemybehavior>();                                         // auf Enemybehavior zugreifen und übertragen damit neu erstellter Virus weiß was er machen soll

                BossBehavior.SpawnSetup(activePathList[ZickZack()], BossID, BossFormation);                                  //einbringung der Daten vom Enemybehavior (pathToFollow = path, enemyID = ID, formation = _formation
                BossID++;

                spawnedEnemies.Add(newBoss);

                //weitergeben an Game Manager
                GameManager.instance.AddEnemy();

                //Warten auf nächstes Spawn (interval)
                yield return(new WaitForSeconds(enemySpawnInterval));
            }



            yield return(new WaitForSeconds(waveSpawnInterval));

            currentWave++;                     //Startet nächste Welle

            foreach (Path p in activePathList) //löschen des benutzten Weg
            {
                Destroy(p.gameObject);
            }
            activePathList.Clear();
        }
    }