Exemple #1
0
    void UpdateDoJob(float deltaTime)
    {
        jobSearchCoolDown -= deltaTime;
        if (myJob == null)
        {
            if (jobSearchCoolDown > 0)
            {
                return;
            }

            GetNewJob();

            if (myJob == null)
            {
                jobSearchCoolDown = UnityEngine.Random.Range(0.5f, 0.1f);
                DestTile          = CurrTile;
                return;
            }
        }

        if (myJob.JobType != EstateJobType.HAUL)
        {
            DestTile = myJob.jobTile;
        }
        else
        {
            if (item == null)
            {
                DestTile = myJob.pickupTile;
                //Debug.Log("Should be heading to pick up at: " + DestTile.X + ":" + DestTile.Y);
            }
            else
            {
                DestTile = myJob.jobTile;
            }
        }

        if (CurrTile == myJob.pickupTile && item == null)
        {
            PickUpHaulableItem();
        }
        if (CurrTile == myJob.jobTile)
        {
            //Debug.Log("At job site");
            myJob.WorkJob(deltaTime);
        }
    }
Exemple #2
0
    public void AddJob(EstateJob job)
    {
        if (JobTileAlreadyHasJobOfType(job.jobTile, job.JobType))
        {
            Debug.Log("EJM::AddJob - Job is already queued up on this tile");
            return;
        }

        //If this job is instant then dont add to queues. just do it
        if (job.JobTime <= 0)
        {
            job.WorkJob(0);
            return;
        }


        switch (job.JobType)
        {
        case EstateJobType.BUILD:
        case EstateJobType.HAUL:
            haulBuildJobList.Add(job);
            break;

        case EstateJobType.CLEAN:
            cleanJobList.Add(job);
            break;

        case EstateJobType.GARDEN:
            gardenJobList.Add(job);
            break;

        default:
            Debug.LogError("EstateJobManager::AddJob -- This job has no type or unrecognised type");
            break;
        }

        ReserveTiles(job);
        if (onJobCreatedCallback != null)
        {
            onJobCreatedCallback(job);
        }
    }