예제 #1
0
        private void OnAttackButtonPress(GameObject go, bool state)
        {
            _attackButtonPressed = false;

            if (_currentWeapon != null)
            {
                if (_currentWeapon.Item is Bow)
                {
                    if (_bowController == null)
                    {
                        _bowController = WeaponHandler.CurrentWeapon.GetComponentInChildren <BowController>();
                        _bowController.Init(_gameManager);
                    }

                    bool hasArrow = _gameManager.PlayerModel.Inventory.GetAmount(typeof(Arrow)) > 0;

                    if (hasArrow)
                    {
                        if (state)
                        {
                            _bowController.TetevenPull();
                        }
                        else if (_bowController.CurrentState == BowState.Ready)
                        {
                            _bowController.Shoot(FpsCamera);
                            _gameManager.PlayerModel.Inventory.UseItem(_gameManager, (typeof(Arrow)));
                        }
                        else
                        {
                            _bowController.TetevenWeaken();
                        }
                    }
                }
                else if (_currentWeapon.Item is Shovel)
                {
                    _shovelController    = WeaponHandler.CurrentWeapon.GetComponentInChildren <ShovelController>();
                    _attackButtonPressed = state;
                }
                else if (_currentWeapon.Item is Fishrod)
                {
                    _fishrodController   = WeaponHandler.CurrentWeapon.GetComponentInChildren <FishrodController>();
                    _attackButtonPressed = state;
                }
                else if ((_currentWeapon.Item as Weapon).WeaponType == WeaponType.Melee)
                {
                    _attackButtonPressed = state;
                }
            }
        }
예제 #2
0
        private IEnumerator ShovelUse()
        {
            _attacked = true;

            yield return(new WaitForSeconds(_currentWeapon.Item.AttackFirstHalfTime));

            _shovelController.Mine(_gameManager);

            MainHud.InventoryPanel.QuickSlotsPanel.CurrentSlot.ItemModel.ChangeDurability(1);
            if (MainHud.InventoryPanel.QuickSlotsPanel.CurrentSlot.ItemModel == null)
            {
                SetEmptyHand();
                _shovelController = null;
                SoundManager.PlaySFX(WorldConsts.AudioConsts.BreakWeapon);
            }

            if (_currentWeapon != null)
            {
                yield return(new WaitForSeconds(_currentWeapon.Item.AttackSeconfHalfTime));
            }
            _attacked = false;
        }