예제 #1
0
    private void Start()
    {
        rigidbody1 = GetComponent <Rigidbody2D>();

        healthShot = GetComponent <HealthShotScripts>();

        //upLeft = Camera.main.ScreenToWorldPoint(new Vector3(0f, Screen.height, 0f));
        //downRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0f, 0f));
    }
예제 #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        bool         isDamagePlayer = false;
        EnemyScripts enemy          = collision.gameObject.GetComponent <EnemyScripts>();

        if (enemy != null)
        {
            HealthShotScripts enemyHealth = enemy.GetComponent <HealthShotScripts>();

            if (enemyHealth != null)
            {
                enemyHealth.Damage(enemyHealth.hp);
            }
            isDamagePlayer = true;
        }
        if (isDamagePlayer)
        {
            HealthShotScripts playerHealth = this.GetComponent <HealthShotScripts>();
            if (playerHealth != null)
            {
                playerHealth.Damage(1);
            }
        }
    }