shoot und reload auf knöpfe vom InputManager angepasst

This commit is contained in:
pbg2h23akl
2024-08-21 12:17:02 +02:00
parent 7c2d4c46d4
commit 4982142557
2 changed files with 76 additions and 4 deletions

View File

@@ -11,6 +11,8 @@ public class WeaponScript : MonoBehaviour
public DataBullet dataBullet;
public UI_Manager uI_Manager;
private InputManagerScript inputManagerScript;
private int ammo;
private bool isReloading = false;
private float time = 0;
@@ -21,7 +23,7 @@ public class WeaponScript : MonoBehaviour
public float schussInterval;
private float delay = 0;
public void checkReload(){
if(ammo == 0){
if(ammo == 0 || Input.GetKeyDown(inputManagerScript.getReload())){
isReloading = true;
}
if(isReloading){
@@ -35,8 +37,8 @@ public class WeaponScript : MonoBehaviour
}
}
public void shoot(){
if(ammo != 0 && delayOver){
if(Input.GetKeyDown(KeyCode.Mouse0)){
if(!isReloading && delayOver){
if(Input.GetKeyDown(inputManagerScript.getShoot())){
muzzle.gameObject.SetActive(true);
//muzzle.Play();
Instantiate(bullet,spawnpoint.transform.position,spawnpoint.transform.rotation);
@@ -61,6 +63,7 @@ public class WeaponScript : MonoBehaviour
muzzle = GetComponentInChildren<ParticleSystem>();
spawnpoint = GameObject.Find("Player/PlayerView/BulletSpawnpoint");
uI_Manager = GameObject.FindGameObjectWithTag("Manager").GetComponent<UI_Manager>();
inputManagerScript = GameObject.Find("InputManager").GetComponent<InputManagerScript>();
}
// Update is called once per frame