Esempio n. 1
0
    void Update()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 100, movementLayer))
            {
                motor.MoveToPoint(hit.point);
                RemoveFocus();
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                _Interactable interactable = hit.collider.GetComponent <_Interactable> ();
                if (interactable != null)
                {
                    SetFoucus(interactable);
                }
            }
        }
    }
Esempio n. 2
0
 void RemoveFocus()
 {
     if (focus != null)
     {
         focus.OnDefocused();
     }
     focus = null;
     motor.StopFollowingTarget();
 }
Esempio n. 3
0
    void SetFoucus(_Interactable newFocus)
    {
        if (newFocus != null)
        {
            if (focus != null)
            {
                focus.OnDefocused();
            }

            focus = newFocus;
            motor.FollowTarget(newFocus);
        }
        focus.OnFocused(transform);
    }
Esempio n. 4
0
 public void StopFollowingTarget()
 {
     target = null;
     agent.stoppingDistance = 0f;
     agent.updateRotation   = true;
 }
Esempio n. 5
0
 public void FollowTarget(_Interactable newTarget)
 {
     agent.stoppingDistance = 2f;
     agent.updateRotation   = false;
     target = newTarget;
 }