public void CHEATGiveResources() { foreach (Cost cost in _currentResources) { cost.amount += 1000; } OnResourcesModification?.Invoke(); }
public void AddResource(Cost resource) { Cost modifiedResource = GetResourceForType(resource.type); if (modifiedResource != null) { modifiedResource.amount += resource.amount; } else { Debug.LogWarning("Resource is not properly initialized"); } OnResourcesModification?.Invoke(); }
public void RemoveResource(Cost resource) { Cost modifiedResource = GetResourceForType(resource.type); if (modifiedResource != null) { modifiedResource.amount -= resource.amount; if (modifiedResource.amount < 0) { Debug.LogWarning("Resource amount is below zero, something went wrong"); modifiedResource.amount = 0; } } OnResourcesModification?.Invoke(); }
private void InitializeResources(List <Cost> newResources) { InitState = InitializationState.Initializing; foreach (Cost currentResource in _currentResources) { int newAmout = 0; Cost resourceToAdd = newResources.Find(x => x.type == currentResource.type); if (resourceToAdd != null) { newAmout = resourceToAdd.amount; } currentResource.amount = newAmout; } OnResourcesModification?.Invoke(); InitState = InitializationState.Ready; }