Exemple #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player") && _playerHealth.NumOfLives > 0 && Time.time > _playerHealth.LastTimeHit)
        {
            _playerHealth.NumOfLives--;
            _lifeGrid.RefreshLifeImages(_playerHealth.NumOfLives);
            Debug.Log(_playerHealth.NumOfLives.ToString());
            _playerHealth.LastTimeHit = Time.time + 1;
        }

        if (_playerHealth.NumOfLives < 1)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        LifeGridController lifeGridController = (LifeGridController)target;

        if (GUILayout.Button("Add Life Image"))
        {
            lifeGridController.AddLifeImage();
        }

        if (GUILayout.Button("Refresh Life Images"))
        {
            lifeGridController.RefreshLifeImages(lifeGridController.NumOfLives);
        }
    }