示例#1
0
    private Resource_Attributes FindResourceAttribute(Resource_V2.ResourceType type)
    {
        Resource_Attributes temp = null;

        foreach (Resource_Attributes ra in resource_inventory)
        {
            if (ra.resource_type == type)
            {
                temp = ra;
                break;
            }
        }
        return(temp);
    }
    //TODO: Towers cost a LIST of resources. This ain't gonna work. Refactor to accept param Resource_Attributes instead of this garbage!
    //Tries to take the amount of resources asked out of the inventory. Return bool indicates success/failure
    public static bool TryTakeResource(Resource_V2.ResourceType type, int amount)
    {
        Resource_Attributes temp = FindResourceAttribute(type);

        if (temp.resource_amount >= amount)
        {
            //no need to clamp
            temp.resource_amount -= amount;
            return(true);
        }
        else
        {
            return(false);
        }
    }
 public Resource_Attributes(Resource_V2.ResourceType type, int amt)
 {
     resource_type   = type;
     resource_amount = amt;
 }
 public AddResourceArgs(int rsc_amt, Resource_V2.ResourceType rsc_type)
 {
     this.resource_amount = rsc_amt;
     this.resource_type   = rsc_type;
 }
示例#5
0
    //sets resource_amount of type argument to amount argument
    public void SetResourceAmount(Resource_V2.ResourceType type, int amount)
    {
        Resource_Attributes temp = FindResourceAttribute(type);

        temp.resource_amount = amount;
    }
示例#6
0
    public int GetResourceAmount(Resource_V2.ResourceType type)
    {
        Resource_Attributes temp = FindResourceAttribute(type);

        return(temp.resource_amount);
    }
    //will add argument amount to the resource_amount of type argument
    public static void AppendResourceAmount(Resource_V2.ResourceType type, int amount)
    {
        Resource_Attributes temp = FindResourceAttribute(type);

        temp.resource_amount += amount;
    }