示例#1
0
    void onTriggerEnterEvent(Collider2D col)
    {
        IStartDialogue    dialogue   = col.GetComponent <IStartDialogue>();
        ITransitionCamera transition = col.GetComponentInParent <ITransitionCamera>();
        IInteract         interact   = col.GetComponent <IInteract>();

        if (dialogue != null)
        {
            dialogue.StartDialogue();
        }

        if (transition != null)
        {
            transition.TransitionCamera();
        }

        if (interact != null)
        {
            interact.Interact();
        }

        if (col.gameObject.layer == LayerMask.NameToLayer("Kill"))
        {
            /* Death Count Statistics */
            StatisticsCollector.instance.deathCount++;
            transform.position = (m_lastCheckpoint + Vector2.up);
        }

        if (col.gameObject.layer == LayerMask.NameToLayer("Checkpoints"))
        {
            m_lastCheckpoint = transform.position;
        }
    }
 public void Interact()
 {
     if (interactable != null)
     {
         interactable.Interact();
     }
 }
        /// <summary>
        /// Checks
        /// </summary>
        private void StartNewInteraction()
        {
            IInteract interact = (_activeInstance == null) ? null : _activeInstance as IInteract;

            if (interact != null)
            {
                _activeInteraction            = interact.Interact(_player);
                _activeInteraction.OnDestroy += ResetInteraction;
            }
        }
    private void InteractWithObject(GameObject go)
    {
        IInteract interactable = go.GetComponent <IInteract>();

        if (interactable != null)
        {
            interactable.AbleToInteract();
            if (Input.GetKeyDown(KeyCode.F))
            {
                interactable.Interact();
            }
        }
    }
示例#5
0
文件: Player.cs 项目: baramyu/JoyGit
    void Interact()
    {
        IInteract interactAbleObj = onStayInteractList.FindLast(interactObj => interactObj.IsInteractAble());

        if (interactAbleObj != null)
        {
            SoundManager.instance.PlayerButtonClick();
            interactAbleObj.Interact();
        }
        else
        {
            SoundManager.instance.PlayerButtonHover();
        }
    }
示例#6
0
    void Update()
    {
        PlayerLook();
        Move();

        UpdateCurrentInteract();
        if (currentInteract != null)
        {
            currentInteract.Display();
            if (Input.GetKeyDown(KeyCode.E))
            {
                currentInteract.Interact();
            }
        }
    }
示例#7
0
 public void InteractWithObject()
 {
     if (interactScript != null)
     {
         interactScript.Interact();
         interactScript       = null;
         interactImage.sprite = null;
     }
     else
     {
         if (DGameSystem.player != null)
         {
             DGameSystem.player.GetComponent <DBattle>().Attack();
         }
     }
 }
示例#8
0
    void Update()
    {
        if (pXboxControllerManager == null)
        {
            pXboxControllerManager = XboxControllerManager.Instance;
        }
        if (_buttonPressedCounter == 0 && base.pXboxControllerManager.GetButtonPressed(base.pPlayerInformation, _interactButton))
        {
            IInteract  tInteractable       = null;
            Collider[] tOverlapcapsulehits = Physics.OverlapCapsule(topOfCapsule.position, bottomOfCapsule.position, 0.5f);
            for (int i = 0; i < tOverlapcapsulehits.Length; i++)
            {
                tInteractable = tOverlapcapsulehits[i].GetComponent <IInteract>();
                if (tInteractable != null && tInteractable != itemIAmHolding)
                {
#if UNITY_EDITOR
                    Debug.Log(tInteractable);
#endif
                    if (tInteractable.GetType() == typeof(ItemBase) && amIHoldingAnItem)
                    {
                        tInteractable = null;
                        continue;
                    }
                    tInteractable.Interact(this);
                    break;
                }
            }
            if (tInteractable == null && amIHoldingAnItem)
            {
                DropItem();
            }
            _buttonPressedCounter++;
        }
        else if (base.pXboxControllerManager.GetButtonPressed(base.pPlayerInformation, _interactButton))
        {
            _buttonPressedCounter++;
        }
        else
        {
            _buttonPressedCounter = 0;
        }
    }
示例#9
0
    public void InitiateInteraction()
    {
        IInteract interactor = VisibleObject() as IInteract;

        if (interactor == null)
        {
            //GD.Print("Nothing in range.");
            return;
        }
        Item.Uses interaction = GetActiveInteraction();

        Item item = interactor as Item;

        if (item != null && (item == hand || item == activeItem))
        {
            return;
        }

        interactor.Interact((object)this, interaction);
    }
示例#10
0
    private void Update()
    {
#if UNITY_STANDALONE
        _interact = (Input.GetKeyDown(_interactKey));
#endif
        if (!_interact)
        {
            return;
        }
        _interact = false;
        // Cast a ray straight down.
        RaycastHit hit;
        Physics.Raycast(transform.position, _thePlayer.RayDir, out hit, 1.5f);
        Debug.DrawRay(transform.position, _thePlayer.RayDir);
        // If it hits something...
        if (hit.collider == null)
        {
            return;
        }
        IInteract interactable = hit.collider.GetComponent <IInteract>();

        interactable?.Interact(_thePlayer);
        //_wasInteracting = interacting;
    }
示例#11
0
 public void GetInteractibleItem(IInteract iItem)
 {
     Debug.Log(iItem.ToString());
     iItem.Interact(this);
 }
示例#12
0
 public void Engage()
 {
     _engaged = true;
     _engagedInteraction.EngagedUnits.Add(this.gameObject);
     StartCoroutine(_engagedInteraction.Interact());
 }