public bool ReachGoal(ResourcesID[] GoalResourcesID, float[] GoalResources) { for (int i = 0; i != GoalResourcesID.Length; ++i) { if (Resources[GoalResourcesID[i]] < GoalResources[i]) { return false; } } return true; }
public void GatherResource(float amount, ResourcesID type) { if (amount < 0) return; Resources [type] += amount; if (Resources[type] > MaxResources) { Resources[type] = MaxResources; } UpdateText (type); }
public void UseResource(float amount, ResourcesID type) { if (amount < 0) return; Resources [type] -= (amount); if (Resources[type] < 0) { Resources[type] = 0; } UpdateText (type); }
public void AddGoal(ResourcesID type, float amount) { Goals.Add(type, amount); }
private void UpdateText(ResourcesID type) { switch (type) { case ResourcesID.Fire: FireCount.text = "x " + Mathf.CeilToInt(Resources[type]).ToString(); break; case ResourcesID.Earth: EarthCount.text = "x " + Mathf.CeilToInt(Resources[type]).ToString(); break; case ResourcesID.Grass: GrassCount.text = "x " + Mathf.CeilToInt(Resources[type]).ToString(); break; case ResourcesID.Wind: WindCount.text = "x " + Mathf.CeilToInt(Resources[type]).ToString(); break; } }
public bool HaveEnoughOf(ResourcesID resource, float amount) { return Resources[resource] >= amount; }