Beispiel #1
0
    private void OnTriggerEnter(Collider other)
    {
        ScoreCounter.ScoreType scoreType;
        try
        {
            scoreType = (ScoreCounter.ScoreType)Enum.Parse(typeof(ScoreCounter.ScoreType), other.gameObject.tag);
        }
        catch (Exception)
        {
            return;
        }

        if (scoreType == ScoreCounter.ScoreType.Trap)
        {
            _scoreCounter.UpdateScore(ScoreCounter.ScoreType.Life, -1);
        }
        else
        {
            _scoreCounter.UpdateScore(scoreType);
        }
        Destroy(other.gameObject);

        if (_scoreCounter.GetLifeScore() <= 0)
        {
            Debug.Log("Game Over");
        }
    }