// Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, movementMask))
            {
                motor.MoveToPoint(hit.point);
                RemoveFocus();
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100))
            {
                Interacted interactable = hit.collider.GetComponent <Interacted>();
                if (interactable != null)
                {
                    SetFocus(interactable);
                }
            }
        }
    }
 void RemoveFocus()
 {
     if (focus != null)
     {
         focus = null;
     }
     motor.StopFollow();
 }
Beispiel #3
0
 /// <summary>
 /// Create list and Add Listeners to the events.
 /// </summary>
 private void Start()
 {
     itemManager          = new ItemManager(hands);
     interactionQueue     = new List <NavigationInteraction>();
     interactionQueueText = new Dictionary <NavigationInteraction, GameObject>();
     Interacted.AddListener(PerformInteraction);
     Arrived.AddListener(ArrivedAtInteraction);
     currentPosition = start.position;
 }
Beispiel #4
0
 public void StartInteraction(InteractionType interactionType)
 {
     Interacted.Raise(this, new InteractedWithEventArgs()
     {
         InteractionType = interactionType
     });
     if (_useGenericInteractionIndicators)
     {
         _interactionIndicatorRend.sprite = _interactingSprite;
         _interactionIndicatorPS.Stop();
     }
 }
 void SetFocus(Interacted newFocus)
 {
     if (newFocus != focus)
     {
         if (focus != null)
         {
             focus.OffFocus();
         }
         focus = newFocus;
         motor.FollowTarget(newFocus);
     }
     newFocus.OnFocus(transform);
 }
    void Update()
    {
        move.x = Input.GetAxis("Horizontal");
        move.y = Input.GetAxis("Vertical");

        mouse.x = Input.mousePosition.x;
        mouse.y = Input.mousePosition.y;

        interactFocus = CheckForInteractable();

        if (interactFocus != null && Input.GetKeyDown(KeyCode.E))
        {
            // Send the interactFocus so it can be acted upon after the event
            Interacted.Invoke(this, interactFocus.interact());
        }

        if (Input.GetKeyDown(KeyCode.I) || Input.GetKeyDown(KeyCode.Tab))
        {
            ShowInventory.Invoke(this);
        }
    }
Beispiel #7
0
 public void Replace(int delta)
 {
     Interacted?.Invoke(new NotifyEventArgs(this, $"Произведено перемещение на {delta} единиц."));
 }
Beispiel #8
0
 public void Interact()
 {
     Interacted?.Invoke();
     unityEvent?.Invoke();
 }
Beispiel #9
0
 public void Interacte(Entity entity, Direction attackDirection, Item item = null)
 {
     Interacted?.Invoke(this, new InteractEventArg(entity, attackDirection, item));
 }
Beispiel #10
0
 private void OnCollisionEnter(Collision collision)
 {
     Interacted.SafeRaise(this, collision.collider);
 }
Beispiel #11
0
 private void RaiseInteractionEvent(AttractorLoopPlayer attractorLoop, InteractedEventArgs args)
 {
     Interacted?.Invoke(attractorLoop, args);
 }
Beispiel #12
0
 public void Interact()
 {
     Interacted.Invoke();
     _audioSource.Play();
 }
Beispiel #13
0
 public void CheckState()
 {
     Interacted?.Invoke(new NotifyEventArgs(this, $"Программа работает? {isAppLaunched}"));
 }
Beispiel #14
0
 public void CloseApp()
 {
     isAppLaunched = false;
     Interacted?.Invoke(new NotifyEventArgs(this, "Программа закрыта."));
 }
Beispiel #15
0
 public void LaunchApp()
 {
     isAppLaunched = true;
     Interacted?.Invoke(new NotifyEventArgs(this, "Программа запущена."));
 }
Beispiel #16
0
 public void Interact(Interactor user)
 {
     OnInteract(user);
     Interacted?.Invoke(user);
 }
Beispiel #17
0
 /// <summary>
 /// Remove listeners.
 /// </summary>
 private void OnDestroy()
 {
     Interacted.RemoveListener(PerformInteraction);
     Arrived.RemoveListener(ArrivedAtInteraction);
 }
Beispiel #18
0
 public void Compress(int ratio)
 {
     Interacted?.Invoke(new NotifyEventArgs(this, $"Произведено сжатие с коэффициентом {ratio}."));
 }
 public void FollowTarget(Interacted newTarget)
 {
     agent.stoppingDistance = newTarget.radius * 1.5f;
     agent.updateRotation   = false;
     target = newTarget.interactionTransform;
 }
Beispiel #20
0
 /// <summary>
 /// Invoked after a player interacted with something.
 /// </summary>
 /// <param name="ev">The <see cref="InteractedEventArgs"/> instance.</param>
 public static void OnInteracted(InteractedEventArgs ev) => Interacted.InvokeSafely(ev);
Beispiel #21
0
 protected virtual void OnInteracted(IInteractable obj)
 {
     Interacted?.Invoke(obj);
 }