Пример #1
0
    // 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);
                }
            }
        }
    }
Пример #2
0
 void RemoveFocus()
 {
     if (focus != null)
     {
         focus = null;
     }
     motor.StopFollow();
 }
Пример #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;
 }
Пример #4
0
 public void StartInteraction(InteractionType interactionType)
 {
     Interacted.Raise(this, new InteractedWithEventArgs()
     {
         InteractionType = interactionType
     });
     if (_useGenericInteractionIndicators)
     {
         _interactionIndicatorRend.sprite = _interactingSprite;
         _interactionIndicatorPS.Stop();
     }
 }
Пример #5
0
 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);
        }
    }
Пример #7
0
 public void Replace(int delta)
 {
     Interacted?.Invoke(new NotifyEventArgs(this, $"Произведено перемещение на {delta} единиц."));
 }
Пример #8
0
 public void Interact()
 {
     Interacted?.Invoke();
     unityEvent?.Invoke();
 }
Пример #9
0
 public void Interacte(Entity entity, Direction attackDirection, Item item = null)
 {
     Interacted?.Invoke(this, new InteractEventArg(entity, attackDirection, item));
 }
Пример #10
0
 private void OnCollisionEnter(Collision collision)
 {
     Interacted.SafeRaise(this, collision.collider);
 }
Пример #11
0
 private void RaiseInteractionEvent(AttractorLoopPlayer attractorLoop, InteractedEventArgs args)
 {
     Interacted?.Invoke(attractorLoop, args);
 }
Пример #12
0
 public void Interact()
 {
     Interacted.Invoke();
     _audioSource.Play();
 }
Пример #13
0
 public void CheckState()
 {
     Interacted?.Invoke(new NotifyEventArgs(this, $"Программа работает? {isAppLaunched}"));
 }
Пример #14
0
 public void CloseApp()
 {
     isAppLaunched = false;
     Interacted?.Invoke(new NotifyEventArgs(this, "Программа закрыта."));
 }
Пример #15
0
 public void LaunchApp()
 {
     isAppLaunched = true;
     Interacted?.Invoke(new NotifyEventArgs(this, "Программа запущена."));
 }
Пример #16
0
 public void Interact(Interactor user)
 {
     OnInteract(user);
     Interacted?.Invoke(user);
 }
Пример #17
0
 /// <summary>
 /// Remove listeners.
 /// </summary>
 private void OnDestroy()
 {
     Interacted.RemoveListener(PerformInteraction);
     Arrived.RemoveListener(ArrivedAtInteraction);
 }
Пример #18
0
 public void Compress(int ratio)
 {
     Interacted?.Invoke(new NotifyEventArgs(this, $"Произведено сжатие с коэффициентом {ratio}."));
 }
Пример #19
0
 public void FollowTarget(Interacted newTarget)
 {
     agent.stoppingDistance = newTarget.radius * 1.5f;
     agent.updateRotation   = false;
     target = newTarget.interactionTransform;
 }
Пример #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);
Пример #21
0
 protected virtual void OnInteracted(IInteractable obj)
 {
     Interacted?.Invoke(obj);
 }