// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, movementMask)) { motor.MoveToPoint(hit.point); // Move player to what we hit Debug.Log(hit.transform.name); if (hit.transform.tag == "JiYeon") { FindObjectOfType <AudioManager>().Play("Win", 0.2f); Button arrow = FindObjectOfType <StarbucksGameManager>().arrow; if (arrow.gameObject.activeSelf) { arrow.StopArrowIndicator(); } StarbucksJiYeon jiYeon = hit.collider.GetComponent <StarbucksJiYeon>(); if (jiYeon != null) { SetFocus(jiYeon); } } else { RemoveFocus(); } // Stop focusing any objects } } }
void RemoveFocus() { if (focus != null) { focus.OnDefocused(); } focus = null; motor.StopFollowingTarget(); }
void SetFocus(StarbucksJiYeon newFocus) { if (newFocus != focus) { if (focus != null) { focus.OnDefocused(); } focus = newFocus; motor.FollowTarget(newFocus); } newFocus.OnFocused(transform); }
public void FollowTarget(StarbucksJiYeon newTarget) { target = newTarget.InteractionTransform; }