コード例 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IAsteroid asteroid = collision.GetComponent <IAsteroid>();

        if (asteroid != null && shieldBlock == true)
        {
            updateShieldHealth(-gc.asteroidShieldDamage);
            gc.score += gc.asteroidPoints;
            asteroid.Split();
        }
        else if (collision.gameObject.tag == "EnemyAmmo" && shieldBlock == true)
        {
            updateShieldHealth(-gc.asteroidShieldDamage);
            Destroy(collision.gameObject);
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IAsteroid asteroid = collision.GetComponent <IAsteroid>();
        IEnemy    enemy    = collision.GetComponent <IEnemy>();

        if (asteroid != null)
        {
            asteroid.Split();
            gc.score += gc.asteroidPoints;
            removeObject();
        }
        else if (enemy != null)
        {
            enemy.takeDamage(1);
            gc.money += enemy.getMoneyWorth();
            removeObject();
        }
    }