コード例 #1
0
        /// <summary>
        /// Drops the current Weapon into the scene
        /// </summary>
        public IEnumerator DropCurrentWeapon()
        {
            _switchingWeapons = true;
            if (LogDebug)
            {
                Debug.Log("Dropping current weapon in slot " + _currentWeapon);
            }
            if (GetCurrentWeaponGo() == null || GetCurrentWeaponComponent().PickupReference == null)
            {
                Debug.Log("Either there is no weapon equippped or the weapon doesn't have a Pickup Reference defined.");
                _switchingWeapons = false;
                yield break;
            }
            StaticUtil.SpawnLoot(WeaponListRuntime[_currentWeapon].GetComponent <Weapon>().PickupReference, transform.position);

            GameObject droppingThis = WeaponListRuntime[_currentWeapon];

            WeaponListRuntime.RemoveAt(_currentWeapon);
            if (WeaponListRuntime.Count == _currentWeapon)
            {
                _currentWeapon -= 1;
            }

            yield return(StartCoroutine(ChangeWeaponToSlot(_currentWeapon)));

            _switchingWeapons = true;

            StaticUtil.DeSpawn(droppingThis);
            while (_myControls.GetInputDropWeapon)
            {
                yield return(null);
            }
            _switchingWeapons = false;
        }