Пример #1
0
    void Consume()
    {
        if (isPlaced)
        {
            _timeSlice = Time.deltaTime;

            float _availableNutrients = nature.GetAvailableNutrients(transform.position);

            if (_availableNutrients > 0)
            {
                if (_availableNutrients - _timeSlice * nutrientConsumptionRate >= 0)
                {
                    nature.ConsumeNutrients(transform.position, Time.deltaTime * nutrientConsumptionRate);
                    HealthControl((_timeSlice * nutrientConsumptionRate) / deathRate);
                    Debug.Log(nature.GetAvailableNutrients(transform.position) + " and consumed " + _timeSlice * nutrientConsumptionRate + "and the sum is" + (nature.GetAvailableNutrients(transform.position) - _timeSlice * nutrientConsumptionRate));
                    ProduceOrganicMatter();
                }
                else
                {
                    nature.ConsumeNutrients(transform.position, Time.deltaTime * nutrientConsumptionRate);
                    HealthControl((nature.GetAvailableNutrients(transform.position) - _timeSlice * nutrientConsumptionRate) / deathRate);
                    //Nature.GetAvailableNutrients(transform.position) = 0;
                }
            }
            else
            {
                HealthControl(-(_timeSlice * nutrientConsumptionRate) / deathRate);
            }
        }
    }