Weapons WORK NOW

Jetzt wirklich
This commit is contained in:
Noah4ever
2021-11-25 12:45:55 +01:00
parent 859dda5899
commit 20080a4dd5
6 changed files with 169 additions and 202 deletions

View File

@@ -119,6 +119,14 @@ public class Shoot : NetworkBehaviour
return false;
}
public bool setWeapon(GameObject newWeapon) {
Debug.Log("SetWeapon: " + newWeapon);
weapon = newWeapon.GetComponent<Weapon>();
curAmmo = weapon.CurrentAmmunition;
totalAmmo = weapon.TotalAmmunition;
muzzle = weapon.BulletExit;
return true;
}
private bool reloadWeapon(Weapon weapon) { // Reloads Ammunition from weapon
if (weapon.AllowAction && weapon.TotalAmmunition > 0) {
weapon.AllowAction = false;

View File

@@ -11,13 +11,15 @@ public class WeaponManager : NetworkBehaviour
private int counter = 0;
public List<GameObject> activeWeapons = new List<GameObject>();
private ProcedualAnimationController procedualAnimationController;
[SerializeField] Shoot shoot;
[SerializeField] GameObject gunHolster;
[SerializeField] Camera cam;
private void Awake()
{
procedualAnimationController = GetComponent<ProcedualAnimationController>();
}
@@ -29,7 +31,8 @@ public class WeaponManager : NetworkBehaviour
if (nextActive != -1) { // -1 no next found
currentWeaponIndex = nextActive;
activeWeapons[currentWeaponIndex].SetActive(true);
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex].gameObject);
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
// play weapon switch animation
}
}
@@ -39,7 +42,8 @@ public class WeaponManager : NetworkBehaviour
if (nextActive != -1) { // -1 no next found
currentWeaponIndex = nextActive;
activeWeapons[currentWeaponIndex].SetActive(true);
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex].gameObject);
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
// play weapon switch animation
}
}
@@ -57,7 +61,8 @@ public class WeaponManager : NetworkBehaviour
if (nextActive != -1) { // -1 no next found
currentWeaponIndex = nextActive;
activeWeapons[currentWeaponIndex].SetActive(true);
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex].gameObject);
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
// play weapon switch animation
}
}
@@ -130,7 +135,9 @@ public class WeaponManager : NetworkBehaviour
activeWeapons[index] = hit.transform.gameObject;
activeWeapons[index].SetActive(true);
currentWeaponIndex = index;
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex].gameObject);
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
Debug.Log(activeWeapons[currentWeaponIndex]);
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
return true;
}