Пример #1
0
        /// <summary>Equip Weapon from holster or from Inventory  (Called by the Animator)</summary>
        public virtual void Equip_Weapon()
        {
            if (!Active)
            {
                return;
            }
            //if (Weapon.gameObject.IsPrefab()) return;   //Means the Weapon is a prefab and is not instantiated yet (MAKE A WAIT COROYTINE)

            WeaponAction = WA.Idle;                                             //Set the Action to Equip
            CombatMode   = true;

            if (Weapon == null)
            {
                return;
            }

            if (debug)
            {
                Debug.Log($"<B>{name}:<color=yellow> [Equip -> {Weapon.name}]</color></b> T{Time.time:F3}");
            }

            Weapon.PrepareWeapon(this);

            if (UseHolsters)                                                             //If Use holster Means that the weapons are on the holster
            {
                ParentWeapon();
                StartCoroutine(MTools.AlignTransformLocal(Weapon.transform, Weapon.PositionOffset, Weapon.RotationOffset, Vector3.one, HolsterTime)); //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
                {
                    ParentWeapon();

                    Weapon.transform.localPosition    = Weapon.PositionOffset; //Set the Correct Position
                    Weapon.transform.localEulerAngles = Weapon.RotationOffset; //Set the Correct Rotation
                    Weapon.transform.localScale       = Vector3.one;           //Set the Correct Rotation
                }
                Weapon.gameObject.SetActive(true);                             //Set the Game Object Instance Active
            }

            OnEquipWeapon.Invoke(Weapon.gameObject); //Let everybody know that the weapon is equipped

            Weapon.PlaySound(WSound.Equip);          //Play Equip Sound
        }