Esempio n. 1
0
    private void collect()
    {
        //TODO Return to base if resource has been consumed completely

        if (resource != null)
        {
            if (collectResourceAmount < MAX_RESOURCE &&
                GoCloser(resource) &&
                doFreq(Action.Collect, resource.SPEED_COLLECTION))
            {
                //Debug.Log("Collecting resource " + resource.name);
                if (resource.consume(1))
                {
                    resource = null;
                }
                collectResourceAmount++;
                anim.SetBool("Working", true);
                Effects.Bluesparks(resource.transform.position);
            }
            else if (collectResourceAmount >= MAX_RESOURCE)               //GO back to base to drop resources
            {
                Building building = Utils.closest <Building>("Base", tag, transform.position);
                if (building != null && GoCloser(building) && !droping)
                {
                    AddResources();
                }
            }
        }
        else
        {
            anim.SetBool("Working", false);
        }
    }