Exemple #1
0
    // Обнуление всего для нового старта
    private void Zeroing()
    {
        if (spawnWaveCor != null)
        {
            StopCoroutine(spawnWaveCor);
        }
        foreach (Coroutine i in spawnEnemiesCorList)
        {
            if (i != null)
            {
                StopCoroutine(i);
            }
        }
        spawnEnemiesCorList.Clear();
        if (tilesMoveCor != null)
        {
            StopCoroutine(tilesMoveCor);
        }
        if (checkWinningCor != null)
        {
            StopCoroutine(checkWinningCor);
        }
        if (spawnPassangersCor != null)
        {
            StopCoroutine(spawnPassangersCor);
        }

        currentMoney   = startMoney;
        moneyText.text = currentMoney.ToString();
        NewCurrentMoney?.Invoke();
        currentLives        = startLives;
        livesText.text      = startLives.ToString();
        score               = 0;
        scoreText.text      = "0";
        currentWave         = 0;
        waveNumberText.text = currentWave.ToString() + "/" + waves.Length.ToString();
        enemyTiles.transform.localPosition = new Vector2(enemyTilesX, enemyTiles.transform.localPosition.y);
        clockText.text = waveWait.ToString();

        for (int i = 0; i < waves.Length; i++)
        {
            if (i > enabledIconsNumber)
            {
                enemyIcons[i].SetActive(false);
            }
            else
            {
                enemyIcons[i].SetActive(true);
            }
        }

        GameObject[] towers = GameObject.FindGameObjectsWithTag("Tower");
        foreach (GameObject i in towers)
        {
            i.GetComponent <TowerController>().DestroyThisTower();
        }

        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
        foreach (GameObject i in enemies)
        {
            i.GetComponent <EnemyController>().DestroyObject(true);
        }

        GameObject[] airEnemies = GameObject.FindGameObjectsWithTag("AirEnemy");
        foreach (GameObject i in airEnemies)
        {
            i.GetComponent <EnemyController>().DestroyObject(true);
        }

        GameObject[] bullets = GameObject.FindGameObjectsWithTag("Bullet");
        foreach (GameObject i in bullets)
        {
            Destroy(i);
        }
    }
Exemple #2
0
 public void ChangeMoney(int money)
 {
     currentMoney  += money;
     moneyText.text = currentMoney.ToString();
     NewCurrentMoney?.Invoke();
 }