This commit is contained in:
2022-05-09 22:43:31 +07:00
parent 2b7f81fa6e
commit 11090096fc
11 changed files with 1060 additions and 1231 deletions

View File

@ -72,10 +72,6 @@ public class scr_CharacterController : MonoBehaviour
public AudioClip aftergunSound;
public AudioSource gunSound;
public int count_of_bullets = 120;
public int count_of_bullets_gun = 30;
private int current_count_of_bullets_gun = 30;
private void Awake()
{
defaultInput = new DefaultInput();
@ -106,39 +102,18 @@ public class scr_CharacterController : MonoBehaviour
}
void PlayShootingSound()
{
{
gunSound.volume = 1;
gunSound.PlayOneShot(gunSound.clip);
gunSound.PlayOneShot(aftergunSound);
}
private void Update()
{
if (Input.GetKeyDown("r"))
{
Debug.Log("Reload");
int difference = 0;
if (count_of_bullets_gun == current_count_of_bullets_gun)
return;
if (current_count_of_bullets_gun < count_of_bullets_gun)
{
difference = count_of_bullets_gun - current_count_of_bullets_gun;
if (count_of_bullets > difference)
{
current_count_of_bullets_gun = count_of_bullets_gun;
count_of_bullets -= count_of_bullets_gun;
}
else
{
current_count_of_bullets_gun = count_of_bullets;
count_of_bullets = 0;
}
}
}
if (Input.GetButtonDown("Fire1") && current_count_of_bullets_gun > 0)
if (Input.GetButtonDown("Fire1"))
{
PlayShootingSound();
Shoot();
Debug.Log(current_count_of_bullets_gun);
current_count_of_bullets_gun -= 5;
}
CalculateView();
CalculateMovement();
@ -153,7 +128,10 @@ public class scr_CharacterController : MonoBehaviour
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
//Vector3 forward = transform.TransformDirection(Vector3.forward) * 30;
//Debug.DrawRay(transform.position, forward, Color.green);
Target target = hit.transform.GetComponent<Target>();
if (target != null)
{