protected override void Update() { base.Update(); if (IsVisible() && character != null && select != null) { float dist = (interact_pos - character.transform.position).magnitude; if (dist > select.use_range * 1.2f) { Hide(); } } if (IsVisible()) { Vector3 dir = TheCamera.Get().GetFacingFront(); transform.rotation = Quaternion.LookRotation(dir, Vector3.up); } if (IsVisible() && select == null) { Hide(); } //Auto focus UISlotPanel focus_panel = UISlotPanel.GetFocusedPanel(); if (focus_panel != this && IsVisible() && PlayerControls.IsAnyGamePad()) { Focus(); } }
void Update() { pause_panel.SetVisible(TheGame.Get().IsPausedByPlayer()); foreach (PlayerControls controls in PlayerControls.GetAll()) { if (controls.IsPressPause() && !TheGame.Get().IsPausedByPlayer()) { TheGame.Get().Pause(); } else if (controls.IsPressPause() && TheGame.Get().IsPausedByPlayer()) { TheGame.Get().Unpause(); } } //Gamepad auto focus UISlotPanel focus_panel = UISlotPanel.GetFocusedPanel(); if (focus_panel != pause_panel && TheGame.Get().IsPausedByPlayer() && PlayerControls.IsAnyGamePad()) { pause_panel.Focus(); } if (focus_panel == pause_panel && !TheGame.Get().IsPausedByPlayer()) { UISlotPanel.UnfocusAll(); } }
protected virtual void Awake() { parent = GetComponentInParent <UISlotPanel>(); rect = GetComponent <RectTransform>(); evt_trigger = GetComponent <EventTrigger>(); button = GetComponent <Button>(); }
public UISlot GetSelectedSlot() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); UISlot selected_slot = selected_panel?.GetSelectSlot(); return(selected_slot); }
void Update() { PlayerControls controls = PlayerControls.Get(player_id); if (!controls.IsGamePad()) { return; } if (controls.IsUIPressLeft()) { Navigate(Vector2.left); } else if (controls.IsUIPressRight()) { Navigate(Vector2.right); } else if (controls.IsUIPressUp()) { Navigate(Vector2.up); } else if (controls.IsUIPressDown()) { Navigate(Vector2.down); } //Stop navigate if out of focus UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); if (selected_panel != null && !selected_panel.IsVisible()) { StopNavigate(); } else if (selected_panel != null && selected_panel.GetSelectSlot() != null && !selected_panel.GetSelectSlot().IsVisible()) { StopNavigate(); } //Controls if (controls.IsPressUISelect()) { OnPressSelect(); } if (controls.IsPressUIUse()) { OnPressUse(); } if (controls.IsPressUICancel()) { OnPressCancel(); } if (controls.IsPressAttack()) { OnPressAttack(); } }
public bool IsPanelFocusItem() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); UISlot slot = selected_panel?.GetSelectSlot(); ItemSlot islot = (slot != null && slot is ItemSlot) ? (ItemSlot)slot : null; return(islot != null && islot.GetItem() != null); }
private void OnAccept(UISlot slot) { OnClick(slot); UISlotPanel.UnfocusAll(); if (prev_panel != null) { prev_panel.Focus(); } }
private void OnPressAttack() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); if (selected_panel is InventoryPanel || selected_panel is EquipPanel) { ItemSlotPanel.CancelSelectionAll(); UISlotPanel.UnfocusAll(); } }
public int GetSelectedIndex() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); if (selected_panel != null) { return(selected_panel.selection_index); } return(-1); }
private void OnAccept(UISlot slot) { PlayerCharacter player = PlayerCharacter.Get(GetPlayerID()); CraftInfoPanel.Get(GetPlayerID())?.OnClickCraft(); if (player.Crafting.IsBuildMode()) { UISlotPanel.UnfocusAll(); } }
private void OnPressUse() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); UISlot selected_slot = selected_panel?.GetSelectSlot(); if (selected_slot != null) { selected_slot.KeyPressUse(); } }
protected override void Update() { base.Update(); //Auto focus UISlotPanel focus_panel = UISlotPanel.GetFocusedPanel(); if (focus_panel != this && IsVisible() && PlayerControls.IsAnyGamePad()) { prev_panel = focus_panel; Focus(); } }
public void NavigateTo(UISlot slot, Vector2 dir) { UISlotPanel panel = slot?.GetParent(); if (panel != null && panel.IsVisible()) { panel.Focus(); panel.selection_index = slot.index; } else { Navigate(panel, dir); } }
private void OnPressCancel() { UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); UISlot selected_slot = selected_panel?.GetSelectSlot(); if (selected_slot != null) { selected_slot.KeyPressCancel(); } if (ReadPanel.Get().IsVisible()) { ReadPanel.Get().Hide(); } }
public void Navigate(UISlotPanel panel, Vector2 dir) { UISlot current = panel?.GetSelectSlot(); if (panel == null || current == null) { if (IsLeft(dir)) { panel = default_left; } else if (IsRight(dir)) { panel = default_right; } else if (IsUp(dir)) { panel = default_top; } else if (IsDown(dir)) { panel = default_down; } panel.Focus(); } else { if (IsLeft(dir) && current.left) { NavigateTo(current.left, dir); } else if (IsRight(dir) && current.right) { NavigateTo(current.right, dir); } else if (IsUp(dir) && current.top) { NavigateTo(current.top, dir); } else if (IsDown(dir) && current.down) { NavigateTo(current.down, dir); } else { NavigateAuto(panel, dir); } } }
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 void NavigateAuto(UISlotPanel panel, Vector2 dir) { if (panel != null) { int slots_per_row = panel.slots_per_row; int prev_select = panel.selection_index; if (IsLeft(dir)) { panel.selection_index--; } else if (IsRight(dir)) { panel.selection_index++; } else if (IsUp(dir)) { panel.selection_index -= slots_per_row; } else if (IsDown(dir)) { panel.selection_index += slots_per_row; } if (panel.IsSelectedInvisible()) { Navigate(panel, dir); //Continue same dir } if (!panel.unfocus_when_out && !panel.IsSelectedValid()) { panel.selection_index = prev_select; //Dont exit panel, set to previous } if (panel.unfocus_when_out && !panel.IsSelectedValid()) { UISlotPanel.UnfocusAll(); //Exit panel } } }
protected override void RefreshPanel() { base.RefreshPanel(); //Gamepad auto controls PlayerCharacter player = GetPlayer(); CraftInfoPanel info_panel = CraftInfoPanel.Get(GetPlayerID()); if (UISlotPanel.GetFocusedPanel() == this) { selection_index = Mathf.Clamp(selection_index, 0, CountActiveSlots() - 1); UISlot slot = GetSelectSlot(); if (player != null && !player.Crafting.IsBuildMode()) { if (prev_slot != slot || !info_panel.IsVisible()) { OnClick(slot); prev_slot = slot; } } } }
private void OnCancel(UISlot slot) { Toggle(); CraftSubPanel.Get(GetPlayerID())?.Hide(); UISlotPanel.UnfocusAll(); }
private void OnAccept(UISlot slot) { OnClick(slot); UISlotPanel.UnfocusAll(); }
public void Navigate(Vector2 dir) { UISlotPanel selected_panel = GetFocusedPanel(); Navigate(selected_panel, dir); }
private void OnCancel(UISlot slot) { ItemSlotPanel.CancelSelectionAll(); UISlotPanel.UnfocusAll(); }
public UISlotPanel GetFocusedPanel() { return(UISlotPanel.GetFocusedPanel()); }
public void StopNavigate() { ActionSelector.Get(player_id)?.Hide(); ActionSelectorUI.Get(player_id)?.Hide(); UISlotPanel.UnfocusAll(); }