Esempio n. 1
0
        void IControllerInputHandler.OnInputPositionChanged(InputPositionEventData eventData)
        {
            // Debug.Log(eventData.PressType.ToString());
            var target = eventData.selectedObject;

            if (target != lastTarget)
            {
                lastTarget = target;
                if (lastTarget != null)
                {
                    so = lastTarget.GetComponent <Slam.SlamObject>();
                }
            }
            if (eventData.PressType == InteractionSourcePressInfo.Thumbstick)
            {
                if (EnableTeleport)
                {
                    if (currentPointingSource == null && eventData.Position.y > 0.8 && Math.Abs(eventData.Position.x) < 0.3)
                    {
                        if (so != null && (so.WalkFloor || so.SitPlane))
                        {
                            if (FocusManager.Instance.TryGetPointingSource(eventData, out currentPointingSource))
                            {
                                currentSourceId = eventData.SourceId;
                                StartTeleport();
                            }
                        }
                    }
                    else if (currentPointingSource != null && currentSourceId == eventData.SourceId && eventData.Position.magnitude < 0.2)
                    {
                        FinishTeleport();
                    }
                }

                if (EnableStrafe && currentPointingSource == null)
                {
                    if (eventData.Position.y < -0.8 && Math.Abs(eventData.Position.x) < 0.3)
                    {
                        DoStrafe(Vector3.back * StrafeAmount);
                    }
                }

                if (EnableRotation && currentPointingSource == null)
                {
                    if (eventData.Position.x < -0.8 && Math.Abs(eventData.Position.y) < 0.3)
                    {
                        DoRotation(-RotationSize);
                    }
                    else if (eventData.Position.x > 0.8 && Math.Abs(eventData.Position.y) < 0.3)
                    {
                        DoRotation(RotationSize);
                    }
                }
            }
        }
Esempio n. 2
0
        public void OnSelectPressedAmountChanged(SelectPressedEventData eventData)
        {
            if (eventData.PressedAmount > 0.9f && waitTime <= 0)
            {
                var target = eventData.selectedObject;

                Slam.SlamObject so = null;
                if (target != null)
                {
                    so = target.GetComponent <Slam.SlamObject>();
                    if (so != null)
                    {
                        so.DoSelect(Vector3.zero);
                        waitTime = 0.5f;
                    }
                }
            }
        }