private void Start() { currentWeaponScript = GetComponent <IWeaponAction>(); playerController = this.transform.parent.parent.GetComponent <PlayerController>(); gunShootScript = GetComponent <ClassicGunShoot>(); currentWeaponScript.OnShoot += ShootShoddyBarrels; }
void UnequipCurrentWeapon() { if (weaponHolder.childCount > 0) { currentWeapon = 0; Destroy(weaponHolder.GetChild(0).gameObject); currentSpawnedWeaponPrefab = null; currentSpawnedWeaponRenderer = null; currentWeaponAction = null; } }
public void EquipWeapon(int weaponId) { UnequipCurrentWeapon(); GameManager.instance.SetPlayerEquipWeaponDisplay(GameManager.instance.GetPlayerId(this.gameObject), weaponId); currentWeapon = weaponId; WeaponInfo weaponToEquip = GameManager.instance.weaponDatabase.allWeapons[weaponId]; if (weaponToEquip.weaponPrefab != null) { currentSpawnedWeaponPrefab = Instantiate(weaponToEquip.weaponPrefab, weaponHolder); } currentWeaponAction = currentSpawnedWeaponPrefab.GetComponent <IWeaponAction>(); currentSpawnedWeaponRenderer = currentSpawnedWeaponPrefab.GetComponent <SpriteRenderer>(); GetComponent <PlayerHealth>().SetMaxHealth(weaponId); maxAmmo = weaponToEquip.ammoCount; currentAmmo = maxAmmo; RefreshAmmoDisplay(); }
public void Fire(IWeaponAction gun) { gun.Fire(); }