Exemple #1
0
    private void CheckIfCloseToPlayers()
    {
        bool tooFarFromPlayers = true;

        foreach (var position in pigRoot.activePlayers)
        {
            if (Vector3.Distance(transform.position, position.position) < tooFarDistance)
            {
                tooFarFromPlayers = false;
            }
        }

        if (tooFarFromPlayers)
        {
            pigRoot.Kill();
        }
    }
Exemple #2
0
    public void TakeDamage(float damage)
    {
        if (!dead)
        {
            currentHealth -= damage;
            if (currentHealth <= 0)
            {
                dead = true;
                // print("died");
                GameManager.Instance.pigsKilled++;
                //audioSource.SetActive(true);
                //audioSource.transform.SetParent(null);
                Instantiate(audioSource, transform.position, transform.rotation);

                pigRoot.Kill();
            }
        }
    }