public void GainEnergyOnMap(int amountToGain) { if (currentEnergy + amountToGain > maximumEnergy) { currentEnergy = maximumEnergy; } else { currentEnergy += amountToGain; } MapConfig mapConfig = FindObjectOfType <MapConfig>(); mapConfig.GetEnergyPipManager().ChangeValue(currentEnergy); SetEnergyText(); }