private IEnumerator RefreshProgress() { while (true) { yield return(new WaitForSeconds(1f)); if (_currentState == GardenBedState.InProgress) { if (_currentItem.CurrentDurability > 1) { _currentItem.ChangeDurability(1); } UpdateItemsPrefabs(); if (_currentItem.CurrentDurability <= _currentItem.Item.GardenTimeStage3) { _currentState = GardenBedState.Finished; if (_panel != null) { _panel.CurrentState = GardenBedState.Finished; _panel.UpdateView(); } } } if (_currentState == GardenBedState.Finished && _currentItem.CurrentDurability > 1) { _currentItem.ChangeDurability(1); UpdateItemsPrefabs(); } } }
private void PlantItem() { if (_currentItem == null) { StartCoroutine(TweenPinPong(DescriptionLabel.gameObject, 0.5f, 1.1f)); return; } if (_currentItem.Amount < _maxSeeds) { StartCoroutine(TweenPinPong(RequarementAmountLabel.gameObject, 0.5f, 1.1f)); return; } var itemType = _currentItem.Item.GetType(); if (_currentItem.Amount <= _maxSeeds) { GameManager.PlayerModel.Inventory.RemoveItem(_currentItem); } else { _currentItem.ChangeAmount(_maxSeeds); } _currentItem = HolderObjectFactory.GetItem(itemType, _maxSeeds); CurrentState = GardenBedState.InProgress; UpdateView(); if (_onPlantAction != null) { _onPlantAction(_currentItem); } }
public void SetInventoryList(List <InventoryBase> inventoryList) { if (inventoryList != null && inventoryList.Count > 0) { _inventory = inventoryList[0]; foreach (var inventorySlot in _inventory.Slots) { if (inventorySlot != null && inventorySlot.Item != null) { _currentItem = inventorySlot; if (_currentItem.CurrentDurability > 0) { _currentState = GardenBedState.InProgress; } else { _currentState = GardenBedState.Finished; if (_panel != null) { _panel.CurrentState = GardenBedState.Finished; } StartCoroutine(UpdateItemsPrefabsDelay()); } } } } _slotInited = true; }
public IEnumerator ShowDelay(float delayTime, HolderObject currentItem, GardenBedState currentState) { IsShowing = true; yield return(new WaitForSeconds(delayTime)); gameObject.SetActive(true); _currentItem = currentItem; CurrentState = currentState; InitItems(); UpdateView(); }
public void Init(GameManager gameManager, InventoryBase inventory, Action <HolderObject> onPlantAction, Action <HolderObject> onGetHarvestAction) { base.Init(gameManager); CurrentState = GardenBedState.Available; Inventory = inventory; _onPlantAction = onPlantAction; _onGetHarvestAction = onGetHarvestAction; RequarementAmountLabel.text = "(" + Localization.Get("required_amount") + ": " + _maxSeeds + ")"; UIEventListener.Get(PlacedItemObject).onClick += OnPlacedItemClick; UIEventListener.Get(PlantButton).onClick += OnPlantButtonClick; UIEventListener.Get(HarvestButton).onClick += OnHarvestButtonClick; UIEventListener.Get(CloseButton).onClick += OnCloseClick; }
private void OnHarvestButtonClick(GameObject go) { if (_currentItem == null) { return; } _currentItem = null; CurrentState = GardenBedState.Available; UpdateView(); if (_onGetHarvestAction != null) { _onGetHarvestAction(_currentItem); } }
private void GeHarvest(HolderObject itemHolder) { _currentState = GardenBedState.Available; var gardenResult = _currentItem.Item.GardenResult; if (_currentItem.CurrentDurability <= 1) { gardenResult = _currentItem.Item.GardenWitheredResult; } var result = new HolderObject(gardenResult.Key.GetType(), gardenResult.Value * _maxSeeds); if (!_gameManager.PlayerModel.Inventory.AddItem(result)) { GameManager.PlacementItemsController.DropItemToGround(GameManager, result); } _inventory.RemoveItem(_currentItem); _currentItem = null; RemoveItemPrefabs(); _itemsInitialized = false; _currentStage = 0; }
private void SetCurretnItem(HolderObject itemHolder) { _currentItem = itemHolder; _currentState = GardenBedState.InProgress; }