Esempio n. 1
0
        public void Init(GameManager gameManager, HolderObject itemModel, int slotId)
        {
            ItemModel    = itemModel;
            _gameManager = gameManager;
            SlotId       = slotId;
            UpdateView();

            if (ItemModel != null)
            {
                ItemModel.OnRemoved           += OnItemModelRemoved;
                ItemModel.OnAmountChanged     += OnAmountChanged;
                ItemModel.OnDurabilityChanged += OnDurabilityChanged;
            }
        }
Esempio n. 2
0
        public void SetEmptyHand()
        {
            if (_currentWeapon != null)
            {
                if (MainHud.InventoryPanel.QuickSlotsPanel.CurrentSlot != null)
                {
                    MainHud.InventoryPanel.QuickSlotsPanel.CurrentSlot.SelectUsable(false);
                    MainHud.InventoryPanel.QuickSlotsPanel.CurrentSlot = null;
                }
            }

            _currentWeapon = null;
            WeaponHandler.SetWeaponSmooth(0);
        }
Esempio n. 3
0
        private void OnDestHolderObjectRemoved(HolderObject holderObject)
        {
            if (holderObject == null)
            {
                return;
            }

            var index = _destinationInventory.Slots.IndexOf(holderObject);

            if (index != -1)
            {
                _destinationInventory.Slots[index] = null;
            }
        }
Esempio n. 4
0
        private void OnSourceHolderObjectRemoved(HolderObject holderObject)
        {
            if (holderObject == null)
            {
                return;
            }

            var index = _sourceinventory.Slots.IndexOf(holderObject);

            if (index != -1)
            {
                _sourceinventory.Slots[index] = null;
            }
        }
Esempio n. 5
0
        public void UseItem(HolderObject holderObject)
        {
            if (holderObject == null || holderObject.Item == null)
            {
                return;
            }

            if (holderObject.Item is Weapon)
            {
                _currentWeapon = holderObject;
                StartCoroutine(WaitChangeWeapon(_currentWeapon.Item as Weapon));
            }

            holderObject.Use(_gameManager);
        }
Esempio n. 6
0
        private void OnHarvestButtonClick(GameObject go)
        {
            if (_currentItem == null)
            {
                return;
            }

            _currentItem = null;
            CurrentState = GardenBedState.Available;
            UpdateView();

            if (_onGetHarvestAction != null)
            {
                _onGetHarvestAction(_currentItem);
            }
        }
Esempio n. 7
0
        public override void PlayerInteract(HolderObject interactObject, GameManager gameManager, Vector3?hitPosition = null)
        {
            base.PlayerInteract(interactObject, gameManager, hitPosition);

            if (gameObject.activeInHierarchy && hitPosition != null)
            {
                if (Animal != null)
                {
                    StartCoroutine(Animal.BloodSplat(hitPosition));
                }
                if (Enemy != null)
                {
                    StartCoroutine(Enemy.BloodSplat(hitPosition));
                }
            }
            SoundManager.PlaySFX(WorldConsts.AudioConsts.DamageEnemy);
        }
Esempio n. 8
0
        public override void PlayerInteract(HolderObject interactObject, GameManager gameManager, Vector3?hitPosition = null)
        {
            base.PlayerInteract(interactObject, gameManager, hitPosition);

            var item = GetResource();

            if (GameManager.PlayerModel.Inventory.AddItem(item))
            {
                GameManager.Player.MainHud.ShowAddedResource(item.Item.IconName, item.Amount, item.Item.LocalizationName);
            }
            else
            {
                GameManager.Player.MainHud.ShowHudText(Localization.Get("no_place_in_inventory"), HudTextColor.Red);
            }

            if (InitialAmount <= 0)
            {
                Destroy();
            }
        }
Esempio n. 9
0
        private void SetCurrentItem(HolderObject itemHolder)
        {
            _currentItem = itemHolder;

            RavnoLabel.enabled = CurrentState == GardenBedState.Available;

            PlacedObjectProgressText.enabled   = CurrentState == GardenBedState.InProgress;
            PlacedObjectProgressSprite.enabled = CurrentState == GardenBedState.InProgress;
            PlacedObjectName.enabled           = _currentItem != null && CurrentState == GardenBedState.Available;
            PlacedItemSprite.enabled           = _currentItem != null && CurrentState == GardenBedState.Available;
            PlacedObjectAmount.enabled         = _currentItem != null && CurrentState == GardenBedState.Available;

            HarvestItemSprite.enabled = _currentItem != null;
            HarvestItemAmount.enabled = _currentItem != null;
            HarvestItemName.enabled   = _currentItem != null;

            HarvestButton.SetActive(CurrentState == GardenBedState.Finished);
            PlantButton.SetActive(CurrentState == GardenBedState.Available);

            if (_currentItem != null)
            {
                PlacedObjectName.text       = Localization.Get(_currentItem.Item.LocalizationName);
                PlacedItemSprite.spriteName = _currentItem.Item.IconName;
                PlacedObjectAmount.text     = _maxSeeds.ToString();

                var resultItem = _currentItem.Item.GardenResult;
                if (_currentItem.CurrentDurability <= 1)
                {
                    resultItem = _currentItem.Item.GardenWitheredResult;
                }

                HarvestItemName.text         = Localization.Get(resultItem.Key.LocalizationName);
                HarvestItemAmount.text       = (resultItem.Value * _maxSeeds).ToString();
                HarvestItemSprite.spriteName = resultItem.Key.IconName;
            }
        }
Esempio n. 10
0
 public void RemoveItem(BaseObject item, int amount = 1)
 {
     ItemModel = new HolderObject(item.GetType(), amount);
 }
Esempio n. 11
0
        public override void PlayerInteract(HolderObject interactObject, GameManager gameManager, Vector3?hitPosition = null)
        {
            base.PlayerInteract(interactObject, gameManager, hitPosition);

            SoundManager.PlaySFX(WorldConsts.AudioConsts.RockHit);
        }
Esempio n. 12
0
 public virtual void SetItem(UiSlot slot, HolderObject itemModel)
 {
 }
Esempio n. 13
0
 public virtual void PlayerInteract(HolderObject interactObject, GameManager gameManager, Vector3?hitPosition = null)
 {
     GameManager    = gameManager;
     InteractObject = interactObject;
 }
Esempio n. 14
0
 public override void SetItem(UiSlot slot, HolderObject itemModel)
 {
     OnSlotValueChanged(slot);
 }