示例#1
0
    private bool InteractHands(bool isDrag)
    {
        if (UIManager.Hands.CurrentSlot.Item != null && objectBehaviour.visibleState)
        {
            InputTrigger inputTrigger = UIManager.Hands.CurrentSlot.Item.GetComponent <InputTrigger>();

            if (inputTrigger != null)
            {
                bool interacted       = false;
                var  interactPosition = Camera.main.ScreenToWorldPoint(CommonInput.mousePosition);
                if (isDrag)
                {
                    interacted = inputTrigger.TriggerDrag(interactPosition);
                }
                else
                {
                    interacted = inputTrigger.Trigger(interactPosition);
                }
                if (interacted)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
示例#2
0
    public void LeftAction(InputTrigger trigger)
    {
        if (armorControllers[2] == null)
        {
            Debug.LogWarning("returning left");
            return;
        }
        if (trigger == InputTrigger.OnPressDown && armorControllers[2].hasPressDownEvent)
        {
            if (armorControllers[2].armorState == ArmorState.ready)
            {
                actionState = ActionState.leftAction;
                Debug.LogWarning("right action state");
                leftJob = Job.make(armorControllers[2].PressDown());
            }
        }

        if (trigger == InputTrigger.OnPressUp && armorControllers[2].hasPressUpEvent)
        {
            //if(leftJob != null)
            //leftJob.kill();
            leftEndJob              = Job.make(armorControllers[2].PressUp());
            leftEndJob.jobComplete += (waskilled) =>
            {
                actionState = ActionState.idle;
                Debug.Log("job ended, was killed = " + waskilled);
            };
        }
    }
    private bool InteractHands(bool isDrag)
    {
        if (UIManager.Hands.CurrentSlot.Item != null && objectBehaviour.visibleState)
        {
            InputTrigger inputTrigger = UIManager.Hands.CurrentSlot.Item.GetComponent <InputTrigger>();
            if (inputTrigger != null)
            {
                bool interacted = false;
                if (isDrag)
                {
                    interacted = inputTrigger.TriggerDrag();
                }
                else
                {
                    interacted = inputTrigger.Trigger();
                }
                if (interacted)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
示例#4
0
    public void RightAction(InputTrigger trigger)
    {
        //Debug.Log("here");
        if (armorControllers[3] == null || isBusy() || armorControllers[3].armorState != ArmorState.ready)
        {
            Debug.LogWarning("returning");

            return;
        }
        if (trigger == InputTrigger.OnPressDown && armorControllers[3].hasPressDownEvent)
        {
            actionState = ActionState.rightAction;
            Debug.Log("right action state");
            rightJob              = Job.make(armorControllers[3].PressDown());
            rightJob.jobComplete += (waskilled) =>
            {
                if (waskilled)
                {
                    actionState = ActionState.idle;
                    Debug.Log("job ended, was killed = " + waskilled);
                }
            };
        }
        if (trigger == InputTrigger.OnPressUp && armorControllers[3].hasPressUpEvent)
        {
            rightEndJob              = Job.make(armorControllers[3].PressUp());
            rightEndJob.jobComplete += (waskilled) =>
            {
                actionState = ActionState.idle;
                Debug.Log("job ended, was killed = " + waskilled);
            };
        }
    }
示例#5
0
        private void Awake()
        {
            _line = SetLineRenderer();

            _onButtonDownTrigger = new InputTrigger(_trackedDevice, _stylusButton, EButtonEvent.OnButtonDown);
            _onButtonTrigger     = new InputTrigger(_trackedDevice, _stylusButton, EButtonEvent.OnButton);
            _onButtonUpTrigger   = new InputTrigger(_trackedDevice, _stylusButton, EButtonEvent.OnButtonUp);
        }
示例#6
0
    public bool Interact(Transform _transform, Vector3 position)
    {
        if (playerMove.isGhost)
        {
            return(false);
        }

        //attempt to trigger the things in range we clicked on
        if (PlayerManager.LocalPlayerScript.IsInReach(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
        {
            //Check for melee triggers first:
            MeleeTrigger meleeTrigger = _transform.GetComponentInParent <MeleeTrigger>();
            if (meleeTrigger != null)
            {
                if (meleeTrigger.MeleeInteract(gameObject, UIManager.Hands.CurrentSlot.eventName))
                {
                    return(true);
                }
            }

            //check the actual transform for an input trigger and if there is non, check the parent
            InputTrigger inputTrigger = _transform.GetComponentInParent <InputTrigger>();
            if (inputTrigger)
            {
                if (objectBehaviour.visibleState)
                {
                    inputTrigger.Trigger(position);

                    //FIXME currently input controller only uses the first InputTrigger found on an object
                    /////// some objects have more then 1 input trigger, like players for example
                    /////// below is a solution that should be removed when InputController is refactored
                    /////// to support multiple InputTriggers on the target object
                    if (inputTrigger.gameObject.layer == 8)
                    {
                        //This is a player. Attempt to use the player based inputTrigger
                        P2PInteractions playerInteractions = inputTrigger.gameObject.GetComponent <P2PInteractions>();
                        if (playerInteractions != null)
                        {
                            playerInteractions.Trigger(position);
                        }
                    }
                    return(true);
                }
                //Allow interact with cupboards we are inside of!
                ClosetControl cCtrl = inputTrigger.GetComponent <ClosetControl>();
                if (cCtrl && cCtrl.transform.position == PlayerManager.LocalPlayerScript.transform.position)
                {
                    inputTrigger.Trigger(position);
                    return(true);
                }
                return(false);
            }
        }
        //if we are holding onto an item like a gun attempt to shoot it if we were not in range to trigger anything
        return(InteractHands());
    }
            public MultiStageInputTrigger(InputTrigger start, InputTrigger end, InputTrigger running)
            {
                start.action += () => { _bStarted = true; };
                start.triggers.Add(hasNotStarted);

                end.triggers.Add(HasStarted);
                end.action += () => { _bStarted = false; };

                running.triggers.Add(HasStarted);
            }
示例#8
0
    public NetTabDescriptor(GameObject provider, NetTabType type)
    {
        this.provider = provider != null?provider.GetComponent <InputTrigger>() : null;

        this.type = type;
        if (type == NetTabType.None && this.provider != null)
        {
            Logger.LogError("You forgot to set a proper NetTabType in your new tab!\n" +
                            "Go to Prefabs/GUI/Resources and see if any prefabs starting with Tab has Type=None", Category.NetUI);
        }
    }
示例#9
0
		internal static void DragToCreateRectangles(InputTrigger trigger)
		{
			var rectangle = new FilledRect(Rectangle.Unused, Color.GetRandomColor());
			new Command((start, end, done) =>
			//ncrunch: no coverage start
			{
				rectangle.DrawArea = Rectangle.FromCorners(start, end);
				if (done)
					rectangle = new FilledRect(Rectangle.Unused, Color.GetRandomColor());
			}).Add(trigger);
			//ncrunch: no coverage end
		}
示例#10
0
    // Start is called before the first frame update
    private void Start()
    {
        _collider      = GetComponent <PolygonCollider2D>();
        _hotSpotHelper = GetComponent <HotSpotHelper>();
        _inputTrigger  = GetComponent <InputTrigger>();

        distanceSwiped    = 0;
        leftToRightSwiped = false;
        swipeCount        = 0;
        sinceLastSwipe    = Time.time;
        _lastSwipe        = new Swipe(0, 0, false);
    }
示例#11
0
    private bool InteractHands()
    {
        if (UIManager.Hands.CurrentSlot.Item != null && objectBehaviour.visibleState)
        {
            InputTrigger inputTrigger = UIManager.Hands.CurrentSlot.Item.GetComponent <InputTrigger>();
            if (inputTrigger != null)
            {
                inputTrigger.Trigger();
                return(true);
            }
        }

        return(false);
    }
示例#12
0
        public void AddWatcher(int vid, int pid, InputTrigger.DeviceSpecificEventHandler handler)
        {
            if (DeviceSpecificWatchers.Any(x => x.Product != pid && x.Vendor != vid))
            {
                DeviceSpecificWatchers.Remove(DeviceSpecificWatchers.First(x => x.Product != pid && x.Vendor != vid));
            }

            var lcs = new InputTrigger
            {
                Product = pid,
                Vendor  = vid
            };

            lcs.KeyPressed += handler;

            DeviceSpecificWatchers.Add(lcs);
        }
示例#13
0
 public void specialAction(InputTrigger trigger)
 {
 }
示例#14
0
    /// <summary>
    /// Checks for the various interactions that can occur and delegates to the appropriate trigger classes.
    /// Note that only one interaction is allowed to occur in this method - the first time any trigger returns true
    /// (indicating that interaction logic has occurred), the method returns.
    /// </summary>
    /// <param name="_transform">transform to check the interaction of</param>
    /// <param name="position">position the interaction is taking place</param>
    /// <param name="isDrag">is this during (but not at the very start of) a drag?</param>
    /// <returns>true iff an interaction occurred</returns>
    public bool Interact(Transform _transform, Vector3 position, bool isDrag)
    {
        if (playerMove.isGhost)
        {
            return(false);
        }

        //attempt to trigger the things in range we clicked on
        var localPlayer = PlayerManager.LocalPlayerScript;

        if (localPlayer.IsInReach(Camera.main.ScreenToWorldPoint(Input.mousePosition)) || localPlayer.IsHidden)
        {
            //Check for melee triggers first. If a melee interaction occurs, stop checking for any further interactions
            MeleeTrigger meleeTrigger = _transform.GetComponentInParent <MeleeTrigger>();
            //no melee action happens due to a drag
            if (meleeTrigger != null && !isDrag)
            {
                if (meleeTrigger.MeleeInteract(gameObject, UIManager.Hands.CurrentSlot.eventName))
                {
                    return(true);
                }
            }

            //check the actual transform for an input trigger and if there is non, check the parent
            InputTrigger inputTrigger = _transform.GetComponentInParent <InputTrigger>();
            if (inputTrigger)
            {
                if (objectBehaviour.visibleState)
                {
                    bool interacted = false;
                    if (isDrag)
                    {
                        interacted = inputTrigger.TriggerDrag(position);
                    }
                    else
                    {
                        interacted = inputTrigger.Trigger(position);
                    }

                    if (interacted)
                    {
                        return(true);
                    }

                    //FIXME currently input controller only uses the first InputTrigger found on an object
                    /////// some objects have more then 1 input trigger, like players for example
                    /////// below is a solution that should be removed when InputController is refactored
                    /////// to support multiple InputTriggers on the target object
                    if (inputTrigger.gameObject.layer == 8)
                    {
                        //This is a player. Attempt to use the player based inputTrigger
                        P2PInteractions playerInteractions = inputTrigger.gameObject.GetComponent <P2PInteractions>();
                        if (playerInteractions != null)
                        {
                            if (isDrag)
                            {
                                interacted = playerInteractions.TriggerDrag(position);
                            }
                            else
                            {
                                interacted = playerInteractions.Trigger(position);
                            }
                        }
                    }
                    if (interacted)
                    {
                        return(true);
                    }
                }
                //Allow interact with cupboards we are inside of!
                ClosetControl closet = inputTrigger.GetComponent <ClosetControl>();
                //no closet interaction happens when dragging
                if (closet && Camera2DFollow.followControl.target == closet.transform && !isDrag)
                {
                    if (inputTrigger.Trigger(position))
                    {
                        return(true);
                    }
                }
                return(false);
            }
        }

        //if we are holding onto an item like a gun attempt to shoot it if we were not in range to trigger anything
        return(InteractHands(isDrag));
    }
示例#15
0
 /// <summary>
 /// Tries to trigger InputTrigger
 /// </summary>
 private static bool TryInputTrigger(Vector3 position, bool isDrag, InputTrigger inputTrigger)
 {
     return(isDrag ? inputTrigger.TriggerDrag(position) : inputTrigger.Trigger(position));
 }
示例#16
0
 /// <summary>
 /// コンストラクタ
 /// コールバックを設定する
 /// </summary>
 /// <param name="arg_trigger">タイミング</param>
 /// <param name="arg_action">コールバック</param>
 public CommandAction(InputTrigger arg_trigger, System.Action arg_action)
 {
     m_trigger = arg_trigger;
     m_action  = arg_action;
 }
	//HACK the problem is that skill IDs are different because of different item spawn order for clients. Reverted to hacky slot index usage. 
	public void UseSkill(InputTrigger trigger, int slot)
	{
		if(isLocked() || (!myStatus.isAlive() && trigger == InputTrigger.OnPressDown))
			return;
		//int skillIndex = -1;
		//skillIndex = GetSkillByIDAndSlot(index, slot);
		for (int i = 0; i < armorSkills.Count; i++) {
			if(armorSkills[i].equipmentSlotIndex == slot)
			{
				if(trigger == InputTrigger.OnPressDown)
				{
					if(armorSkills[i].CanPressDown() && !isOtherSkillBusy(slot))
					{
						int rng = Random.Range(armorSkills[i].lowerRNGLimit, armorSkills[i].upperRNGLimit);
						myPhotonView.RPC("PressDownAction", PhotonTargets.All, slot, rng);
						//PressDownAction(skillIndex, rng);
					}
				}
				else if(trigger == InputTrigger.OnPressUp && !isOtherSkillBusy(slot))
				{
					if(armorSkills[i].CanPressUp())
					{
						int rng = Random.Range(armorSkills[i].lowerRNGLimit, armorSkills[i].upperRNGLimit);
						myPhotonView.RPC("PressUpAction", PhotonTargets.All, slot, rng);
						//PressUpAction(skillIndex, rng);
					}
				}
			}
		}
	}
示例#18
0
 /// <summary>
 /// コンストラクタ
 /// 引数ありコールバックを設定する
 /// </summary>
 /// <param name="arg_trigger">タイミング</param>
 /// <param name="arg_objectAction">コールバック</param>
 /// <param name="arg_value">引数</param>
 public CommandAction(InputTrigger arg_trigger, System.Action <object> arg_objectAction, object arg_value)
 {
     m_trigger      = arg_trigger;
     m_objectAction = arg_objectAction;
     m_value        = arg_value;
 }
示例#19
0
 void Awake()
 {
     pointerTrigger = new InputTrigger <int, Pointer> (PointerInjection(), Pointer.Canceled);
 }
 public void registerTrigger(InputTrigger trigger, KeyCode key)
 {
     _keyMap.Add(key, trigger);
 }
示例#21
0
 void Awake()
 {
     handledKeys = handledKeys == null? new KeyCode[0]: handledKeys.Distinct().ToArray();
     keyTrigger  = new InputTrigger <KeyCode, Key> (() => InputExt.KeysFromCodes(handledKeys), Key.Canceled);
 }
示例#22
0
 private void OnValidate()
 {
     _onButtonDownTrigger = new InputTrigger(_trackedDevice, _stylusButton, EButtonEvent.OnButtonDown);
     _onButtonTrigger     = new InputTrigger(_trackedDevice, _stylusButton, EButtonEvent.OnButton);
     _onButtonUpTrigger   = new InputTrigger(_trackedDevice, _stylusButton, EButtonEvent.OnButtonUp);
 }
示例#23
0
 public void specialAction(InputTrigger trigger)
 {
 }
示例#24
0
    public void LeftAction(InputTrigger trigger)
    {
        if(armorControllers[2] == null)
        {
            Debug.LogWarning("returning left");
            return;
        }
        if(trigger == InputTrigger.OnPressDown && armorControllers[2].hasPressDownEvent)
        {
            if(armorControllers[2].armorState == ArmorState.ready)
            {
                actionState = ActionState.leftAction;
                Debug.LogWarning("right action state");
                leftJob = Job.make( armorControllers[2].PressDown() );
            }

        }

        if(trigger == InputTrigger.OnPressUp && armorControllers[2].hasPressUpEvent)
        {
            //if(leftJob != null)
                //leftJob.kill();
            leftEndJob = Job.make( armorControllers[2].PressUp() );
            leftEndJob.jobComplete += (waskilled) =>
            {
                actionState = ActionState.idle;
                Debug.Log("job ended, was killed = " + waskilled);
            };
        }
    }
示例#25
0
 private void OnValidate()
 {
     _buttonTrigger = new InputTrigger(_trackedDeviceProvider, _stylusButton, EButtonEvent.OnButton);
 }
示例#26
0
    public void RightAction(InputTrigger trigger)
    {
        //Debug.Log("here");
        if(armorControllers[3] == null || isBusy() || armorControllers[3].armorState != ArmorState.ready)
        {
            Debug.LogWarning("returning");

            return;
        }
        if(trigger == InputTrigger.OnPressDown && armorControllers[3].hasPressDownEvent)
        {
            actionState = ActionState.rightAction;
            Debug.Log("right action state");
            rightJob = Job.make( armorControllers[3].PressDown() );
            rightJob.jobComplete += (waskilled) =>
            {
                if(waskilled)
                {
                    actionState = ActionState.idle;
                    Debug.Log("job ended, was killed = " + waskilled);
                }
            };
        }
        if(trigger == InputTrigger.OnPressUp && armorControllers[3].hasPressUpEvent)
        {
            rightEndJob = Job.make( armorControllers[3].PressUp() );
            rightEndJob.jobComplete += (waskilled) =>
            {
                actionState = ActionState.idle;
                Debug.Log("job ended, was killed = " + waskilled);
            };
        }
    }
 void GetGamepadTrigger(ref InputTrigger _button, GamePad.Trigger _gamepadButton, GamePad.Index _index)
 {
     _button.lastFrame = _button.thisFrame;
     _button.thisFrame = GamePad.GetTrigger(_gamepadButton, _index, true);
 }
示例#28
0
 // Start is called before the first frame update
 private void Start()
 {
     _collider2D   = GetComponent <Collider2D>();
     _inputTrigger = GetComponent <InputTrigger>();
 }