示例#1
0
    public void SetObservingPlace(ILabourable wb)
    {
        if (wb == null)
        {
            SelfShutOff();
            return;
        }
        if (!wb.IsWorksite())
        {
            UIBuildingObserver ub = Building.buildingObserver;
            if (ub == null)
            {
                ub = UIBuildingObserver.InitializeBuildingObserverScript();
            }
            else
            {
                ub.gameObject.SetActive(true);
            }
            ub.SetObservingBuilding(wb as WorkBuilding);
        }
        observingPlace         = wb; isObserving = true;
        showingWorkersCount    = wb.GetWorkersCount();
        showingWorkersMaxCount = wb.GetMaxWorkersCount();

        ignoreWorkersSlider = true;// иначе будет вызывать ивент
        slider.minValue     = 0;
        slider.maxValue     = showingWorkersMaxCount;
        slider.value        = showingWorkersCount;
        ignoreWorkersSlider = false;

        workersCountField.text = showingWorkersCount.ToString() + '/' + showingWorkersMaxCount.ToString();
        workSpeedField.text    = observingPlace.UI_GetInfo();

        workspeedStringEnabled = observingPlace.ShowUIInfo();
        workSpeedField.enabled = workspeedStringEnabled;
        if (observingPlace.IsWorksite())
        {
            actionLabel.enabled = true;
            actionLabel.text    = (observingPlace as Worksite).actionLabel;
            stopButton.SetActive(true);
        }
        else
        {
            actionLabel.enabled = false;
            stopButton.SetActive(false);
        }
        StatusUpdate();
    }