コード例 #1
0
    void Shot()
    {
        if (is_infinite_ammo == false)
        {
            currentAmmo--;
        }

        RaycastHit hit;

        Ray r = cam.ScreenPointToRay(transform.position);

        if (Physics.Raycast(r, out hit))
        {
            Target    target = hit.transform.GetComponent <Target>();
            Explosion bomb   = hit.transform.GetComponent <Explosion>();
            Enemy     enemy  = hit.transform.GetComponent <Enemy>();

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

            if (bomb != null)
            {
                bomb.Activate_Explosion();
                //powerup_go.bomb_used = true;
            }

            if (enemy != null)
            {
                powerup_go.Increase_kills();
            }

            if (enemy == null && enemy == null && bomb == null)
            {
                //Restart kills
                powerup_go.Reset_Kills();
            }
        }
    }