예제 #1
0
    public void gunShot()
    {
        Ray        ray = Camera.main.ScreenPointToRay(crossHair.position);
        RaycastHit enemyHit;

        if (currentGun.bullet_Count > 0)
        {
            currentGun.bullet_Count--;
            if (Physics.Raycast(ray, out enemyHit) && enemyHit.collider != null)
            {
                if (enemyHit.collider.gameObject.CompareTag(currentGun.tag) || enemyHit.collider.gameObject.CompareTag("Boss"))
                {
                    //Debug.Log("3D Hit: " + enemyHit.collider.name);
                    playerStats.AddPoints();
                    playerStats.AddScore();
                    enemyHit.collider.gameObject.GetComponent <EnemyBehavior>().onGetHit(currentGun.damage);
                }
            }
        }
        else
        {
            Debug.Log("Out of Ammo");
        }
        //update ui text
        ammoText.text = "Ammo: " + currentGun.bullet_Count.ToString();
    }