/// <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
            }
        }
Beispiel #2
0
        ///──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
        /// <summary>
        /// If the Rider had a weapon before mounting.. equip it.
        /// The weapon need an |IMWeapon| Interface, if not it wont be equiped
        /// </summary>
        public virtual void SetWeaponBeforeMounting(GameObject weapon)
        {
            if (weapon == null)
            {
                return;
            }
            if (weapon.GetComponent <IMWeapon>() == null)
            {
                return;                                                                                 //If the weapon doesn't have IMweapon Interface do nothing
            }
            /// Try the set to false the weapon if is not a Prefab ///

            SetActiveWeapon(weapon);

            isInCombatMode = true;

            Active_IMWeapon.Equiped();                                                                   //Let the weapon know that it has been Equiped

            EnableMountAttack(false);

            SetActiveHolder(Active_IMWeapon.Holder);                                                    //Set the Active Holder for the Active Weapon

            _weaponType = GetWeaponType();                                                              //Set the Weapon Type

            SetAction(WeaponActions.Idle);

            SetWeaponIdleAnimState(Active_IMWeapon.RightHand);                                          //Set the Correct Idle Hands Animations

            Active_IMWeapon.HitMask = HitMask;                                                          //Link the Hit Mask

            ActiveAbility = CombatAbilities.Find(ability => ability.WeaponType() == GetWeaponType());   //Find the Ability for the IMWeapon

            if (ActiveAbility)
            {
                ActiveAbility.ActivateAbility();
            }
            else
            {
                Debug.LogWarning("The Weapon is combatible but there's no Combat Ability available for it, please Add the matching ability it on the list of Combat Abilities");
            }

            OnEquipWeapon.Invoke(ActiveWeapon);

            LinkAnimator();
        }
        /// <summary>If the Rider had a weapon before mounting.. equip it.
        /// The weapon need an |IMWeapon| Interface, if not it wont be equiped</summary>
        public virtual void SetWeaponBeforeMounting(GameObject weapon)
        {
            if (weapon == null)
            {
                return;
            }
            if (weapon.GetComponent <IMWeapon>() == null)
            {
                return;                                                                                 //If the weapon doesn't have IMweapon Interface do nothing
            }
            /// Try the set to false the weapon if is not a Prefab ///

            ActiveWeaponGameObject = weapon;

            CombatMode = true;

            ActiveWeapon.Owner              = transform;
            ActiveWeapon.IsEquiped          = true;                                                   //Let the weapon know that it has been Equiped
            ActiveWeapon.HitLayer           = Aimer.AimLayer;                                         //Link the Hit Mask
            ActiveWeapon.TriggerInteraction = Aimer.TriggerInteraction;                               //Link the Trigger Interatction

            SetActiveHolder(ActiveWeapon.Holder);                                                     //Set the Active Holder for the Active Weapon

            WeaponType = GetWeaponType();                                                             //Set the Weapon Type

            WeaponAction = WA.Idle;

            SetWeaponIdleAnimState(ActiveWeapon.RightHand);                                           //Set the Correct Idle Hands Animations

            SetActiveAbility();

            if (ActiveAbility)
            {
                ActiveAbility.ActivateAbility();
            }
            else
            {
                Debug.LogError("The Weapon is combatible but there's no Combat Ability available for it, please Add the matching ability it on the list of Combat Abilities");
            }

            OnEquipWeapon.Invoke(ActiveWeaponGameObject);
        }