Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        {
            Enemy enemy = collision.gameObject.GetComponent <Enemy>();

            if (enemy != null)
            {
                enemy.ActivateStick();
            }

            PuzzleEnemy pEnemy = collision.gameObject.GetComponent <PuzzleEnemy>();

            if (pEnemy != null)
            {
                pEnemy.ActivateStick();
            }

            Shield shield = collision.gameObject.GetComponent <Shield>();

            if (shield != null)
            {
                shield.ActivateStick();
            }

            Destroy(gameObject);
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Enemy enemy = collision.gameObject.GetComponent <Enemy>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
        }

        PuzzleEnemy pEnemy = collision.gameObject.GetComponent <PuzzleEnemy>();

        if (pEnemy != null)
        {
            pEnemy.TakeDamage(damage);
        }

        Destroy(gameObject);
    }
Ejemplo n.º 3
0
    private void DetectHit()
    {
        Collider2D[] objectsInRange = Physics2D.OverlapCircleAll(location.position, range);

        foreach (Collider2D collider in objectsInRange)
        {
            Enemy enemy = collider.GetComponent <Enemy>();

            if (enemy != null)
            {
                enemy.HitByBomb();
                continue;
            }

            PuzzleEnemy pEnemy = collider.gameObject.GetComponent <PuzzleEnemy>();

            if (pEnemy != null)
            {
                pEnemy.HitByBomb();
            }

            Player player = collider.GetComponent <Player>();

            if (player != null)
            {
                player.TakeDamage(2);
                continue;
            }

            BreakableWall wall = collider.GetComponent <BreakableWall>();

            if (wall != null)
            {
                wall.BlowUp();
                continue;
            }
        }
    }