mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
Weapons WORK NOW
Jetzt wirklich
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user