Пример #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "enemy" && gameObject.tag != "enemybullet" && !other.name.Contains("spike"))
        {
            //   enemy.GetEnemyHit();
            thescoremanager.Addscore(100);
            other.gameObject.SetActive(false);


            Destroy(gameObject);
        }
        else if (other.gameObject.tag == "Player" && gameObject.tag == "enemybullet")
        {
            player.GetPlayerHit();

            Destroy(gameObject);
        }
        else if (other.gameObject.tag == "ground")
        {
            Destroy(gameObject);
        }
        else
        {
            Physics2D.IgnoreCollision(GetComponent <Collider2D>(), other);
        }
    }
Пример #2
0
    void OnTriggerEnter2D(Collider2D other)  //when a projectile collides with another object
    {
        if (other.gameObject.tag == "enemy")
        {
            if (gameObject.tag != "enemybullet")
            {
                enemy.GetEnemyHit();
                thescoremanager.Addscore(100);
                other.gameObject.SetActive(false);
            }

            Destroy(gameObject);
        }
        else if (other.gameObject.tag == "Player")   //if anoter object is 'player' or 'enemy sending the command of receiving the damage
        {
            player.GetPlayerHit();

            Destroy(gameObject);
        }
        else if (other.gameObject.tag == "ground")
        {
            Destroy(gameObject);
        }
        else
        {
            Physics2D.IgnoreCollision(GetComponent <Collider2D>(), other);
        }
    }
Пример #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.name == "Mupi")
        {
            thescoremanager.Addscore(scoretogive);
            gameObject.SetActive(false);

            sound.CoinSound();
        }
    }
Пример #4
0
    private void OnTriggerEnter2D(Collider2D other) // beépített unity fügvény, ha valami belesétál
    {
        if (other.gameObject.name == "Mupi")
        {
            thescoremanager.Addscore(scoretogive); // hozzáadja a jalanlagihez az érme értékét
            gameObject.SetActive(false);

            sound.CoinSound();
        }
    }