Beispiel #1
0
    /**
     * defines collison of bullet
     * @pre bullet must be fired
     * @post if it collides with enemy,damage is dealt
     * @param collison is a Collider2D object
     * @return void
     **/
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log(collision.name);
        Enimies_Status enemy = collision.GetComponent <Enimies_Status>();

        if (enemy != null)
        {
            enemy.TakeDmg(damage);
        }
        Destroy(gameObject);
    }
Beispiel #2
0
    /**
     * defines collison of bullet
     * @pre bullet must be fired
     * @post if it collides with enemy,damage is dealt
     * @param collison is a Collider2D object
     * @return void
     **/
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log(collision.name);
        Enimies_Status enemy = collision.GetComponent <Enimies_Status>();
        Boss_Status    boss  = collision.GetComponent <Boss_Status>();

        if (enemy != null)
        {
            Debug.Log("TEST 11: PLAYER SHOT AN ENEMY PASSED");
            enemy.TakeDmg(damage);
        }
        if (boss != null)
        {
            Debug.Log("TEST 12: PLAYER SHOT THE BOSS PASSED");
            boss.TakeDmg(damage);
        }
        Destroy(gameObject);
    }