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; } }
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); }
private void OnDestHolderObjectRemoved(HolderObject holderObject) { if (holderObject == null) { return; } var index = _destinationInventory.Slots.IndexOf(holderObject); if (index != -1) { _destinationInventory.Slots[index] = null; } }
private void OnSourceHolderObjectRemoved(HolderObject holderObject) { if (holderObject == null) { return; } var index = _sourceinventory.Slots.IndexOf(holderObject); if (index != -1) { _sourceinventory.Slots[index] = null; } }
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); }
private void OnHarvestButtonClick(GameObject go) { if (_currentItem == null) { return; } _currentItem = null; CurrentState = GardenBedState.Available; UpdateView(); if (_onGetHarvestAction != null) { _onGetHarvestAction(_currentItem); } }
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); }
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(); } }
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; } }
public void RemoveItem(BaseObject item, int amount = 1) { ItemModel = new HolderObject(item.GetType(), amount); }
public override void PlayerInteract(HolderObject interactObject, GameManager gameManager, Vector3?hitPosition = null) { base.PlayerInteract(interactObject, gameManager, hitPosition); SoundManager.PlaySFX(WorldConsts.AudioConsts.RockHit); }
public virtual void SetItem(UiSlot slot, HolderObject itemModel) { }
public virtual void PlayerInteract(HolderObject interactObject, GameManager gameManager, Vector3?hitPosition = null) { GameManager = gameManager; InteractObject = interactObject; }
public override void SetItem(UiSlot slot, HolderObject itemModel) { OnSlotValueChanged(slot); }