Skip to content
Snippets Groups Projects
LoseNature.cs 711 B
Newer Older
v.bloch's avatar
v.bloch committed
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LoseNature : MonoBehaviour
{
    private bool lostLife = false;
    private int nbFactory = 0;
    public int damageByFactory = 20;
v.bloch's avatar
v.bloch committed

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            if (!lostLife)
            {
                nbFactory = GameObject.FindGameObjectsWithTag("factory").Length;
                Debug.Log("il pert de la vie: " + nbFactory * damageByFactory);
                collision.GetComponent<PlayerNature>().LooseNature(damageByFactory * nbFactory);
v.bloch's avatar
v.bloch committed
                this.lostLife = true;
            }
        }
    }
}