Example #1
0
        /// <summary>
        /// On Start(), we set our tunnel flag to false
        /// </summary>
        protected override void Initialization()
        {
            base.Initialization();

            if (ObjectToRotate != null)
            {
                _model = ObjectToRotate;
            }
            else
            {
                _model = _character.CharacterModel;
            }

            _handleWeapon = GetComponent <CharacterHandleWeapon> ();
            if (_handleWeapon != null)
            {
                if (_handleWeapon.CurrentWeapon != null)
                {
                    _weaponAim = _handleWeapon.CurrentWeapon.GetComponent <WeaponAim> ();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Changes the character's current weapon to the one passed as a parameter
        /// </summary>
        /// <param name="newWeapon">The new weapon.</param>
        public virtual void ChangeWeapon(Weapon newWeapon, string weaponID)
        {
            // if the character already has a weapon, we make it stop shooting
            if (CurrentWeapon != null)
            {
                ShootStop();
                Destroy(CurrentWeapon.gameObject);
            }

            if (newWeapon != null)
            {
                CurrentWeapon = (Weapon)Instantiate(newWeapon, WeaponAttachment.transform.position + newWeapon.WeaponAttachmentOffset, WeaponAttachment.transform.rotation);
                CurrentWeapon.transform.parent = WeaponAttachment.transform;
                CurrentWeapon.SetOwnerEMP(_character, this);
                CurrentWeapon.WeaponID = weaponID;
                _aimableWeapon         = CurrentWeapon.GetComponent <WeaponAim>();
                // we handle (optional) inverse kinematics (IK)
                if (_weaponIK != null)
                {
                    _weaponIK.SetHandles(CurrentWeapon.LeftHandHandle, CurrentWeapon.RightHandHandle);
                }
                // we turn off the gun's emitters.
                CurrentWeapon.Initialization();
                //InitializeAnimatorParameters();
                if (!_character.IsFacingRight)
                {
                    if (CurrentWeapon != null)
                    {
                        CurrentWeapon.FlipWeapon();
                        CurrentWeapon.FlipWeaponModel();
                    }
                }
            }
            else
            {
                CurrentWeapon = null;
            }
        }
Example #3
0
        /// <summary>
        /// Changes the character's current weapon to the one passed as a parameter
        /// </summary>
        /// <param name="newWeapon">The new weapon.</param>
        public virtual void ChangeWeapon(Weapon newWeapon, string weaponID, bool combo = false)
        {
            // if the character already has a weapon, we make it stop shooting
            if (CurrentWeapon != null)
            {
                if (!combo)
                {
                    ShootStop();

                    AnimatorControllerParameter[] parameters = _character._animator.parameters;
                    foreach (AnimatorControllerParameter parameter in parameters)
                    {
                        if (parameter.name == CurrentWeapon.EquippedAnimationParameter)
                        {
                            MMAnimatorExtensions.UpdateAnimatorBool(_animator, CurrentWeapon.EquippedAnimationParameter, false);
                        }
                    }

                    Destroy(CurrentWeapon.gameObject);
                }
            }

            if (newWeapon != null)
            {
                if (!combo)
                {
                    CurrentWeapon = (Weapon)Instantiate(newWeapon, WeaponAttachment.transform.position + newWeapon.WeaponAttachmentOffset, Quaternion.identity);
                }
                CurrentWeapon.transform.SetParent(WeaponAttachment.transform);
                if (ForceWeaponScaleResetOnEquip)
                {
                    CurrentWeapon.transform.localScale = Vector3.one;
                }
                CurrentWeapon.SetOwner(_character, this);
                CurrentWeapon.WeaponID = weaponID;
                _aimableWeapon         = CurrentWeapon.GetComponent <WeaponAim> ();
                // we handle (optional) inverse kinematics (IK)
                if (_weaponIK != null)
                {
                    _weaponIK.SetHandles(CurrentWeapon.LeftHandHandle, CurrentWeapon.RightHandHandle);
                }
                // we turn off the gun's emitters.
                CurrentWeapon.Initialization();
                CurrentWeapon.InitializeComboWeapons();
                CurrentWeapon.InitializeAnimatorParameters();
                InitializeAnimatorParameters();
                if ((_character != null) && !combo)
                {
                    if (!_character.IsFacingRight)
                    {
                        if (CurrentWeapon != null)
                        {
                            CurrentWeapon.FlipWeapon();
                            CurrentWeapon.FlipWeaponModel();
                        }
                    }
                }
            }
            else
            {
                CurrentWeapon = null;
            }
        }