void Shoot()
{
if (!isLocalPlayer || weaponManager.isReloading)
{
return;
}
if (currentWeapon.bullets <= 0)
{
weaponManager.Reload();
return;
}
currentWeapon.bullets--;
Debug.Log("Remaining bullets: " + currentWeapon.bullets);
//We are shooting, call the OnShoot method on the server
CmdOnShoot();
RaycastHit _hit;
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, currentWeapon.range, mask) )
{
if (_hit.collider.tag == PLAYER_TAG)
{
CmdPlayerShot(_hit.collider.name, currentWeapon.damage, transform.name);
}
// We hit something, call the OnHit method on the server
CmdOnHit(_hit.point, _hit.normal);
}
if (currentWeapon.bullets <= 0)
{
weaponManager.Reload();
}
}