コード例 #1
0
        public bool OnUpdate()
        {
            bool key = LazyManager <InputManager> .Current.GetKey(LazyManager <VoxelTycoon.Settings> .Current.MultipleModeKey);

            if (this._deactivate && !key)
            {
                return(true);
            }
            VehicleStation station = null;

            if (!InputHelper.OverUI)
            {
                station = ObjectRaycaster.Get <VehicleStation>();
            }
            if (station != null)
            {
                if (this._station != station)
                {
                    if (this._station != null)
                    {
                        this._station.SetTint(null);
                    }
                    this._station = station;
                    this._canPick = this.CanPick(station);
                    if (_canPick)
                    {
                        this._tooltip.Background = new PanelColor(ReadyToPickTooltipColor, 0f);
                        this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/add_connected_station");
                    }
                    else
                    {
                        this._tooltip.Background = new PanelColor(WrongReadyToPickHighlightColor, 0f);
                        this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/already_added");

                        station.SetTint(new Color?(WrongReadyToPickHighlightColor));
                    }
                }
                if (_canPick)
                {
                    UIManager.Current.SetCursor(Cursors.Pointer);
                    if (InputHelper.WorldMouseDown)
                    {
                        this.OnStationPicked?.Invoke(station);
                        Manager <SoundManager> .Current.PlayOnce(R.Audio.Click, null);

                        if (!key)
                        {
                            return(true);
                        }
                        this._deactivate = true;
                    }
                }
            }
            else
            {
                if (this._station != null)
                {
                    this._station.SetTint(null);
                    this._station = null;
                }
                this._tooltip.Background = new PanelColor(PickingTooltipColor, 0f);
                this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/pick_station");
            }
            this._tooltip.RectTransform.anchoredPosition = (new Vector2(Input.mousePosition.x, Input.mousePosition.y) + new Vector2(-10f, -16f)) / UIManager.Current.Scale;
            this._tooltip.ClampPositionToScreen();
            return(InputHelper.MouseDown && !key);
        }
コード例 #2
0
        public bool OnUpdate()
        {
            bool key = LazyManager <InputManager> .Current.GetKey(LazyManager <VoxelTycoon.Settings> .Current.MultipleModeKey);

            if (this._deactivate && !key)
            {
                return(true);
            }
            Building building = null;

            if (!InputHelper.OverUI)
            {
                building = ObjectRaycaster.Get <Building>((Component comp) => comp is Store || comp is Lab);
            }
            else
            {
                GameObject gameObject = InputHelper.GetUIGameObjectUnderPointer();
                if (gameObject != null)
                {
                    DemandIndicator demandInd;
                    if ((demandInd = gameObject.GetComponent <DemandIndicator>()) != null)
                    {
                        CityDemand demand = Traverse.Create(demandInd).Field <CityDemand>("_demand").Value;
                        if (demand != null && demand.Store)
                        {
                            building = demand.Store;
                        }
                    }
                }
            }
            if (building != null)
            {
                if (this._building != building)
                {
                    if (this._building != null)
                    {
                        this._building.SetTint(null);
                    }
                    this._building = building;
                    this._canPick  = this.CanPick(building);
                    if (_canPick)
                    {
                        this._tooltip.Background = new PanelColor(DemandPickerTool.ReadyToPickTooltipColor, 0f);
                        this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/add_building_for_demand");
                    }
                    else
                    {
                        this._tooltip.Background = new PanelColor(DemandPickerTool.WrongReadyToPickHighlightColor, 0f);
                        this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/already_added");

                        building.SetTint(new Color?(WrongReadyToPickHighlightColor));
                    }
                }
                if (_canPick)
                {
                    UIManager.Current.SetCursor(Cursors.Pointer);
                    if (InputHelper.MouseDown)
                    {
                        this.OnBuildingPicked?.Invoke(building);
                        Manager <SoundManager> .Current.PlayOnce(R.Audio.Click, null);

                        if (_indicatorEntered)
                        {
                            _disableIndicatorUntilExit = true;
                        }
                        if (!key)
                        {
                            return(true);
                        }
                        DisabledNodes?.Add(building as IStorageNetworkNode);
                        LazyManager <BuildingTintManager> .Current.SetDefaultColor(building, null);

                        building.SetTint(null);
                        this._deactivate = true;
                    }
                }
            }
            else
            {
                if (this._building != null)
                {
                    this._building.SetTint(null);
                    this._building = null;
                }
                this._tooltip.Background = new PanelColor(DemandPickerTool.PickingTooltipColor, 0f);
                this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/pick_store_or_lab");
            }
            this._tooltip.RectTransform.anchoredPosition = (new Vector2(Input.mousePosition.x, Input.mousePosition.y) + new Vector2(-10f, -16f)) / UIManager.Current.Scale;
            this._tooltip.ClampPositionToScreen();
            return(InputHelper.MouseDown && !key);
        }