weapon changed
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Media;
|
||||
using Unity.Barracuda;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@ -68,6 +69,13 @@ public class scr_CharacterController : MonoBehaviour
|
||||
public Camera fpsCam;
|
||||
public ParticleSystem muzzleFlash;
|
||||
public GameObject impactEffect;
|
||||
|
||||
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();
|
||||
@ -97,11 +105,40 @@ public class scr_CharacterController : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
void PlayShootingSound()
|
||||
{
|
||||
gunSound.PlayOneShot(gunSound.clip);
|
||||
gunSound.PlayOneShot(aftergunSound);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetButtonDown("Fire1"))
|
||||
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)
|
||||
{
|
||||
PlayShootingSound();
|
||||
Shoot();
|
||||
Debug.Log(current_count_of_bullets_gun);
|
||||
current_count_of_bullets_gun -= 5;
|
||||
}
|
||||
CalculateView();
|
||||
CalculateMovement();
|
||||
|
Reference in New Issue
Block a user