Exemplo n.º 1
0
    private void OnTriggerStay2D(Collider2D hitInfo)
    {
        //check for scripts
        enemyhealth   enemy   = hitInfo.GetComponent <enemyhealth>();
        ebulletscript ebullet = hitInfo.GetComponent <ebulletscript>();
        pbulletscript pbullet = hitInfo.GetComponent <pbulletscript>();
        PlayerScript  player  = hitInfo.GetComponent <PlayerScript>();

        //check what script was pulled
        if (ebullet != null)
        {
            //remove ebullet
            ebullet.die();
        }
        if (pbullet != null)
        {
            //remove pbullet
            pbullet.die();
        }
        if (player != null)
        {
            //damage player
            player.TakeDamage(damage);
        }
        if (enemy != null)
        {
            enemy.TakeDamage(damage);
        }
    }
Exemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        //get script
        pbulletscript pbullet = hitInfo.GetComponent <pbulletscript>();

        if (pbullet != null)
        {
            health -= pbullet.GetComponent <pbulletscript>().Damage;
            //remove pbullet
            pbullet.die();
        }
    }
Exemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        //check if enemy/get enemy script
        PlayerScript  player  = hitInfo.GetComponent <PlayerScript>();
        pbulletscript pBullet = hitInfo.GetComponent <pbulletscript>();

        if (pBullet != null)
        {
            ObserverScript.Instance.score += value;
            //remove pbullet
            pBullet.die();
            //remove ebullet
            Destroy(gameObject);
        }
        if (player != null)
        {
            //damage enemy
            player.TakeDamage(Damage);
            //remove bullet
            Destroy(gameObject);
        }
    }