Exemplo n.º 1
0
    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;
    }
Exemplo n.º 2
0
    public void GatherResource(float amount, ResourcesID type)
    {
        if (amount < 0) return;
        Resources [type] += amount;

        if (Resources[type] > MaxResources)
        {
            Resources[type] = MaxResources;
        }

        UpdateText (type);
    }
Exemplo n.º 3
0
    public void UseResource(float amount, ResourcesID type)
    {
        if (amount < 0) return;

        Resources [type] -= (amount);

        if (Resources[type] < 0)
        {
            Resources[type] = 0;
        }

        UpdateText (type);
    }
Exemplo n.º 4
0
 public void AddGoal(ResourcesID type, float amount)
 {
     Goals.Add(type, amount);
 }
Exemplo n.º 5
0
 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;
     }
 }
Exemplo n.º 6
0
 public bool HaveEnoughOf(ResourcesID resource, float amount)
 {
     return Resources[resource] >= amount;
 }