예제 #1
0
    public void StartGame()
    {
        //Erase any bullets left
        for (int i = bulletContainer.childCount - 1; i >= 0; i--)
        {
            Destroy(bulletContainer.GetChild(i).gameObject);
        }

        //Make the spawner clean itself
        spawner.Clean();

        //Re-Enable Turrets
        EnableTurrets(true);

        //Move torrets back to the initial pos
        foreach (var turret in turrets)
        {
            turret.RestartPos();
        }

        //Initiate Spawns
        spawner.Start();

        //Reset Lifes
        _currentLifes = initialLifes;
        lifeText.text = Mathf.Clamp(_currentLifes, 0, initialLifes) + "";

        //Set the currentState to playing
        _currentState = GameState.Playing;

        //Make sure the tower is active
        playerTower.SetActive(true);
    }