public void EquipOrUnequip(WeaponMount weaponMount, bool equip) { if (weaponMount.DecorationTransform != null) { weaponMount.DecorationTransform.gameObject.SetActive(!equip); } if (weaponMount.EquippedWeaponTransform != null) { weaponMount.EquippedWeaponTransform.gameObject.SetActive(equip); } if (weaponMount.EquippedThrowableDecorationTransform != null) { weaponMount.EquippedThrowableDecorationTransform.gameObject.SetActive(equip); } if (weaponMount.CarrierDecoration != null) { weaponMount.CarrierDecoration.gameObject.SetActive(true); } // We play the equip animation if (equip) { _player.PlayerWeaponsAnimator.EquipAnimation(weaponMount); } }
public Adder() { Category = "Small Spacecraft"; Manufacturer = "Zorgon Peterson"; Dimensions = "L 31.5m x W 28.8m x H 9.6m"; LandingPad = "Small"; Crew = 2; Passengers = 1; Agility = 8; Speed = 6; Range = "Explorer (50% Bonus)"; Fuel = "8T (80LY)"; Hull = 75; SetHullValues(75, 112); Shields = 0; Bulkheads = new Bulkheads("Adder", 35120, 79030); ReinforcedAlloys = true; Weapons = new WeaponMount[] { new WeaponMount(1), new WeaponMount(1), new WeaponMount(2) }; Utilities = new UtilityMount[] { new UtilityMount(0), new UtilityMount(0) }; Fixed = new FixedMount[] { new FixedMount(3, "Power Plant", new PowerPlants('E', 3, 8, 30, 6200)), new FixedMount(3, "Thrusters", new Thrusters(3, 'E', 2.48, 30, 0, 0, 6270)), new FixedMount(3, "FSD", new FrameShiftDrive('E', 3, 25, 0.24, 9, 6270)), new FixedMount(1, "Life Support", new LifeSupport(5, 0.32, 'E', 520, 1, 15)), new FixedMount(2, "Power Distributor", new PowerDistributor('E', 0.36, 1450, 2, 20, 0, 0, 0, 0)), new FixedMount(3, "Sensors", new Sensors(3, 'E', 0.18, 1450, 15, new int[] { 0, 0 })) }; FuelTank = new FixedMount(3, "FuelTank", new FuelTank('C', 3, 8, 7060)); CargoHatch = new FixedMount(1, "Cargo Hatch", new CargoHatch()); Optionals = new OptionalMount[] { new OptionalMount(3), new OptionalMount(3), new OptionalMount(2), new OptionalMount(2), new OptionalMount(1) }; }
public void EquipAnimation(WeaponMount weaponMount) { if (weaponMount.EquipAnimatorTrigger != "") { _animator.SetTrigger(weaponMount.EquipAnimatorTrigger); } }
public float GetWeaponDamage(WeaponMount slot) { if (equippedWeapons.ContainsKey(slot)) { return(equippedWeapons[slot].baseDamage); } return(baseDamage); }
public frmCreateWeaponMount(Vehicle objVehicle, Character objCharacter, WeaponMount objWeaponMount = null) { _xmlDoc = XmlManager.Load("vehicles.xml"); _objVehicle = objVehicle; _objMount = objWeaponMount; _objCharacter = objCharacter; InitializeComponent(); }
void SetWeapon(WeaponMount mount, GameObject prefab = null) { for (int i = 0; i < mount.transform.childCount; ++i) { Destroy(mount.transform.GetChild(0).gameObject); } Instantiate(prefab == null ? mount.weapons[0].prefab : prefab, mount.transform); }
public PowerupAttachable GetWeapon(WeaponMount mount) { if (equippedWeapons.ContainsKey(mount)) { return(equippedWeapons[mount]); } return(null); }
public IEnumerator AutoFireWeapon(WeaponMount weaponMount) { while (isAutoFiring) { WeaponData weapon = weaponMount.weapons[0]; FireWeapon(weapon, weaponMount.transform); yield return(new WaitForSeconds(1 / weapon.fireRate)); } }
public void Unequipper(string name) { noItem = true; switch (name) { case "FrontWeapons": weaponMount = WeaponMount.Grill; isWeapon = true; break; case "RearWeapons": weaponMount = WeaponMount.Hitch; isWeapon = true; break; case "DoorWeapons": weaponMount = WeaponMount.Doors; isWeapon = true; break; case "RoofWeapons": weaponMount = WeaponMount.Roof; isWeapon = true; break; case "WheelWeapons": weaponMount = WeaponMount.Wheels; isWeapon = true; break; case "EngineMods": modMount = ModMount.Engine; isWeapon = false; break; case "NitroMods": modMount = ModMount.Trunk; isWeapon = false; break; case "ChassisMods": modMount = ModMount.Frame; isWeapon = false; break; case "BumperMods": modMount = ModMount.Bumpers; isWeapon = false; break; case "WheelMods": modMount = ModMount.Tires; isWeapon = false; break; } }
private void Update() { if (_player.PlayerWeapons.EquippedWeaponMount == null) { return; } WeaponMount weaponMount = _player.PlayerWeapons.EquippedWeaponMount; // Can't fire when spriting or busy with wall or weapon is unprepared if (GameManager.Instance.InputManager.Firing //&& !_player.PlayerState.IsSprinting() && !_player.PlayerState.IsBusyWithWall && _player.PlayerState.PlayerWeaponState == PlayerWeaponState.Prepared && weaponMount.MagazineAmmo != 0 && !_player.PlayerWeaponsAnimator.IsReloading) { if (Time.time > _nextFireTime) { _nextFireTime = Time.time + weaponMount.Weapon.TimeBetweenBullets; if (weaponMount.Weapon.WithFireAnimation) { if (weaponMount.Weapon.ChargingWeapon) { if (_isCharging) { return; } _isCharging = true; _player.PlayerWeaponsAnimator.Charge(true); //GameManager.Instance.AudioManager.PlayOneShotSound(weaponMount.Weapon.ChargingSound, 1, 0, 1, transform.position); _player.PlayerWeaponsAnimator.Fire(); } else { _player.PlayerWeaponsAnimator.Fire(); } } else { Fire(weaponMount); } } } // If we are done charging the weapon, we let go and exert the attack if (!GameManager.Instance.InputManager.Firing && _isCharging) { _isCharging = false; _player.PlayerWeaponsAnimator.Charge(false); } }
protected T GetWeaponMount <T>(int index, HardpointTypes type) where T : WeaponTemplate, new() { WeaponMount mount = FindWeaponMount(type, index); if (mount.MountedWeapon == null || mount.MountedWeapon.WeaponType != GetStandardWeaponTypeForMount(type)) { mount.MountedWeapon = new T(); } return(mount.MountedWeapon as T); }
public void SetupBeamWeapon(int hardpointIndex, float arc, float nomialDir, float range, float cycleTime, float damage) { WeaponMount mount = FindWeaponMount(HardpointTypes.Beam, hardpointIndex); var beam = GetWeaponMount <BeamWeaponBankTemplate>(hardpointIndex, HardpointTypes.Beam); beam.BeamArc = arc; mount.DefaultFacing = nomialDir; beam.NominalRange = range; beam.NominalCycleTime = cycleTime; beam.NominalDamage = damage; }
private void HandleReload() { if (GameManager.Instance.InputManager.Reload && !_isReloading && _player.PlayerState.PlayerWeaponState == PlayerWeaponState.Prepared) { WeaponMount weaponMount = _player.PlayerWeapons.EquippedWeaponMount; if (weaponMount.MagazineAmmo < weaponMount.Weapon.MaxMagazineAmmo && weaponMount.Ammo > 0) { Reload(); } } }
public WeaponMount Clone() { WeaponMount m = new WeaponMount(); m.DefaultFacing = DefaultFacing; m.IsTurret = IsTurret; m.RotationArc = RotationArc; m.RotationSpeed = RotationSpeed; m.MountedWeapon = MountedWeapon?.Clone(); m.Hardpoint = new HardpointID(Hardpoint); return(m); }
public void ShowUnequippedItem(WeaponMount mount) { StatPack pack = new StatPack(); PowerupAttachable otherItem = controller.GetCar().GetComponent <PowerupManager>().GetWeapon(mount); if (otherItem == null) { return; } StatPack otherPack = otherItem.GetComponent <PowerupStats>().GetPack(); ShowStatBars(pack, otherPack); damageSliders.ShowPotentialWeapon(mount, controller.GetCar().GetComponent <PowerupManager>().baseDamage); }
public WeaponMount FindWeaponMount(HardpointTypes type, int index) { HardpointID id = new HardpointID(type, index); if (Weapons.ContainsKey(id)) { return(Weapons[id]); } WeaponMount mount = new WeaponMount(); mount.Hardpoint = id; Weapons.Add(id, mount); return(mount); }
public void Remove(WeaponMount slot) { Debug.Log("CALLED"); if (equippedWeapons.ContainsKey(slot)) { equippedWeapons[slot].GetComponent <PowerupMain>().UnEquip(); equippedWeapons.Remove(slot); } if (physicalWeapons.ContainsKey(slot)) { foreach (GameObject oldWeapon in physicalWeapons[slot]) { Destroy(oldWeapon); } } ReCalcStats(); }
private void Update() { WeaponMount weaponMount = GameManager.Instance.Player.PlayerWeapons.EquippedWeaponMount; if (weaponMount.Weapon.WeaponType == WeaponType.Hands && _ammoPanel.gameObject.activeSelf) { _ammoPanel.gameObject.SetActive(false); } else if ((weaponMount.Weapon.IsRangeWeapon) && !_ammoPanel.gameObject.activeSelf) { _ammoPanel.gameObject.SetActive(true); } _magazineAmmoText.text = weaponMount.MagazineAmmo + ""; _ammoText.text = weaponMount.Ammo + ""; }
public static void TryUpdate(StatPack pack, WeaponMount weapon, float damage) { if (damage > maxDamage) { maxDamage = damage; } if (WeaponMin.ContainsKey(weapon)) { WeaponMin[weapon] = StatPack.Min(WeaponMin[weapon], pack); WeaponMax[weapon] = StatPack.Max(WeaponMax[weapon], pack); } else { WeaponMin[weapon] = StatPack.Min(new StatPack(), pack); WeaponMax[weapon] = StatPack.Max(new StatPack(), pack); } UpdateMinMax(); }
public void RefreshAmmunationDecoration(WeaponMount weaponMount) { if (weaponMount.AmmunationDecorations.Count == 0) { return; } for (int i = 0; i < weaponMount.AmmunationDecorations.Count; i++) { if (i < weaponMount.Ammo) { weaponMount.AmmunationDecorations[i].gameObject.SetActive(true); } else { weaponMount.AmmunationDecorations[i].gameObject.SetActive(false); } } }
private void Equip(int scroll) { if (scroll != 0) { GameManager.Instance.AudioManager.PlayOneShotSound(_equipWeaponSound, 1, 0, 1, transform.position); } // When we equip a new weapon, we unprepare the previous one if (scroll != 0) { _player.PlayerState.UnprepareWeapon(); } int equippedWeaponIndex = 0; for (int i = 0; i < _weaponMountsInPossession.Count; i++) { if (_weaponMountsInPossession[i] == _equippedWeaponMount) { equippedWeaponIndex = i; } } equippedWeaponIndex += scroll; if (equippedWeaponIndex >= _weaponMountsInPossession.Count) { equippedWeaponIndex = 0; } if (equippedWeaponIndex < 0) { equippedWeaponIndex = _weaponMountsInPossession.Count - 1; } foreach (WeaponMount weaponMount in _weaponMountsInPossession) { EquipOrUnequip(weaponMount, false); } EquipOrUnequip(_weaponMountsInPossession[equippedWeaponIndex], true); _equippedWeaponMount = _weaponMountsInPossession[equippedWeaponIndex]; }
public void ShowPotentialWeapon(WeaponMount weaponLocation, float damage) { Slider slider; PowerupManager car = controller.GetCar().GetComponent <PowerupManager>(); switch (weaponLocation) { case WeaponMount.Grill: slider = transform.Find("FrontSlider").GetComponent <Slider>(); break; case WeaponMount.Hitch: slider = transform.Find("RearSlider").GetComponent <Slider>(); break; case WeaponMount.Roof: slider = transform.Find("RoofSlider").GetComponent <Slider>(); break; case WeaponMount.Doors: slider = transform.Find("DoorSlider").GetComponent <Slider>(); break; default: slider = transform.Find("WheelSlider").GetComponent <Slider>(); break; } float newPosition = GarageSlider.SliderPosition(GarageStats.minDamage, GarageStats.maxDamage, damage); if (newPosition > slider.value + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newPosition < slider.value + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = newPosition; }
private void HitSomething(RaycastHit hitInfo, WeaponMount weaponMount) { if (weaponMount.Weapon.Projectile != null) { InstantiateProjectile(weaponMount, (hitInfo.point - weaponMount.FirePosition.position).normalized); } else { Health health = hitInfo.transform.GetComponent <Health>(); if (health != null) { health.TakeDamage(weaponMount.Weapon.Damage, _player.gameObject, weaponMount.Weapon.DamageParticleType); } else { GlassBreaker glassBreaker = hitInfo.transform.GetComponent <GlassBreaker>(); if (glassBreaker != null) { glassBreaker.BreakerGlass(); } else { Rigidbody rigidbody = hitInfo.transform.GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.AddForce(_player.transform.forward * weaponMount.Weapon.PushForce); } else { GameObject tmp = Instantiate(weaponMount.Weapon.BulletHole, hitInfo.point + hitInfo.normal * .01f, Quaternion.identity); tmp.transform.forward = -hitInfo.normal; tmp.transform.parent = hitInfo.transform; } } } } }
public void ReloadAnimationEvent() { WeaponMount weaponMount = _player.PlayerWeapons.EquippedWeaponMount; int needed = weaponMount.Weapon.MaxMagazineAmmo - weaponMount.MagazineAmmo; int toAdd = 0; if (weaponMount.Ammo > needed) { weaponMount.Ammo -= needed; toAdd = needed; } else { toAdd = weaponMount.Ammo; weaponMount.Ammo = 0; } weaponMount.MagazineAmmo += toAdd; // Refrech ammuniation decoration _player.PlayerWeapons.RefreshAmmunationDecoration(_player.PlayerWeapons.EquippedWeaponMount); }
private void cmdOK_Click(object sender, EventArgs e) { //TODO: THIS IS UGLY AS SHIT, FIX BETTER string strSelectedMount = cboSize.SelectedValue?.ToString(); if (string.IsNullOrEmpty(strSelectedMount)) { return; } string strSelectedControl = cboControl.SelectedValue?.ToString(); if (string.IsNullOrEmpty(strSelectedControl)) { return; } string strSelectedFlexibility = cboFlexibility.SelectedValue?.ToString(); if (string.IsNullOrEmpty(strSelectedFlexibility)) { return; } string strSelectedVisibility = cboVisibility.SelectedValue?.ToString(); if (string.IsNullOrEmpty(strSelectedVisibility)) { return; } XmlNode xmlSelectedMount = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + strSelectedMount + "\"]"); if (xmlSelectedMount == null) { return; } XmlNode xmlSelectedControl = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + strSelectedControl + "\"]"); if (xmlSelectedControl == null) { return; } XmlNode xmlSelectedFlexibility = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + strSelectedFlexibility + "\"]"); if (xmlSelectedFlexibility == null) { return; } XmlNode xmlSelectedVisibility = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + strSelectedVisibility + "\"]"); if (xmlSelectedVisibility == null) { return; } XmlNode xmlForbiddenNode = xmlSelectedMount["forbidden"]; if (xmlForbiddenNode != null) { string strStringToCheck = xmlSelectedControl["name"]?.InnerText; if (!string.IsNullOrEmpty(strStringToCheck)) { using (XmlNodeList xmlControlNodeList = xmlForbiddenNode.SelectNodes("control")) if (xmlControlNodeList?.Count > 0) { foreach (XmlNode xmlLoopNode in xmlControlNodeList) { if (xmlLoopNode.InnerText == strStringToCheck) { return; } } } } strStringToCheck = xmlSelectedFlexibility["name"]?.InnerText; if (!string.IsNullOrEmpty(strStringToCheck)) { using (XmlNodeList xmlFlexibilityNodeList = xmlForbiddenNode.SelectNodes("flexibility")) if (xmlFlexibilityNodeList?.Count > 0) { foreach (XmlNode xmlLoopNode in xmlFlexibilityNodeList) { if (xmlLoopNode.InnerText == strStringToCheck) { return; } } } } strStringToCheck = xmlSelectedVisibility["name"]?.InnerText; if (!string.IsNullOrEmpty(strStringToCheck)) { using (XmlNodeList xmlVisibilityNodeList = xmlForbiddenNode.SelectNodes("visibility")) if (xmlVisibilityNodeList?.Count > 0) { foreach (XmlNode xmlLoopNode in xmlVisibilityNodeList) { if (xmlLoopNode.InnerText == strStringToCheck) { return; } } } } } XmlNode xmlRequiredNode = xmlSelectedMount["required"]; if (xmlRequiredNode != null) { bool blnRequirementsMet = true; string strStringToCheck = xmlSelectedControl["name"]?.InnerText; if (!string.IsNullOrEmpty(strStringToCheck)) { using (XmlNodeList xmlControlNodeList = xmlRequiredNode.SelectNodes("control")) if (xmlControlNodeList?.Count > 0) { foreach (XmlNode xmlLoopNode in xmlControlNodeList) { blnRequirementsMet = false; if (xmlLoopNode.InnerText == strStringToCheck) { blnRequirementsMet = true; break; } } } } if (!blnRequirementsMet) { return; } strStringToCheck = xmlSelectedFlexibility["name"]?.InnerText; if (!string.IsNullOrEmpty(strStringToCheck)) { using (XmlNodeList xmlFlexibilityNodeList = xmlRequiredNode.SelectNodes("flexibility")) if (xmlFlexibilityNodeList?.Count > 0) { foreach (XmlNode xmlLoopNode in xmlFlexibilityNodeList) { blnRequirementsMet = false; if (xmlLoopNode.InnerText == strStringToCheck) { blnRequirementsMet = true; break; } } } } if (!blnRequirementsMet) { return; } strStringToCheck = xmlSelectedVisibility["name"]?.InnerText; if (!string.IsNullOrEmpty(strStringToCheck)) { using (XmlNodeList xmlVisibilityNodeList = xmlRequiredNode.SelectNodes("visibility")) if (xmlVisibilityNodeList?.Count > 0) { foreach (XmlNode xmlLoopNode in xmlVisibilityNodeList) { blnRequirementsMet = false; if (xmlLoopNode.InnerText == strStringToCheck) { blnRequirementsMet = true; break; } } } } if (!blnRequirementsMet) { return; } } if (_objMount == null) { _objMount = new WeaponMount(_objCharacter, _objVehicle); _objMount.Create(xmlSelectedMount); } else if (_objMount.SourceId != strSelectedMount) { _objMount.Create(xmlSelectedMount); } WeaponMountOption objControlOption = new WeaponMountOption(_objCharacter); WeaponMountOption objFlexibilityOption = new WeaponMountOption(_objCharacter); WeaponMountOption objVisibilityOption = new WeaponMountOption(_objCharacter); if (objControlOption.Create(xmlSelectedControl) && objFlexibilityOption.Create(xmlSelectedFlexibility) && objVisibilityOption.Create(xmlSelectedVisibility)) { _objMount.WeaponMountOptions.Clear(); _objMount.WeaponMountOptions.Add(objControlOption); _objMount.WeaponMountOptions.Add(objFlexibilityOption); _objMount.WeaponMountOptions.Add(objVisibilityOption); } _objMount.Mods.Clear(); foreach (VehicleMod objMod in _lstMods) { objMod.WeaponMountParent = _objMount; _objMount.Mods.Add(objMod); } DialogResult = DialogResult.OK; }
private void cmdOK_Click(object sender, EventArgs e) { TreeNode tree = new TreeNode(); //TODO: THIS IS UGLY AS SHIT, FIX BETTER XmlNode node = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + cboSize.SelectedValue + "\"]"); if (node["forbidden"] != null) { XmlNodeList list = node.SelectNodes("/forbidden/control"); XmlNode check = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + cboControl.SelectedValue + "\"]"); if (list.Cast <XmlNode>().Any(n => n.InnerText == check["name"].InnerText)) { return; } list = node.SelectNodes("/forbidden/flexibility"); check = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + cboFlexibility.SelectedValue + "\"]"); if (list.Cast <XmlNode>().Any(n => n.InnerText == check["name"].InnerText)) { return; } list = node.SelectNodes("/forbidden/visibility"); check = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + cboVisibility.SelectedValue + "\"]"); if (list.Cast <XmlNode>().Any(n => n.InnerText == check["name"].InnerText)) { return; } } if (node["required"] != null) { bool requirementsMet = true; XmlNodeList list = node.SelectNodes("/required/control"); XmlNode check = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + cboControl.SelectedValue + "\"]"); if (list.Count > 0) { requirementsMet = requirementsMet && list.Cast <XmlNode>().Any(n => n.InnerText == check["name"].InnerText); if (!requirementsMet) { return; } } list = node.SelectNodes("/required/flexibility"); if (list.Count > 0) { check = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + cboFlexibility.SelectedValue + "\"]"); requirementsMet = requirementsMet && list.Cast <XmlNode>().Any(n => n.InnerText == check["name"].InnerText); if (!requirementsMet) { return; } } list = node.SelectNodes("/required/visibility"); if (list.Count > 0) { check = _xmlDoc.SelectSingleNode("/chummer/weaponmounts/weaponmount[id = \"" + cboVisibility.SelectedValue + "\"]"); requirementsMet = requirementsMet && list.Cast <XmlNode>().Any(n => n.InnerText == check["name"].InnerText); if (!requirementsMet) { return; } } } WeaponMount mount = new WeaponMount(_objCharacter, _vehicle); mount.Create(node, tree, _vehicle); WeaponMountOption option = new WeaponMountOption(_objCharacter); option.Create(cboControl.SelectedValue.ToString(), mount.WeaponMountOptions); option = new WeaponMountOption(_objCharacter); option.Create(cboFlexibility.SelectedValue.ToString(), mount.WeaponMountOptions); option = new WeaponMountOption(_objCharacter); option.Create(cboVisibility.SelectedValue.ToString(), mount.WeaponMountOptions); WeaponMount = mount; tree.Text = mount.DisplayName(GlobalOptions.Language); DialogResult = DialogResult.OK; }
void Awake() { _mount = GetComponentInChildren <WeaponMount>(); }
public void SetMissleWeaponDirection(int hardpointIndex, float direction) { WeaponMount mount = FindWeaponMount(HardpointTypes.Tube, hardpointIndex); mount.DefaultFacing = direction; }
private void InstantiateProjectile(WeaponMount weaponMount, Vector3 direction) { Projectile projectileTmp = Instantiate(weaponMount.Weapon.Projectile, weaponMount.FirePosition.position, Quaternion.identity); projectileTmp.Initialize(gameObject, direction); }
public virtual void Fire(WeaponMount weaponMount) { // We can't fire when we are taking a hit if (_player.TakingHit) { return; } if (weaponMount.MuzzleFlash != null) { weaponMount.MuzzleFlash.gameObject.SetActive(true); weaponMount.MuzzleFlash.Play(); } Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 1)); RaycastHit[] hitInfos = Physics.RaycastAll(ray, weaponMount.Weapon.Range, _layerMask); int closestHitIndex = -1; if (hitInfos.Length > 0) { for (int i = 0; i < hitInfos.Length; i++) { RaycastHit hitInfo = hitInfos[i]; // We make sure we don't hit something behind us if (Vector3.Angle(hitInfo.transform.position - _player.transform.position, _player.transform.forward) > 180) { continue; } if (closestHitIndex == -1) { closestHitIndex = i; } else { float thisDistance = (hitInfo.point - transform.position).magnitude; float closestDistance = (hitInfos[closestHitIndex].point - transform.position).magnitude; if (thisDistance < closestDistance) { closestHitIndex = i; } } } if (closestHitIndex != -1) { RaycastHit hitInfo = hitInfos[closestHitIndex]; HitSomething(hitInfo, weaponMount); } } // If we didn't hit anything but the weapon uses a projectile, we still want to instantiate the projectile if (closestHitIndex == -1 && weaponMount.Weapon.Projectile != null) { InstantiateProjectile(weaponMount, Camera.main.transform.forward); } GameManager.Instance.AudioManager.PlayOneShotSound(weaponMount.Weapon.FireSound, 1, 0, 1, transform.position); weaponMount.MagazineAmmo -= 1; // We don't want to reload when we have a bow equipped because the bow is automatically going to reload after playing the fire animation (for smoother movements of the player) if (weaponMount.MagazineAmmo == 0 && weaponMount.Ammo > 0 && !_player.PlayerWeaponsAnimator.PreparedBow) { _player.PlayerWeaponsAnimator.Reload(); } }