// 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(); }
/// <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; }
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); } }
public void Replace(int delta) { Interacted?.Invoke(new NotifyEventArgs(this, $"Произведено перемещение на {delta} единиц.")); }
public void Interact() { Interacted?.Invoke(); unityEvent?.Invoke(); }
public void Interacte(Entity entity, Direction attackDirection, Item item = null) { Interacted?.Invoke(this, new InteractEventArg(entity, attackDirection, item)); }
private void OnCollisionEnter(Collision collision) { Interacted.SafeRaise(this, collision.collider); }
private void RaiseInteractionEvent(AttractorLoopPlayer attractorLoop, InteractedEventArgs args) { Interacted?.Invoke(attractorLoop, args); }
public void Interact() { Interacted.Invoke(); _audioSource.Play(); }
public void CheckState() { Interacted?.Invoke(new NotifyEventArgs(this, $"Программа работает? {isAppLaunched}")); }
public void CloseApp() { isAppLaunched = false; Interacted?.Invoke(new NotifyEventArgs(this, "Программа закрыта.")); }
public void LaunchApp() { isAppLaunched = true; Interacted?.Invoke(new NotifyEventArgs(this, "Программа запущена.")); }
public void Interact(Interactor user) { OnInteract(user); Interacted?.Invoke(user); }
/// <summary> /// Remove listeners. /// </summary> private void OnDestroy() { Interacted.RemoveListener(PerformInteraction); Arrived.RemoveListener(ArrivedAtInteraction); }
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; }
/// <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);
protected virtual void OnInteracted(IInteractable obj) { Interacted?.Invoke(obj); }