public void CancelSelection() { EquipBar.Get().CancelSelection(); CraftBar.Get().CancelSelection(); InventoryBar.Get().CancelSelection(); PlayerCharacter.Get().CancelConstruction(); }
void Awake() { _instance = this; animator = GetComponent <Animator>(); for (int i = 0; i < slots.Length; i++) { int index = i; //Important to copy so not overwritten in loop slots[i].slot_index = index; slots[i].onClick += (GroupData category) => { OnClickSlot(index, category); }; slots[i].onClickRight += (GroupData category) => { OnClickSlotRight(index, category); }; } if (animator != null) { animator.SetBool("Visible", is_visible); } }
private void OnMouseClick() { if (IsMouseOverUI()) { return; } //If mobile, only check for raycast on click (otherwise it does it every frame in Update) if (TheGame.IsMobile()) { RaycastSelectables(); RaycastFloorPos(); } if (CraftBar.Get()) { CraftBar.Get().CancelSubSelection(); } Selectable hovered = GetNearestRaycastList(floor_pos); if (hovered != null) { if (onClick != null) { onClick.Invoke(hovered.transform.position); } if (onClickObject != null) { onClickObject.Invoke(hovered); } } else { if (onClick != null) { onClick.Invoke(floor_pos); } if (onClickFloor != null) { onClickFloor.Invoke(floor_pos); } } }
public void OnClickCraft() { CancelSelection(); CraftBar.Get().ToggleBar(); }
void Update() { move = Vector3.zero; rotate_cam = Vector3.zero; press_action = false; press_attack = false; if (Input.GetKey(KeyCode.A)) { move += Vector3.left; } if (Input.GetKey(KeyCode.D)) { move += Vector3.right; } if (Input.GetKey(KeyCode.W)) { move += Vector3.forward; } if (Input.GetKey(KeyCode.S)) { move += Vector3.back; } if (Input.GetKey(KeyCode.LeftArrow)) { move += Vector3.left; } if (Input.GetKey(KeyCode.RightArrow)) { move += Vector3.right; } if (Input.GetKey(KeyCode.UpArrow)) { move += Vector3.forward; } if (Input.GetKey(KeyCode.DownArrow)) { move += Vector3.back; } move = move.normalized * Mathf.Min(move.magnitude, 1f); if (Input.GetKey(cam_rotate_left)) { rotate_cam += Vector3.left; } if (Input.GetKey(cam_rotate_right)) { rotate_cam += Vector3.right; } if (Input.GetKeyDown(action_key1) || Input.GetKeyDown(action_key2)) { press_action = true; } if (Input.GetKeyDown(attack_key1) || Input.GetKeyDown(attack_key2)) { press_attack = true; } if (press_action || press_attack) { if (CraftBar.Get()) { CraftBar.Get().CancelSubSelection(); } } }