コード例 #1
0
    private IEnumerator GatherResources(ResourceSource source)
    {
        source.StartGathering();
        while (source.resourceAmount > 0 && this.currentResourceAmount < this.m_ResourceCarryCapacity)
        {
            this.currentResourceAmount += source.GatherResource(m_GatherSpeed, this.m_ResourceCarryCapacity - this.currentResourceAmount);
            if (source.resourceAmount > 0)
            {
                yield return(new WaitForSeconds(1));
            }
        }
        source.StopGathering();

        lockedTrees.Remove(source.transform);

        if (this.currentResourceAmount == this.m_ResourceCarryCapacity)
        {
            SetNewState(State.GotoWoodBuilding);
            StartCoroutine(GotoWoodBuilding(this.m_ClosestWoodBuilding));
        }
        else
        {
            SetNewState(State.LookingForTarget);
        }
    }
コード例 #2
0
    private IEnumerator GatherResources(ResourceSource source)
    {
        source.StartGathering();
        while (source.resourceAmount > 0)
        {
            WoodResource += source.GatherResource(gatherSpeed, m_MaxGatherCapacity - WoodResource);
            if (source.resourceAmount > 0)
            {
                yield return(new WaitForSeconds(1));
            }
        }
        source.StopGathering();

        IsGathering        = false;
        CanGatherResources = false;
    }