void SetTarget(Interactable newTarget) { if (newTarget == target) { return; } if (target != null) { target.OnRemoveTarget(); } target = newTarget; if (target == null) { InteractPanel.Hide(); } else { InteractPanel.Show(target.text); target.OnSetAsTarget(); } }
// Update is called once per frame void Update() { if (EventSystem.current.IsPointerOverGameObject()) { return; } if (Input.GetMouseButtonDown(0)) { // If no battle is happening -> Move normally if (BattleSystem.instance.state == BattleState.END) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, movementMask)) { // Move to what we hit motor.MoveToPoint(hit.point); RemoveFocus(); } } } //TODO: make UI show up for interaction menu if (Input.GetMouseButtonDown(1)) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { Interactable interactable = hit.collider.GetComponent <Interactable>(); if (interactable != null) { //If no battle is happening -> Activate interaction panel if (BattleSystem.instance.state == BattleState.END) { interactOriginPoint.transform.position = Input.mousePosition; InteractPanel panel = interactPanel.GetComponent <InteractPanel>(); panel.setInteractions(interactable.interactions, interactable); interactPanel.SetActive(true); } } } } }
void Awake() { instance = this; Hide(); }