public void AddResource(BaseResourceType type, float value) { var resourceContainer = _availableResources.FirstOrDefault(r => r.ResourceType == type); if (resourceContainer != null) { resourceContainer.Count += value; } else { Debug.LogError("Resource type not found: " + type.ToString()); } }
public bool TryUseResource(BaseResourceType type, float count) { var resourceContainer = _availableResources.FirstOrDefault(r => r.ResourceType == type); if (resourceContainer == null) { Debug.LogError("Resource type not found: " + type.ToString()); return(false); } if (resourceContainer.Count >= count) { resourceContainer.Count -= count; return(true); } return(false); }