/// <summary>Equip Weapon from Holders or from Inventory (Called by the Animator)</summary> public virtual void Equip_Weapon() { //WeaponAction = WA.Equip; //Set the Action to Equip WeaponAction = WA.Idle; //Set the Action to Equip CombatMode = true; if (ActiveWeapon == null) { return; } if (debug) { Debug.Log($"Equip Weapon Type: <b> {ActiveWeapon.WeaponType.name}</b>"); } ActiveWeapon.HitLayer = Aimer.AimLayer; //Update the Hit Mask on the Weapon ActiveWeapon.TriggerInteraction = Aimer.TriggerInteraction; //Update the Trigger Interatction on the Weapon if (UseHolders) //If Use Holders Means that the weapons are on the Holders { if (ActiveHolderTransform.transform.childCount > 0) //If there's a Weapon on the Holder { ActiveWeaponGameObject = ActiveHolderTransform.GetChild(0).gameObject; //Set the Active Weapon as the First Child Inside the Holder ActiveWeaponGameObject.transform.parent = ActiveWeapon.RightHand ? RightHandEquipPoint : LeftHandEquipPoint; //Parent the Active Weapon to the Right/Left Hand ActiveWeapon.Holder = ActiveHolderSide; StartCoroutine(SmoothWeaponTransition (ActiveWeaponGameObject.transform, ActiveWeapon.PositionOffset, ActiveWeapon.RotationOffset, 0.3f)); //Smoothly put the weapon in the hand } } else if (UseInventory) //If Use Inventory means that the weapons are on the inventory { if (!AlreadyInstantiated) //Do this if the Instantiation is not handled Externally { ActiveWeaponGameObject.transform.parent = ActiveWeapon.RightHand ? RightHandEquipPoint : LeftHandEquipPoint; //Parent the Active Weapon to the Right/Left Hand ActiveWeaponGameObject.transform.localPosition = ActiveWeapon.PositionOffset; //Set the Correct Position ActiveWeaponGameObject.transform.localEulerAngles = ActiveWeapon.RotationOffset; //Set the Correct Rotation } ActiveWeaponGameObject.gameObject.SetActive(true); //Set the Game Object Instance Active } ActiveWeapon.Owner = transform; ActiveWeapon.IsEquiped = true; //Inform the weapon that it has been equipped OnEquipWeapon.Invoke(ActiveWeaponGameObject); //Let everybody know that the weapon is equipped if (ActiveAbility) { ActiveAbility.ActivateAbility(); //Call For the first activation of the weapon when first Equipped } }
///────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── /// <summary> /// Draw (Set the Correct Parameters to play Draw Weapon Animation) /// </summary> public virtual void Draw_Weapon() { EnableMountAttack(false); //Disable Attack Animations of the Animal ResetRiderCombat(); if (UseInventory) //If is using inventory { if (Active_IMWeapon != null) { SetActiveHolder(Active_IMWeapon.Holder); //Set the Current Holder to the weapon asigned holder } } else //if Use Holders { if (ActiveHolderTransform.childCount == 0) { return; } IMWeapon isCombatible = ActiveHolderTransform.GetChild(0).GetComponent <IMWeapon>(); //Check if the Child on the holder Has a IMWeapon on it if (isCombatible == null) { return; } SetActiveWeapon(ActiveHolderTransform.GetChild(0).gameObject); //Set Active Weapon to the Active Holder Child } _weaponType = GetWeaponType(); //Set the Weapon Type (For the correct Animations) SetAction(Active_IMWeapon.RightHand ? WeaponActions.DrawFromRight : WeaponActions.DrawFromLeft); //Set the Weapon Action to -1 to Draw Weapons From Right or from left -2 SetWeaponIdleAnimState(Active_IMWeapon.RightHand); ActiveAbility = CombatAbilities.Find(ability => ability.TypeOfAbility(Active_IMWeapon)); //Find the Ability for the IMWeapon LinkAnimator(); if (debug) { Debug.Log("Draw: " + ActiveWeapon.name); //Debug } }
/// <summary> Draw (Set the Correct Parameters to play Draw Weapon Animation) </summary> public virtual void Draw_Weapon() { ResetRiderCombat(); if (UseInventory) //If is using inventory { if (ActiveWeapon != null) { SetActiveHolder(ActiveWeapon.Holder); //Set the Current Holder to the weapon asigned holder } } else //if Use Holders { if (ActiveHolderTransform.childCount == 0) { return; } IMWeapon isCombatible = ActiveHolderTransform.GetChild(0).GetComponent <IMWeapon>(); //Check if the Child on the holder Has a IMWeapon on it if (isCombatible == null) { return; } ActiveWeaponGameObject = (ActiveHolderTransform.GetChild(0).gameObject); //Set Active Weapon to the Active Holder Child } WeaponType = GetWeaponType(); //Set the Weapon Type (For the correct Animations) WeaponAction = ActiveWeapon.RightHand ? WA.DrawFromRight : WA.DrawFromLeft; //Set the Weapon Action to -1 to Draw Weapons From Right or from left -2 SetWeaponIdleAnimState(ActiveWeapon.RightHand); SetActiveAbility(); if (debug) { Debug.Log($"Play Draw Animation with: <b>{ActiveWeaponGameObject?.name}</b>"); //Debug } }