Esempio n. 1
0
        public void RaycastSelectables()
        {
            raycast_list.Clear();

            if (TheUI.Get().IsBlockingPanelOpened())
            {
                return;
            }

            PlayerUI ui = PlayerUI.GetFirst();

            if (ui != null && ui.IsBuildMode())
            {
                return; //Dont hover/select things in build mode
            }
            RaycastHit[] hits = Physics.RaycastAll(GetMouseCameraRay(), 99f, selectable_layer.value);
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider != null)
                {
                    Selectable select = hit.collider.GetComponentInParent <Selectable>();
                    if (select != null)
                    {
                        raycast_list.Add(select);
                    }
                }
            }
        }
 public void SetFilter(int filter_level)
 {
     if (filter != null)
     {
         filter.enabled = filter_level > 0;
         filter.color   = filter_level >= 2 ? TheUI.Get().filter_red : TheUI.Get().filter_yellow;
     }
 }
        void Update()
        {
            PlayerControlsMouse controls = PlayerControlsMouse.Get();

            float target_alpha = controls.IsJoystickActive() && !PlayerUI.GetFirst().IsBuildMode() ? 1f : 0f;

            canvas.alpha = Mathf.MoveTowards(canvas.alpha, target_alpha, 4f * Time.deltaTime);

            Vector2 screenPos = controls.GetJoystickPos();

            rect.anchoredPosition = TheUI.Get().ScreenPointToCanvasPos(screenPos);
            pin.anchoredPosition  = controls.GetJoystickDir() * 50f;
        }
Esempio n. 4
0
        void RefreshTooltip()
        {
            if (target != null)
            {
                rect.anchoredPosition = TheUI.Get().ScreenPointToCanvasPos(Input.mousePosition);
                //transform.position = PlayerControlsMouse.Get().GetPointingPos();
                //transform.rotation = Quaternion.LookRotation(TheCamera.Get().transform.forward, Vector3.up);

                PlayerControlsMouse mouse = PlayerControlsMouse.Get();
                if (!target.IsHovered() || mouse.IsMovingMouse())
                {
                    Hide();
                }
            }
        }
Esempio n. 5
0
        void Awake()
        {
            _instance = this;
            canvas    = GetComponent <Canvas>();
            rect      = GetComponent <RectTransform>();

            if (ui_material != null)
            {
                foreach (Image image in GetComponentsInChildren <Image>())
                {
                    image.material = ui_material;
                }
            }
            if (text_material != null)
            {
                foreach (Text txt in GetComponentsInChildren <Text>())
                {
                    txt.material = text_material;
                }
            }
        }
Esempio n. 6
0
        protected override void RefreshPanel()
        {
            base.RefreshPanel();

            PlayerCharacter player = GetPlayer();

            if (player != null)
            {
                CraftStation station = player.Crafting.GetCraftStation();
                if (current_staton != station)
                {
                    current_staton = station;
                    RefreshCategories();
                }
            }

            //Gamepad auto controls
            PlayerControls controls    = PlayerControls.Get(GetPlayerID());
            CraftSubPanel  sub_panel   = CraftSubPanel.Get(GetPlayerID());
            UISlotPanel    focus_panel = UISlotPanel.GetFocusedPanel();

            if (focus_panel != this && focus_panel != sub_panel && !TheUI.Get().IsBlockingPanelOpened() &&
                controls.IsGamePad() && player != null && !player.Crafting.IsBuildMode())
            {
                Focus();
                CraftInfoPanel.Get(GetPlayerID())?.Hide();
            }
            if (focus_panel == this)
            {
                selection_index = Mathf.Clamp(selection_index, 0, CountActiveSlots() - 1);

                UISlot slot = GetSelectSlot();
                if (prev_slot != slot || !sub_panel.IsVisible())
                {
                    OnClick(slot);
                    sub_panel.selection_index = 0;
                    prev_slot = slot;
                }
            }
        }
 public bool IsControlsEnabled()
 {
     return(controls_enabled && !TheUI.Get().IsFullPanelOpened());
 }