예제 #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        var otherTag = other.gameObject.tag;

        // extract to separate function
        if (otherTag.Contains("Asteroid"))
        {
            if (other.CompareTag("Asteroid_big"))
            {
                spawner.SpawnMiddle(2, other.transform.position);
            }
            else if (other.CompareTag("Asteroid_middle"))
            {
                spawner.SpawnSmall(2, other.transform.position);
            }

            gameManager.HandleObjectExplosion(other);
            gameManager.HandlePlayerDamage(GetComponent <Collider2D>());
        }
        else if (other.CompareTag("Ufo_big") || other.CompareTag("Ufo_small"))
        {
            gameManager.HandleObjectExplosion(other);
            gameManager.HandlePlayerDamage(GetComponent <Collider2D>());
        }
    }
예제 #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        var otherTag = other.gameObject.tag;

        if (otherTag.Contains("Asteroid"))
        {
            if (other.CompareTag("Asteroid_big"))
            {
                spawner.SpawnMiddle(2, other.transform.position);
            }
            else if (other.CompareTag("Asteroid_middle"))
            {
                spawner.SpawnSmall(2, other.transform.position);
            }

            gameManager.HandleObjectExplosion(other);
            Destroy(gameObject);
        }
    }
예제 #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        var otherTag = other.gameObject.tag;

        // extract to separate function
        if (otherTag.Contains("Asteroid"))
        {
            if (other.CompareTag("Asteroid_big"))
            {
                spawner.SpawnMiddle(2, other.transform.position);
            }
            else if (other.CompareTag("Asteroid_middle"))
            {
                spawner.SpawnSmall(2, other.transform.position);
            }

            HandleExplosion(other);
        }
        else if (otherTag.Contains("Ufo"))
        {
            HandleExplosion(other);
        }
    }