Пример #1
0
        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");
            }
        }
 public static void Transmit(InteractMessage message)
 {
     if (OnInteract != null)
     {
         OnInteract.Invoke(message);
     }
 }
 // Method called by the player gameobject that is interacting with this interactable
 public void Interact(GameObject playerInteracting)
 {
     if (OnInteract != null)
     {
         OnInteract.Invoke(playerInteracting);
     }
 }
Пример #4
0
        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();
        }
Пример #5
0
 /// <summary>
 /// Assigns all events to the selectable, since there are so many of them.
 /// </summary>
 /// <param name="selectable">The selectable to assign events to.</param>
 /// <param name="i">The index of the methods array.</param>
 /// <param name="j">The number to pass into the method.</param>
 private void AssignSelectable(KMSelectable selectable, ref int i, ref int j)
 {
     if (OnCancel != null && i < OnCancel.Length)
     {
         selectable.OnCancel += OnCancel[i](j);
     }
     if (OnDefocus != null && i < OnDefocus.Length)
     {
         selectable.OnDefocus += OnDefocus[i](j);
     }
     if (OnDeselect != null && i < OnDeselect.Length)
     {
         selectable.OnDeselect += OnDeselect[i](j);
     }
     if (OnFocus != null && i < OnFocus.Length)
     {
         selectable.OnFocus += OnFocus[i](j);
     }
     if (OnHighlight != null && i < OnHighlight.Length)
     {
         selectable.OnHighlight += OnHighlight[i](j);
     }
     if (OnHighlightEnded != null && i < OnHighlightEnded.Length)
     {
         selectable.OnHighlightEnded += OnHighlightEnded[i](j);
     }
     if (OnInteract != null && i < OnInteract.Length)
     {
         selectable.OnInteract += OnInteract[i](j);
     }
     if (OnInteractEnded != null && i < OnInteractEnded.Length)
     {
         selectable.OnInteractEnded += OnInteractEnded[i](j);
     }
     if (OnLeft != null && i < OnLeft.Length)
     {
         selectable.OnLeft += OnLeft[i](j);
     }
     if (OnRight != null && i < OnRight.Length)
     {
         selectable.OnRight += OnRight[i](j);
     }
     if (OnSelect != null && i < OnSelect.Length)
     {
         selectable.OnSelect += OnSelect[i](j);
     }
 }
Пример #6
0
        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();
        }
Пример #7
0
    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);
        }
    }
Пример #8
0
        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);
            }
        }
Пример #9
0
    public void Interact(PlayerCharacterLogic playerCharacter)
    {
        damageEntity.Attack(playerCharacter);

        if (playerCharacter.CanGetDamage)
        {
            OnInteract.Invoke(transform.position);
        }
    }
Пример #10
0
 public void Interact()
 {
     if (playerCanInteract)
     {
         OnInteract?.Invoke(this, new OnInteractEventArgs()
         {
             interactingPlayer = this
         });
     }
 }
Пример #11
0
 public virtual void Interact(InteractionHandler handler)
 {
     if (OnInteract != null)
     {
         OnInteract.Invoke();
     }
     canAct = false;
     if (OnLeaveRange != null)
     {
         OnLeaveRange.Invoke();
     }
 }
Пример #12
0
 public virtual void Interact(Interactor interactor)
 {
     OnInteract?.Invoke(interactor);
     if (_hasAnimator)
     {
         animator.SetTrigger(InteractTrigger);
     }
     if (_hasAudioClip)
     {
         AudioManager.Instance.PlaySound(audioClip);
     }
 }
 protected override void Activate()
 {
     IsInteractable = false;
     if (OnInteract != null)
     {
         OnInteract.Invoke();
     }
     foreach (Event item in events)
     {
         item.LaunchEvent();
     }
 }
    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 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);
         }
     }
 }
Пример #16
0
    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");
        }
    }
Пример #17
0
        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);
                }
            }
        }
Пример #18
0
        /// <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();
        }
    }
Пример #21
0
 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();
             }
         }
     }
 }
Пример #22
0
        /*
         *      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);
        }
Пример #23
0
        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;
        }
Пример #24
0
 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
         }
     }
 }
Пример #25
0
 public void Interact(string dialogue)
 {
     OnInteract?.Invoke(dialogue);
 }
Пример #26
0
 public override void Interact()
 {
     OnInteract?.Invoke(this, new ButtonInfo(_FloorNumber));
     base.Interact();
 }
Пример #27
0
 public void HandleInteract(Vector3 interactionPoint)
 {
     Debug.Log(gameObject.name);
     OnInteract?.Invoke(interactionPoint);
 }
Пример #28
0
 internal IEnumerator Interact()
 {
     return(OnInteract?.Invoke());
 }
Пример #29
0
 public virtual void Interact(GameObject interacting)
 {
     OnInteract?.Invoke(this, interacting);
 }
Пример #30
0
    // Start is called before the first frame update

    public override void Interact(PlayerInteraction playerInteraction)
    {
        Debug.Log("Interacted");
        OnInteract?.Invoke(this);
    }