示例#1
0
        /// <summary>
        /// When one of the weapons has ended its attack, we start our countdown and switch to the next weapon
        /// </summary>
        /// <param name="weaponThatStopped"></param>
        public virtual void WeaponStopped(Weapon weaponThatStopped)
        {
            OwnerCharacterHandleWeapon = Weapons[_currentWeaponIndex].CharacterHandleWeapon;

            int newIndex = 0;

            if (OwnerCharacterHandleWeapon != null)
            {
                if (Weapons.Length > 1)
                {
                    if (_currentWeaponIndex < Weapons.Length - 1)
                    {
                        newIndex = _currentWeaponIndex + 1;
                    }
                    else
                    {
                        newIndex = 0;
                    }

                    _countdownActive           = true;
                    TimeSinceLastWeaponStopped = 0f;

                    _currentWeaponIndex = newIndex;
                    OwnerCharacterHandleWeapon.CurrentWeapon = Weapons[newIndex];
                    OwnerCharacterHandleWeapon.ChangeWeapon(Weapons[newIndex], Weapons[newIndex].WeaponID, true);
                }
            }
        }
        /// <summary>
        /// Grabs the CharacterHandleWeapon component and sets the weapon
        /// </summary>
        /// <param name="newWeapon">New weapon.</param>
        protected virtual void EquipWeapon(Weapon newWeapon)
        {
            if (EquippableWeapon == null)
            {
                return;
            }
            if (TargetInventory.Owner == null)
            {
                return;
            }

            Character character = TargetInventory.Owner.GetComponent <Character>();

            if (character == null)
            {
                return;
            }

            // we equip the weapon to the chosen CharacterHandleWeapon
            CharacterHandleWeapon targetHandleWeapon = null;

            CharacterHandleWeapon[] handleWeapons = character.GetComponentsInChildren <CharacterHandleWeapon>();
            foreach (CharacterHandleWeapon handleWeapon in handleWeapons)
            {
                if (handleWeapon.HandleWeaponID == HandleWeaponID)
                {
                    targetHandleWeapon = handleWeapon;
                }
            }

            if (targetHandleWeapon != null)
            {
                targetHandleWeapon.ChangeWeapon(newWeapon, this.ItemID);
            }
        }
 /// <summary>
 /// Performs the weapon change
 /// </summary>
 protected virtual void ChangeWeapon()
 {
     if (_change < 1)
     {
         _characterHandleWeapon.ChangeWeapon(NewWeapon, NewWeapon.name);
         _change++;
     }
 }
示例#4
0
        /// <summary>
        /// What happens when the weapon gets picked
        /// </summary>
        protected override void Pick()
        {
            CharacterHandleWeapon characterShoot = _collider.GetComponent <CharacterHandleWeapon>();

            characterShoot.ChangeWeapon(WeaponToGive, null);
            if (characterShoot != null)
            {
                if (characterShoot.CanPickupWeapons)
                {
                }
            }
        }
        /// <summary>
        /// Grabs the CharacterHandleWeapon component and sets the weapon
        /// </summary>
        /// <param name="newWeapon">New weapon.</param>
        protected virtual void EquipWeapon(Weapon newWeapon)
        {
            if (EquippableWeapon == null)
            {
                return;
            }
            if (TargetInventory.Owner == null)
            {
                return;
            }
            CharacterHandleWeapon characterHandleWeapon = TargetInventory.Owner.GetComponent <CharacterHandleWeapon>();

            if (characterHandleWeapon != null)
            {
                characterHandleWeapon.ChangeWeapon(newWeapon, this.ItemID);
            }
        }
示例#6
0
        /// <summary>
        /// Resets the combo if enough time has passed since the last attack
        /// </summary>
        protected virtual void ResetCombo()
        {
            if (Weapons.Length > 1)
            {
                if (_countdownActive && DroppableCombo)
                {
                    TimeSinceLastWeaponStopped += Time.deltaTime;
                    if (TimeSinceLastWeaponStopped > DropComboDelay)
                    {
                        _countdownActive = false;

                        _currentWeaponIndex = 0;
                        OwnerCharacterHandleWeapon.CurrentWeapon = Weapons[_currentWeaponIndex];
                        OwnerCharacterHandleWeapon.ChangeWeapon(Weapons[_currentWeaponIndex], Weapons[_currentWeaponIndex].WeaponID, true);
                    }
                }
            }
        }