/// <summary> /// Grabs the CharacterHandleWeapon component and sets the weapon /// </summary> /// <param name="newWeapon">New weapon.</param> protected virtual void EquipWeapon(Weapon newWeapon) { if (EquippableWeapon == null) { return; } if (TargetInventory.Owner == null) { return; } Character character = TargetInventory.Owner.GetComponent <Character>(); if (character == null) { return; } // we equip the weapon to the chosen CharacterHandleWeapon CharacterHandleWeapon targetHandleWeapon = null; CharacterHandleWeapon[] handleWeapons = character.GetComponentsInChildren <CharacterHandleWeapon>(); foreach (CharacterHandleWeapon handleWeapon in handleWeapons) { if (handleWeapon.HandleWeaponID == HandleWeaponID) { targetHandleWeapon = handleWeapon; } } if (targetHandleWeapon != null) { targetHandleWeapon.ChangeWeapon(newWeapon, this.ItemID); } }
/// <summary> /// When one of the weapons has ended its attack, we start our countdown and switch to the next weapon /// </summary> /// <param name="weaponThatStopped"></param> public virtual void WeaponStopped(Weapon weaponThatStopped) { OwnerCharacterHandleWeapon = Weapons[_currentWeaponIndex].CharacterHandleWeapon; int newIndex = 0; if (OwnerCharacterHandleWeapon != null) { if (Weapons.Length > 1) { if (_currentWeaponIndex < Weapons.Length - 1) { newIndex = _currentWeaponIndex + 1; } else { newIndex = 0; } _countdownActive = true; TimeSinceLastWeaponStopped = 0f; _currentWeaponIndex = newIndex; OwnerCharacterHandleWeapon.CurrentWeapon = Weapons[newIndex]; OwnerCharacterHandleWeapon.CurrentWeapon.WeaponCurrentlyActive = false; OwnerCharacterHandleWeapon.ChangeWeapon(Weapons[newIndex], Weapons[newIndex].WeaponID, true); OwnerCharacterHandleWeapon.CurrentWeapon.WeaponCurrentlyActive = true; } } }
/// <summary> /// What happens when the weapon gets picked /// </summary> protected override void Pick(GameObject picker) { Character character = _collidingObject.gameObject.MMGetComponentNoAlloc <Character>(); if (character == null) { return; } // we equip the weapon to the chosen CharacterHandleWeapon CharacterHandleWeapon targetHandleWeapon = null; CharacterHandleWeapon[] handleWeapons = character.GetComponentsInChildren <CharacterHandleWeapon>(); foreach (CharacterHandleWeapon handleWeapon in handleWeapons) { if (handleWeapon.HandleWeaponID == HandleWeaponID) { targetHandleWeapon = handleWeapon; } } if (targetHandleWeapon != null) { targetHandleWeapon.ChangeWeapon(WeaponToGive, null); } }
/// <summary> /// What happens when the weapon gets picked /// </summary> protected override void Pick(GameObject picker) { _handleWeapon = _collidingObject.gameObject.MMGetComponentNoAlloc <CharacterHandleWeapon>(); if (_handleWeapon != null) { if (_handleWeapon.CanPickupWeapons) { _handleWeapon.ChangeWeapon(WeaponToGive, null); } } }
/// <summary> /// Grabs the CharacterHandleWeapon component and sets the weapon /// </summary> /// <param name="newWeapon">New weapon.</param> protected virtual void EquipWeapon(Weapon newWeapon) { if (EquippableWeapon == null) { return; } if (TargetInventory.Owner == null) { return; } CharacterHandleWeapon characterHandleWeapon = TargetInventory.Owner.GetComponent <CharacterHandleWeapon>(); if (characterHandleWeapon != null) { characterHandleWeapon.ChangeWeapon(newWeapon, this.ItemID); } }
/// <summary> /// Resets the combo if enough time has passed since the last attack /// </summary> public virtual void ResetCombo() { if (Weapons.Length > 1) { if (_countdownActive && DroppableCombo) { TimeSinceLastWeaponStopped += Time.deltaTime; if (TimeSinceLastWeaponStopped > DropComboDelay) { _countdownActive = false; _currentWeaponIndex = 0; OwnerCharacterHandleWeapon.CurrentWeapon = Weapons[_currentWeaponIndex]; OwnerCharacterHandleWeapon.ChangeWeapon(Weapons[_currentWeaponIndex], Weapons[_currentWeaponIndex].WeaponID, true); } } } }