Example #1
0
 /// <summary>
 /// When entering the state we reset our shoot counter and grab our weapon
 /// </summary>
 public override void OnEnterState()
 {
     base.OnEnterState();
     _numberOfShoots   = 0;
     _shooting         = true;
     _weaponAim        = _characterHandleWeapon.CurrentWeapon.gameObject.MMGetComponentNoAlloc <WeaponAim>();
     _projectileWeapon = _characterHandleWeapon.CurrentWeapon.gameObject.MMGetComponentNoAlloc <ProjectileWeapon>();
 }
Example #2
0
 protected virtual void HandleWeaponIK()
 {
     if (_weaponIK != null)
     {
         _weaponIK.SetHandles(CurrentWeapon.LeftHandHandle, CurrentWeapon.RightHandHandle);
     }
     _projectileWeapon = CurrentWeapon.gameObject.MMFGetComponentNoAlloc <ProjectileWeapon>();
     if (_projectileWeapon != null)
     {
         _projectileWeapon.SetProjectileSpawnTransform(ProjectileSpawn);
     }
 }
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();
                    if (_weaponAim != null)
                    {
                        _weaponAim.RemoveReticle();
                    }
                    Destroy(CurrentWeapon.gameObject);
                }
            }

            if (newWeapon != null)
            {
                if (!combo)
                {
                    CurrentWeapon = (Weapon)Instantiate(newWeapon, WeaponAttachment.transform.position + newWeapon.WeaponAttachmentOffset, WeaponAttachment.transform.rotation);
                }
                CurrentWeapon.transform.parent        = WeaponAttachment.transform;
                CurrentWeapon.transform.localPosition = newWeapon.WeaponAttachmentOffset;
                CurrentWeapon.SetOwner(_character, this);
                CurrentWeapon.WeaponID = weaponID;
                _weaponAim             = CurrentWeapon.gameObject.MMGetComponentNoAlloc <WeaponAim>();
                // we handle (optional) inverse kinematics (IK)
                if (_weaponIK != null)
                {
                    _weaponIK.SetHandles(CurrentWeapon.LeftHandHandle, CurrentWeapon.RightHandHandle);
                }
                _projectileWeapon = CurrentWeapon.gameObject.MMFGetComponentNoAlloc <ProjectileWeapon>();
                if (_projectileWeapon != null)
                {
                    _projectileWeapon.SetProjectileSpawnTransform(ProjectileSpawn);
                }
                // we turn off the gun's emitters.
                CurrentWeapon.Initialization();
                CurrentWeapon.InitializeComboWeapons();
                CurrentWeapon.InitializeAnimatorParameters();
                InitializeAnimatorParameters();
            }
            else
            {
                CurrentWeapon = null;
            }
        }