Exemplo n.º 1
0
 public void OnInteract(InputAction.CallbackContext context)
 {
     if (context.phase == InputActionPhase.Performed)
     {
         InteractEvent.Invoke();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 3
0
 public override void Interact()
 {
     base.Interact();
     talk();
     if (InteractEvent != null)
     {
         InteractEvent.Invoke(this);
     }
 }
Exemplo n.º 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;
    }
Exemplo n.º 5
0
    public virtual bool Interact(Interacter source)
    {
        if (IsInteractable(source))
        {
            OnInteract.Invoke(source, this);
            return(true);
        }

        return(false);
    }
Exemplo n.º 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;
    }
Exemplo n.º 7
0
    public virtual bool InteractWith(Pawn source)
    {
        if (IgnoresInteraction)
        {
            return(false);
        }

        OnInteract.Invoke(source);
        return(true);
    }
Exemplo n.º 8
0
 private void UseButton()
 {
     PlayOneSoundRandom();
     onInteract.Invoke(parent);
     if (numberUses > 0)
     {
         numberUses--;
         if (numberUses <= 0)
         {
             Destroy(this);
         }
     }
 }
Exemplo n.º 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);
             }
         }
     }
 }
Exemplo n.º 10
0
 public override void Interact()
 {
     if (Active)
     {
         if (CurrentPage >= Pages.Count - 1)
         {
             Hide();
             InteractEvent?.Invoke(this, null);
         }
         else
         {
             CurrentPage++;
             Stopwatch.Restart();
         }
     }
 }
Exemplo n.º 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;
    }
Exemplo n.º 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);
        }
    }
Exemplo n.º 13
0
 public override void Interact()
 {
     InteractEvent?.Invoke(this, null);
 }
Exemplo n.º 14
0
 public void InvokeGameFlowProgression(int gameStateId)
 {
     gameFlowEvent.Invoke(gameStateId);
 }
Exemplo n.º 15
0
 public void Interact(GameObject caller)
 {
     OnInteracted?.Invoke(caller);
 }
Exemplo n.º 16
0
 public void InvokeInteract(int itemId)
 {
     interactEvent.Invoke(itemId);
 }
Exemplo n.º 17
0
 private void OnInteract()
 {
     //Debug.Log("OnInteract");
     InteractEvent?.Invoke();
 }
Exemplo n.º 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);
        }
Exemplo n.º 19
0
 public void invokeEvent(InteractEventArgs interactEventArgs)
 {
     InteractEvent?.Invoke(this, interactEventArgs);
 }