Example #1
0
 // Update is called once per frame
 void Update()
 {
     if (level == null)
     {
         spawnTime = 1.5f;
         if (ApplicationModel.level == 0 || Int32.Parse(ScoreManager.instance.scoreString) < 50)
         {
             spawnTimer += Time.deltaTime;
             if (spawnTimer >= spawnTime && GameObject.FindGameObjectsWithTag("Enemy").Length < 4)
             {
                 EnnemiScript enemy = spawner.spawn();
                 spawnTimer = 0f;
             }
         }
         else if (GameObject.FindGameObjectsWithTag("Enemy").Length == 0)
         {
             SceneManager.LoadScene(2);
         }
     }
     else
     {
         if (!dialog.isTextBoxActiv() && (nextDialog < currentEvent.dialogs.Count))
         {
             Dialog currentDialog = currentEvent.dialogs[nextDialog];
             if (currentDialog.isFunction)
             {
                 dialog.SendFctBox(currentDialog.content, currentDialog.functionName);
             }
             else
             {
                 dialog.SendOkBox(currentDialog.content);
             }
             nextDialog++;
             spawnTimer = 0;
         }
         else if (!dialog.isTextBoxActiv() && enemiesSpawned == false)
         {
             spawnTimer = 0;
             foreach (Enemy e in currentEvent.enemies)
             {
                 spawnEnemi(e);
             }
             enemiesSpawned = true;
         }
         spawnTimer += Time.deltaTime;
         if ((enemiesSpawned && GameObject.FindGameObjectsWithTag("Enemy").Length == 0) || spawnTimer > spawnTime)
         {
             nextEvent();
         }
     }
 }