private void SetupAvailableWeapons() { //Add all available weapons based on the weapon templates that were set in the inspector. // Each weapon template has a corresponding weapon class, any unrecognised templates wil throw an error availableWeapons = new Weapon[availableWeaponTemplates.Length]; for (int i = 0; i < availableWeaponTemplates.Length; i++) { if (availableWeaponTemplates[i] is GunWeaponTemplate gunTemplate) { availableWeapons[i] = new GunWeapon(this, gunTemplate); } else if (availableWeaponTemplates[i] is MeleeWeaponTemplate meleeTemplate) { availableWeapons[i] = new MeleeWeapon(this, meleeTemplate); } else if (availableWeaponTemplates[i] is GrenadeWeaponTemplate grenadeTemplate) { availableWeapons[i] = new GrenadeWeapon(this, grenadeTemplate); } else if (availableWeaponTemplates[i] is PrototypeWeaponTemplate prototypeTemplate) { availableWeapons[i] = new PrototypeWeapon(this, prototypeTemplate); } else { Debug.LogError("Unrecognised weapon type at setup: " + availableWeaponTemplates[i].GetWeaponName()); } } }
private void CheckBullet() { currentGun = theHandGunController.GetWeaponGun(); testsBullet[0].text = currentGun.carryBulletCount.ToString(); testsBullet[1].text = currentGun.reloadBulletCount.ToString(); testsBullet[2].text = currentGun.currentBulletCount.ToString(); }
private void FillWeaponList() { foreach (Transform weapon in this.gameObject.transform) { GunWeapon addedWeapon = weapon.GetComponent <GunWeapon>(); if (addedWeapon) { playerWeapons.Add(addedWeapon); } } }
public virtual void GunWeaponChange(GunWeapon _gunWeapon) { if (WeaponManager.currentWeapon != null) { WeaponManager.currentWeapon.gameObject.SetActive(false); WeaponManager.currentWeapon.go_MainUI.SetActive(false); } currentGunWeapon = _gunWeapon; //WeaponManager.currentWeapon = currentGunWeapon.GetComponent<Transform>(); WeaponManager.currentWeapon = currentGunWeapon; WeaponManager.currentWeaponAnim = currentGunWeapon.anim; currentGunWeapon.transform.localPosition = Vector3.zero; currentGunWeapon.gameObject.SetActive(true); currentGunWeapon.go_MainUI.SetActive(true); }
public override void GunWeaponChange(GunWeapon _gunWeapon) { base.GunWeaponChange(_gunWeapon); isActivate = true; }
// Start is called before the first frame update void Awake() { this.virtualCameraNoise = this.virtualCamera.GetCinemachineComponent <CinemachineBasicMultiChannelPerlin>(); this.weapon = this.GetComponent <GunWeapon>(); }
private void ActivateNewWeapon() { playerWeapons[currentWeaponIndex].gameObject.SetActive(true); activeWeapon = playerWeapons[currentWeaponIndex]; }
private void SetStartingWeapon() { currentWeaponIndex = 0; activeWeapon = playerWeapons[currentWeaponIndex]; }