//获取当前武器上的属性脚本
 public GunAtt GetCurrentWeaponScript()
 {
     if (CurrentWeapon)
     {
         return(CurrentWeapon.GetComponent <GunAtt>());
     }
     return(null);
 }
Exemple #2
0
 // Equip the weapon we Specify
 public void EquipWeapon(Weapon weapon, Transform weaponPosition)
 {
     CurrentWeapon = Instantiate(weapon, weaponPosition.position, weaponPosition.rotation);
     CurrentWeapon.transform.parent = weaponPosition;
     CurrentWeapon.SetOwner(character);
     WeaponAim = CurrentWeapon.GetComponent <WeaponAim>();
     UpdateWeaponUI();
 }
Exemple #3
0
    public void EquipWeapon(Weapon weapon, Transform weaponPosition)
    {
        CurrentWeapon = Instantiate(weapon, weaponPosition.position, weaponPosition.rotation);
        CurrentWeapon.transform.parent = weaponPosition;
        CurrentWeapon.SetOwner(character);
        weaponAim = CurrentWeapon.GetComponent <WeaponAim>();

        if (character.CharacterType == Character.CharacterTypes.Player)
        {
            UIManager.Instance.UpdateAmmo(CurrentWeapon.CurrentAmmo, CurrentWeapon.MagazineSize);
        }
    }
Exemple #4
0
    // Unholsters Weapon
    public void UnholsterWeapon()
    {
        BoneFollower    follower = CurrentWeapon.GetComponent <BoneFollower>();
        WeaponBehaviour weapon   = CurrentWeapon;
        string          handBone = bFacingLeft ? sWeaponRearHandBone: sWeaponFrontHandBone;

        weapon.bHolstered = false;
        follower.boneName = handBone;
        follower.HandleRebuildRenderer(follower.SkeletonRenderer);

        bHoldingWeapon = true;
    }
Exemple #5
0
    // Holsters Weapon
    public void HolsterWeapon(int index = -1, bool instantSwitch = false)
    {
        if (!bHoldingWeapon)
        {
            return;
        }

        BoneFollower    follower    = CurrentWeapon.GetComponent <BoneFollower>();
        WeaponBehaviour weapon      = CurrentWeapon;
        string          holsterBone = weapon.HoldType == eWeaponHoldType.Secondary
                        ? sSecondaryWeaponHolsterBone : sPrimaryWeaponHolsterBone;

        weapon.bHolstered = true;
        follower.boneName = holsterBone;
        follower.HandleRebuildRenderer(follower.SkeletonRenderer);
        weapon.HandleVisualOffset();

        if (index == -1)
        {
            // Move to the next weapon index
            if (iCurrentWeaponIndex == lWeapons.Count - 1)
            {
                iCurrentWeaponIndex = 0;
            }
            else
            {
                iCurrentWeaponIndex++;
            }
        }
        else
        {
            index = Mathf.Clamp(index, 0, lWeapons.Count - 1);
            iCurrentWeaponIndex = index;
        }

        if (aOnWeaponSwitch != null)
        {
            aOnWeaponSwitch(iCurrentWeaponIndex, instantSwitch);
        }

        // Setup new current weapon
        weapon = CurrentWeapon;
        weapon.EndCooldownTimers();

        bHoldingWeapon = false;
    }
Exemple #6
0
    /// <summary>
    ///
    /// </summary>
    public void ActivateWeapon(int index)
    {
        m_CurrentWeaponIndex = index;
        m_CurrentWeapon      = null;
        if (m_CurrentWeaponIndex > 0)
        {
            m_CurrentWeapon = Weapons[m_CurrentWeaponIndex - 1];
            if (m_CurrentWeapon != null)
            {
                m_CurrentWeapon.ActivateGameObject(true);
            }
        }

        if (m_CurrentWeapon != null)
        {
            m_CurrentShooter = CurrentWeapon.GetComponent <vp_Shooter>();
        }
    }
Exemple #7
0
    // Switches the weapon hand transform for the currently held weapon
    public IEnumerator SwitchWeaponHand()
    {
        // If no weapons are in the weapon list, return
        if (lWeapons.Count <= 0)
        {
            yield break;
        }

        if (!Application.isEditor)
        {
            yield return(new WaitForEndOfFrame());
        }

        // Bone Follower
        BoneFollower follower = CurrentWeapon.GetComponent <BoneFollower>();
        // Weapon Hand Transform
        string handBone = bFacingLeft ? sWeaponRearHandBone : sWeaponFrontHandBone;

        follower.SetBone(handBone);
    }
Exemple #8
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.WeaponID = weaponID;
                _weaponAim             = CurrentWeapon.GetComponent <WeaponAim>();

                // we turn off the gun's emitters.
                CurrentWeapon.Initialization();
                CurrentWeapon.InitializeComboWeapons();
                CurrentWeapon.InitializeAnimatorParameters();
            }
            else
            {
                CurrentWeapon = null;
            }
        }