IEnumerator ProduceCycle()
        {
            WaitForSeconds delay = new WaitForSeconds(UpdateDelay);

            while (true)
            {
                if (_item.CurrentProducingRecycleTime >= _item.ProducingRecycleTime)
                {
                    if (!_lackState)
                    {
                        FarmingGameController.ChangeResources(_item.ProducingResourcesValue);

                        Instantiate(_animation, transform.position, Quaternion.identity).
                        Initialization(_item.ProducingResourcesValue.Quantity, false);
                    }
                    else
                    {
                        yield break;
                    }
                    _item.CurrentProducingRecycleTime = 0;
                }
                yield return(delay);

                _item.CurrentProducingRecycleTime += UpdateDelay;
            }
        }
        IEnumerator ConsumeCycle()
        {
            WaitForSeconds delay = new WaitForSeconds(UpdateDelay);

            while (true)
            {
                if (_item.CurrentConsumableRecycleTime >= _item.ConsumableRecycleTime)
                {
                    if (FarmingGameController.CurrentGame.GetNaturalResources(_item.ConsumableResourcesValue.Type).Quantity <
                        Mathf.Abs(_item.ConsumableResourcesValue.Quantity))
                    {
                        UpdateLackState(true);
                        yield break;
                    }
                    else
                    {
                        FarmingGameController.ChangeResources(_item.ConsumableResourcesValue, true);

                        Instantiate(_animation, transform.position, Quaternion.identity).
                        Initialization(_item.ProducingResourcesValue.Quantity, true);
                    }
                    _item.CurrentConsumableRecycleTime = 0;
                }
                yield return(delay);

                _item.CurrentConsumableRecycleTime += UpdateDelay;
            }
        }
Beispiel #3
0
        public void CreateFarmItem(ConsumableFarmItemController farmItemController)
        {
            ConsumableFarmItem farmItem = FarmingGameController.GetItemStats(farmItemController.Type);

            _farmCell.SetConsumableFarmItem(farmItem);
            Instantiate(farmItemController, transform).Initiazliation(farmItem);
        }
Beispiel #4
0
        private void SaleResource()
        {
            NaturalResourceValue naturalResourceValue =
                new NaturalResourceValue(_naturalResources.Value.Type, 1);

            if (FarmingGameController.CurrentGame.GetNaturalResources(naturalResourceValue.Type).Quantity > 0)
            {
                FarmingGameController.ChangeResources(naturalResourceValue, true);
                FarmingGameController.ChangeMoney(_naturalResources.UnitPrice);
            }

            UpdateText(_type);
        }
Beispiel #5
0
        private void BuyItem(ShopItem item)
        {
            if (item == null)
            {
                return;
            }

            if (item.Cost <= FarmingGameController.CurrentGame.Money)
            {
                FarmingGameController.ChangeMoney(item.Cost, true);

                BuyFarmItem.CallActionIfNotNull(item);
            }
        }