public void TryInteract() { double hitTime = TapTapAimSetup.Tracker.GetTimeInMs(); if (!IsHitAttempted) { Debug.Log(QueueID + "tryHit Triggered. : " + hitTime + "Perfect time =>" + PerfectInteractionTimeInMs + " IsInBounds:" + IsInInteractionBound(hitTime)); if (InteractionID == TapTapAimSetup.Tracker.NextObjToHit) { if (IsInInteractionBound(hitTime)) { transform.GetComponent <Rigidbody2D>().simulated = false; transform.GetComponent <CircleCollider2D>().enabled = false; OnInteract.Invoke(this, null); TapTapAimSetup.HitSource.Play(); Outcome(hitTime, true); StartCoroutine(FadeOut()); } else { Debug.LogError($" HitId:{InteractionID} Hit attempted but missed. Time difference: {hitTime - PerfectInteractionTimeInMs}ms"); Outcome(hitTime, false); } } } else { Debug.LogError($" HitId:{InteractionID} Hit already attempted. Time difference: {hitTime - PerfectInteractionTimeInMs}ms"); } }
// Method called by the player gameobject that is interacting with this interactable public void Interact(GameObject playerInteracting) { if (OnInteract != null) { OnInteract.Invoke(playerInteracting); } }
void Interact() { if (onInteract != null) { onInteract.Invoke(); } }
public static void Transmit(InteractMessage message) { if (OnInteract != null) { OnInteract.Invoke(message); } }
public override void Click(UIMouseEvent evt) { base.Click(evt); if (CanInteract?.Invoke(Item, Main.mouseItem) ?? true) { Item.newAndShiny = false; Player player = Main.LocalPlayer; if (ItemSlot.ShiftInUse) { Main.NewText("move to inventory"); return; } Item temp = Item; Utils.Swap(ref temp, ref Main.mouseItem); Item = temp; if (Item.stack > 0) { AchievementsHelper.NotifyItemPickup(player, Item); } if (Item.type == 0 || Item.stack < 1) { Item = new Item(); } if (Main.mouseItem.IsTheSameAs(Item)) { Utils.Swap(ref Item.favorited, ref Main.mouseItem.favorited); if (Item.stack != Item.maxStack && Main.mouseItem.stack != Main.mouseItem.maxStack) { if (Main.mouseItem.stack + Item.stack <= Main.mouseItem.maxStack) { Item.stack += Main.mouseItem.stack; Main.mouseItem.stack = 0; } else { int delta = Main.mouseItem.maxStack - Item.stack; Item.stack += delta; Main.mouseItem.stack -= delta; } } } if (Main.mouseItem.type == 0 || Main.mouseItem.stack < 1) { Main.mouseItem = new Item(); } if (Main.mouseItem.type > 0 || Item.type > 0) { Terraria.Recipe.FindRecipes(); Main.PlaySound(7); } OnInteract?.Invoke(); } SendUpdate(); }
public override void RightClickContinuous(UIMouseEvent evt) { OnInteract?.Invoke(); Player player = Main.LocalPlayer; Item.newAndShiny = false; if (player.itemAnimation > 0) { return; } //bool specialClick = false; //if (ItemLoader.CanRightClick(Item) && Main.mouseRightRelease) //{ // specialClick = true; //} //if (specialClick && Main.mouseRightRelease) //{ // OnInteract?.Invoke(); // return; //} if (Main.stackSplit <= 1 && Main.mouseRight) { if ((Main.mouseItem.IsTheSameAs(Item) || Main.mouseItem.type == 0) && (Main.mouseItem.stack < Main.mouseItem.maxStack || Main.mouseItem.type == 0)) { if (Main.mouseItem.type == 0) { Main.mouseItem = Item.Clone(); Main.mouseItem.stack = 0; if (Item.favorited && Item.maxStack == 1) { Main.mouseItem.favorited = true; } Main.mouseItem.favorited = false; } Main.mouseItem.stack++; Item.stack--; if (Item.stack <= 0) { Item = new Item(); } Recipe.FindRecipes(); Main.soundInstanceMenuTick.Stop(); Main.soundInstanceMenuTick = Main.soundMenuTick.CreateInstance(); Main.PlaySound(12); Main.stackSplit = Main.stackSplit == 0 ? 15 : Main.stackDelay; } } OnInteract?.Invoke(); }
void Update() { // more to be added based on need if (Input.GetKeyDown(PAUSE)) { OnPause?.Invoke(); } if (!DialogueManager.InConversation && !TimelineController.InCutscene) { Horizontal = Input.GetAxisRaw("Horizontal"); Vertical = Input.GetAxisRaw("Vertical"); if (Input.GetKeyDown(INTERACT)) { OnInteract?.Invoke(); } if (Input.GetKeyUp(INTERACT)) { OnStopInteract?.Invoke(); } if (!EventSystem.current.IsPointerOverGameObject()) { if (Input.GetMouseButtonDown(0)) { OnMouseClickLeft?.Invoke(); } if (Input.GetMouseButtonDown(1)) { OnMouseClickRight?.Invoke(); } if (Input.GetMouseButtonUp(0)) { OnMouseUpLeft?.Invoke(); } if (Input.GetMouseButtonUp(1)) { OnMouseUpRight?.Invoke(); } } } else { Horizontal = 0; Vertical = 0; if (Input.GetKeyDown(INTERACT) || Input.GetKeyDown(KeyCode.Space)) { OnNextDialogue?.Invoke(); } } int scrollDirection = (int)Input.mouseScrollDelta.y; if (scrollDirection != 0) { OnScroll?.Invoke(scrollDirection); } }
void Update() { if (Input.GetKey(settings.forward)) { applyAcceleration(gameObject.transform.forward); } if (Input.GetKey(settings.backward)) { applyAcceleration(-gameObject.transform.forward); } if (Input.GetKey(settings.left)) { applyAcceleration(Quaternion.Euler(0, -90, 0) * gameObject.transform.forward); } if (Input.GetKey(settings.right)) { applyAcceleration(Quaternion.Euler(0, 90, 0) * gameObject.transform.forward); } if (Input.GetKey(settings.jump)) { applyAcceleration(gameObject.transform.up); } if (Input.GetKey(settings.fire)) { inventoryController.FireCurrentGun(); } if (Input.GetKeyDown(settings.interaction)) { OnInteract?.Invoke(this); } if (Input.GetKeyDown(settings.openAlliesMenu)) { _toggleMouseFollow = false; UI.OpenAlliesMenu(_alliesCommander); } if (Input.GetKeyUp(settings.openAlliesMenu)) { _toggleMouseFollow = true; UI.CloseAlliesMenu(); } if (_toggleMouseFollow) { _yaw += speedH * Input.GetAxis("Mouse X"); _pitch -= speedV * Input.GetAxis("Mouse Y"); transform.eulerAngles = new Vector3(0f, _yaw, 0f); camera.transform.eulerAngles = new Vector3(_pitch, _yaw, 0f); gunPlace.transform.eulerAngles = new Vector3(_pitch, _yaw, 0f); } }
public void Interact(PlayerCharacterLogic playerCharacter) { damageEntity.Attack(playerCharacter); if (playerCharacter.CanGetDamage) { OnInteract.Invoke(transform.position); } }
public void Interact() { if (playerCanInteract) { OnInteract?.Invoke(this, new OnInteractEventArgs() { interactingPlayer = this }); } }
/// <summary> /// API for controlling the torch state from a script /// </summary> /// <param name="lit">Whether to set the torch to be lit or not</param> public void SetLit(bool lit) { // Exit if state is already set if (isLit == lit) { return; } isLit = lit; onInteract?.Invoke(isLit); flameVFX.SetActive(isLit); }
protected override void Activate() { IsInteractable = false; if (OnInteract != null) { OnInteract.Invoke(); } foreach (Event item in events) { item.LaunchEvent(); } }
public virtual void Interact(InteractionHandler handler) { if (OnInteract != null) { OnInteract.Invoke(); } canAct = false; if (OnLeaveRange != null) { OnLeaveRange.Invoke(); } }
public virtual void Interact(Interactor interactor) { OnInteract?.Invoke(interactor); if (_hasAnimator) { animator.SetTrigger(InteractTrigger); } if (_hasAudioClip) { AudioManager.Instance.PlaySound(audioClip); } }
public void Interact() { if (!IsActive) { return; } if (audioClip != null) { audioSource.PlayOneShot(audioClip); } onInteract?.Invoke(this); }
private void HandleInteraction() { List <Collider2D> overlapColls = new List <Collider2D>(Physics2D.OverlapCircleAll(interactionPoint.position, interactionRadius, interactableLayer)); if (overlapColls.Count <= 0) { interactionCanvas.enabled = false; return; } for (int i = overlapColls.Count - 1; i >= 0; i--) { Interactable inter = overlapColls[i].GetComponent <Interactable>(); if (inter == null) { overlapColls.RemoveAt(i); } else if (!inter.CanInteract) { overlapColls.RemoveAt(i); } } if (overlapColls.Count <= 0) { interactionCanvas.enabled = false; return; } Interactable interactable = overlapColls[0].GetComponent <Interactable>(); if (!interactionCanvas.enabled) { interactionText.text = interactable.InteractionMessage; interactionCanvas.enabled = true; } if (Input.GetKeyDown(KeyCode.E)) { OnInteract?.Invoke(interactable); interactable.Interact(this); movement.moveInput = Vector2.zero; interactionCanvas.enabled = false; soundSystem.PlaySfx("pickup"); } }
private void Update() { _interact.transform.localScale = Scale; //_empty.transform.position = transform.TransformPoint(Offset); if (!_used && _interact.activeInHierarchy && Input.GetKeyDown(KeyCode.E)) { _used = !Multiuse; OnInteract?.Invoke(); if (!Multiuse) { _interact.SetActive(false); } } }
IEnumerator AfterTaskEvents() { yield return(new WaitForSeconds(timeConsumes)); OnInteract?.Invoke(); LoadingBar.Instance.UISlider.gameObject.SetActive(false); LoadingBar.Instance.Reset(); if (ItemInside != null) { DialogueDisplayer.Instance.DisplayMessage($"You've got a {ItemInside.objectName}."); Inventory.instance.AddItemToInventory(ItemInside.id); } }
private void OnMouseDown() { // Cast ray to get position of touch Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 50f)) { Vector3 position = hit.point; HexCell cell = GetCell(position); if (cell != null) { OnInteract?.Invoke(this, cell); } } }
/// <summary> /// Interact with this object. An event is raised /// </summary> public virtual void Interact() { if (hasInteract && interactOnce) { return; } hasInteract = true; /// A listener must decide what happens with every object InteractEventArgs interactArgs = (items.Length > 0) ? new InteractEventArgs(InteractionType, nextDoor, items[0].audioClip, Items) : new InteractEventArgs(InteractionType, nextDoor, items); OnInteract?.Invoke(this, interactArgs); }
protected override void Activate() { events[0].LaunchEvent(); audioSources[0].Play(); DialogueBoxController.Instance.currentAudio = audioSources[0]; if (OnInteract != null) { OnInteract.Invoke(); } if (events.Count > 1) { events.RemoveAt(0); audioSources.RemoveAt(0); } IsInteractable = false; Invoke("SetInteractable", duration); }
protected override void Activate() { if (IsInvoking()) { IsInteractable = false; return; } myAnimation.Play(); IsInteractable = false; Invoke("SetInteractable", duration); if (OnInteract != null) { OnInteract.Invoke(); } foreach (var item in events) { item.LaunchEvent(); } }
private void OnTriggerStay2D(Collider2D collision) { if (_triggerActivatorsTegs.Contains(collision.tag)) { OnStay?.Invoke(_args); if (Controllers.InputController.Instance.ControlParams.Interacting) { OnInteract?.Invoke(_args); //if (IsInteractble) //{ // //_args.boolMeta = !_args.boolMeta; // //_animator?.SetBool("On", _args.boolMeta); //} if (_disableAfterInterract) { Deactivate(); } } } }
/* * public override void ScrollWheel(UIScrollWheelEvent evt) * { * if (!Main.keyState.IsKeyDown(Keys.LeftAlt)) return; * * if (evt.ScrollWheelValue > 0) * { * if (Main.mouseItem.type == Item.type && Main.mouseItem.stack < Main.mouseItem.maxStack) * { * Main.mouseItem.stack++; * if (--Item.stack <= 0) Item.TurnToAir(); * } * else if (Main.mouseItem.IsAir) * { * Main.mouseItem = Item.Clone(); * Main.mouseItem.stack = 1; * if (--Item.stack <= 0) Item.TurnToAir(); * } * } * else if (evt.ScrollWheelValue < 0) * { * if (Item.type == Main.mouseItem.type && Item.stack < Item.maxStack) * { * Item.stack++; * if (--Main.mouseItem.stack <= 0) Main.mouseItem.TurnToAir(); * } * else if (Item.IsAir) * { * Item = Main.mouseItem.Clone(); * Item.stack = 1; * if (--Main.mouseItem.stack <= 0) Main.mouseItem.TurnToAir(); * } * } * } */ public override void Click(UIMouseEvent evt) { Item.newAndShiny = false; Player player = Main.LocalPlayer; if (ItemSlot.ShiftInUse) { Item = Utility.PutItemInInventory(Item); OnInteract?.Invoke(); base.Click(evt); return; } if (Main.mouseItem.IsAir) { Main.mouseItem = Network.ExtractItem(Item); } else { Network.InsertItem(ref Main.mouseItem); Main.PlaySound(SoundID.Grab); } if (Item.stack > 0) { AchievementsHelper.NotifyItemPickup(player, Item); } if (Main.mouseItem.type > 0 || Item.type > 0) { Recipe.FindRecipes(); Main.PlaySound(SoundID.Grab); } OnInteract?.Invoke(); base.Click(evt); }
private void GetKeyboardInput() { if (Input.GetKey(_fireButton) && !EventSystem.current.IsPointerOverGameObject()) { OnAttackTrigger?.Invoke(); } if (Input.GetKeyUp(_fireButton)) { OnAttackCancel?.Invoke(); } if (Input.GetKey(_interactButton)) { OnInteract?.Invoke(); } IsJumpButtonPressed = Input.GetKeyDown(_jumpButton) ? true : false; IsDashButtonPressed = (Input.GetKeyDown(_dashButton)) ? true : false; }
public virtual void Interact() { if (isReuseable || !hasBeenUsed) { OnInteract?.Invoke(); OnUseText?.Invoke(useText); if (objAudioSource.clip != null) { objAudioSource.Play(); } else { Debug.LogWarning(this.gameObject + " tried to play a null clip"); } hasBeenUsed = true; if (!this.isReuseable) { displayText = string.Empty; OnLookedAtStateChange?.Invoke(); // If the object changes state, look at new display text } } }
public virtual void Interact(GameObject interacting) { OnInteract?.Invoke(this, interacting); }
virtual protected void Update() { DebugInputs(); if (!playerAlive) { return; } #region Cooldowns (only look here if you dare) if (_abilityOneCooldown <= playerStats.abilityOneCooldown.GetValue()) { _abilityOneCooldown += Time.deltaTime; UIManager.current.updateUICallback.Invoke(); a1 = false; } else if (_abilityOneCooldown >= playerStats.abilityOneCooldown.GetValue() && !a1) { //abilityOne.Stop(); //abilityOne.Play(); a1 = true; } if (_abilityTwoCooldown <= playerStats.abilityTwoCooldown.GetValue()) { _abilityTwoCooldown += Time.deltaTime; UIManager.current.updateUICallback.Invoke(); a2 = false; } else if (_abilityTwoCooldown >= playerStats.abilityTwoCooldown.GetValue() && !a2) { abilityTwo.Stop(); abilityTwo.Play(); a2 = true; } if (_abilityThreeCooldown <= playerStats.abilityThreeCooldown.GetValue()) { _abilityThreeCooldown += Time.deltaTime; UIManager.current.updateUICallback.Invoke(); a3 = false; } else if (_abilityThreeCooldown >= playerStats.abilityThreeCooldown.GetValue() && !a3) { abilityThree.Stop(); abilityThree.Play(); a3 = true; } #endregion if (Input.GetKeyDown(KeyCode.Space)) { if (onInteractCallback != null) { onInteractCallback.Invoke(); } } }
public void Interact(string dialogue) { OnInteract?.Invoke(dialogue); }
public override void Interact() { OnInteract?.Invoke(this, new ButtonInfo(_FloorNumber)); base.Interact(); }