Esempio n. 1
0
    void PathEnd()
    {
        if (CurrentIssue)
        {
            if (!CurrentIssue.bIsBeingWorked && ContractorType == CurrentIssue.CurrentIssueType)
            {
                bIsWorking = true;
                CurrentIssue.bIsBeingWorked = true;
                TimeRemainingInJobSlider.gameObject.SetActive(true);
                StatusText.text = "Is Working..";
            }
            else if (CurrentIssue.bIsBeingWorked && bIsWorking)
            {
                if (TimeRemainingInJobSlider.value + Time.deltaTime >= TimeToCompleteJob)
                {
                    ShowPositiveText();
                    SatisfactionManager.JobDone();
                    CurrentIssue.SetCompleted();
                    CurrentIssue.gameObject.SetActive(false);
                    TileToMoveTo.SetIssueCompleted();
                    JobsCompleted++;
                    CurrentIssue = null;
                    TimeRemainingInJobSlider.value = 0.0f;
                    TimeRemainingInJobSlider.gameObject.SetActive(false);
                    bool hasSucceeded = agent.SetDestination(originalSpawnPoint);
                    if (!hasSucceeded)
                    {
                        //Debug.Log("Didn't succeed at setting path");
                    }
                    StatusText.text = "Is Returning..";
                    bIsWorking      = false;
                    bIsReturning    = true;
                }

                TimeRemainingInJobSlider.value += Time.deltaTime;
            }
            else if (!CurrentIssue.bIsCompleted && !bIsWorking)
            {
                // Debug.Log("Someone is already working on it OR ContractorType != IssueType");
                CurrentIssue.ShowNegativeText();
                SatisfactionManager.ReduceCitySatisfaction();
                agent.SetDestination(originalSpawnPoint);
                StatusText.text = "Is Returning..";
                CurrentIssue    = null;
                bIsReturning    = true;
            }
            else if (!bIsWorking)
            {
                //Debug.Log("The job is already completed");
                CurrentIssue = null;
                agent.SetDestination(originalSpawnPoint);
            }
        }
        else if (!bHasReturned)
        {
            // Debug.Log("I have returned OR i cant find path back");
            bHasReturned              = true;
            MyHQ.JobsCompleted       += JobsCompleted;
            MyHQ.JobsCompletedForDay += JobsCompleted;
            MyHQ.ReturnContractor();
            Destroy(MyContractorUI.gameObject, 1.4f);
            Destroy(gameObject, 1.5f);
        }
    }