示例#1
0
 public void OnInteract(InputAction.CallbackContext context)
 {
     if (context.phase == InputActionPhase.Performed)
     {
         InteractEvent.Invoke();
     }
 }
示例#2
0
 public void OnInteract(InputAction.CallbackContext context)
 {
     if ((context.phase == InputActionPhase.Performed) &&
         (_gameStateManager.CurrentGameState == GameState.Gameplay))                // Interaction is only possible when in gameplay GameState
     {
         InteractEvent.Invoke();
     }
 }
示例#3
0
 public override void Interact()
 {
     base.Interact();
     talk();
     if (InteractEvent != null)
     {
         InteractEvent.Invoke(this);
     }
 }
示例#4
0
    private void Grab(GameObject p_toGrab)
    {
        InteractEvent.Invoke();
        m_grabbedObject       = p_toGrab;
        m_grabbedObjectScript = m_grabbedObject.GetComponent <Grabbable>();

        m_grabbedObjectScript.Grab(gameObject);
        m_distanceBetweenObjectAndCameraDueToMeshSize = m_grabbedObjectScript.CalculateDistanceToCameraOffset();
        m_grabbedDuringThisFrame = true;
    }
示例#5
0
    public virtual bool Interact(Interacter source)
    {
        if (IsInteractable(source))
        {
            OnInteract.Invoke(source, this);
            return(true);
        }

        return(false);
    }
示例#6
0
    private void ThrowObject(float p_strength)
    {
        InteractEvent.Invoke();

        m_grabbedObjectScript.Drop(gameObject);
        m_grabbedObjectScript.Throw(p_strength);

        m_grabbedObject       = null;
        m_grabbedObjectScript = null;
    }
    public virtual bool InteractWith(Pawn source)
    {
        if (IgnoresInteraction)
        {
            return(false);
        }

        OnInteract.Invoke(source);
        return(true);
    }
示例#8
0
 private void UseButton()
 {
     PlayOneSoundRandom();
     onInteract.Invoke(parent);
     if (numberUses > 0)
     {
         numberUses--;
         if (numberUses <= 0)
         {
             Destroy(this);
         }
     }
 }
示例#9
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.E))
     {
         if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out _hit, InteractDistance))
         {
             if (_hit.collider.gameObject != null)
             {
                 InteractEvent.Invoke(_hit.collider.gameObject);
             }
         }
     }
 }
示例#10
0
 public override void Interact()
 {
     if (Active)
     {
         if (CurrentPage >= Pages.Count - 1)
         {
             Hide();
             InteractEvent?.Invoke(this, null);
         }
         else
         {
             CurrentPage++;
             Stopwatch.Restart();
         }
     }
 }
示例#11
0
    IEnumerator OperateSwitch(bool opened)
    {
        while (working)
        {
            yield return(null);
        }

        working = true;
        anim.SetBool("Opened", opened);

        if (opened)
        {
            OnSwitchOn.Invoke(this);
        }
        else
        {
            OnSwitchOff.Invoke(this);
        }

        yield return(new WaitForSeconds(1));

        working = false;
    }
示例#12
0
    void Update()
    {
        if (target != null && agent.hasPath && agent.remainingDistance <= interactDistance)
        {
            Event?.Invoke(gameObject, target);
            target = null;
        }

        if (EventSystem.current.IsPointerOverGameObject() || !Input.GetMouseButton(0))
        {
            return;
        }

        Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 100))
        {
            var interaction = hit.transform.gameObject.GetComponent <Interactable>();
            target = (interaction == null) ? null : hit.transform.gameObject;

            agent.SetDestination(hit.point);
        }
    }
示例#13
0
 public override void Interact()
 {
     InteractEvent?.Invoke(this, null);
 }
示例#14
0
 public void InvokeGameFlowProgression(int gameStateId)
 {
     gameFlowEvent.Invoke(gameStateId);
 }
示例#15
0
 public void Interact(GameObject caller)
 {
     OnInteracted?.Invoke(caller);
 }
示例#16
0
 public void InvokeInteract(int itemId)
 {
     interactEvent.Invoke(itemId);
 }
示例#17
0
 private void OnInteract()
 {
     //Debug.Log("OnInteract");
     InteractEvent?.Invoke();
 }
示例#18
0
        public void AddInteractionController()
        {
            var controller     = new SmartController();
            var buttonsCreated = StaticServiceLocator.ContainsService <List <IButtonAble> >();

            if (!buttonsCreated)
            {
                var interactButton = new List <IButtonAble>
                {
                    new KeyButton(Keys.E),
                    new GamePadButton(Buttons.A)
                };
                StaticServiceLocator.AddService(interactButton);
            }
            var buttons     = StaticServiceLocator.GetService <List <IButtonAble> >();
            var smartButton = new CompositeSmartButton(buttons)
            {
                OnButtonJustPressed = (sender, args) =>
                {
                    if (!DialogBox.Interact())
                    {
                        InteractEvent?.Invoke(this, null);
                    }
                }
            };

            controller.AddButton(smartButton);
            var upButton = new List <IButtonAble> {
                new DirectionGamePadButton(Buttons.DPadUp, PlayerIndex.One, false)
            };
            var smartUpButton = new CompositeSmartButton(upButton)
            {
                OnButtonJustPressed = (sender, args) =>
                {
                    DialogBox.Up();
                }
            };

            controller.AddButton(smartUpButton);
            var downButton = new List <IButtonAble> {
                new DirectionGamePadButton(Buttons.DPadDown, PlayerIndex.One, false)
            };
            var smartDownButton = new CompositeSmartButton(downButton)
            {
                OnButtonJustPressed = (sender, args) =>
                {
                    DialogBox.Down();
                }
            };

            controller.AddButton(smartDownButton);
            var optionsButtons = new List <IButtonAble>
            {
                new KeyButton(Keys.Escape),
                new GamePadButton(Buttons.Start)
            };
            var optionsAction = new CompositeSmartButton(optionsButtons)
            {
                OnButtonJustPressed = (sender, args) =>
                {
                    _backButtonClickEvent.Invoke(this, null);
                }
            };

            controller.AddButton(optionsAction);
            UpdateList.Add(controller);
        }
示例#19
0
 public void invokeEvent(InteractEventArgs interactEventArgs)
 {
     InteractEvent?.Invoke(this, interactEventArgs);
 }