private void ChangeUsingRessource(GameManager.ResourceType emptyResource)
 {
     for (int i = 0; i < needs.Length; i++)
     {
         if (needs[i].ResourceUsed == null)
         {
             ResourceInStock firstResourceUsable = GetResourceInStock(needs[i].resourcesUsable[0]);
             needs[i].ResourceUsed = firstResourceUsable;
         }
         else
         {
             if (emptyResource == needs[i].ResourceUsed.resourcesInfos.resourceType)
             {
                 for (int j = 0; j < needs[i].resourcesUsable.Length; j++)
                 {
                     if (needs[i].resourcesUsable[j] != emptyResource)
                     {
                         ResourceInStock otherResourceUsable = GetResourceInStock(needs[i].resourcesUsable[j]);
                         if (otherResourceUsable.NumberInStock > 0)
                         {
                             needs[i].ResourceUsed = otherResourceUsable;
                         }
                         else
                         {
                             if (needs[i].multiplicator > 0)
                             {
                                 RoundManager.Instance.EndLevel(false);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
 public bool CanUseResource(GameManager.ResourceType resourceType)
 {   
     //check if the need can use a resource type
     bool canIUseIt = false;
     for (int i = 0; i < resourcesUsable.Length; i++)
     {
         if (resourcesUsable[i] == resourceType)
             canIUseIt = true;
     }
     return canIUseIt;
 }
Beispiel #3
0
    public ResourceInStock GetResourceInStock(GameManager.ResourceType resourceType)
    {
        ResourceInStock resourceInStockNeeded = null;

        for (int i = 0; i < stock.Length; i++)
        {
            if (resourceType == stock[i].resourcesInfos.resourceType)
            {
                resourceInStockNeeded = stock[i];
            }
        }
        return(resourceInStockNeeded);
    }
Beispiel #4
0
 public void UpdateResourceUI(GameManager.ResourceType resource, int val)
 {
     if (resource == GameManager.ResourceType.GOLD)
     {
         BounceEffect(m_MoneyUI.rectTransform, 0.2f);
         m_MoneyUI.text = val.ToString("### ##0");
     }
     else if (resource == GameManager.ResourceType.POWER)
     {
         BounceEffect(m_PowerUI.rectTransform, 0.2f);
         m_PowerUI.text = val.ToString("### ###0");
     }
 }
Beispiel #5
0
 public void SetResourceInStock(GameManager.ResourceType typeOfResource, int amount)
 {
     GetResourceInStock(typeOfResource).NumberInStock += amount;
 }