/// <summary>
        /// Occurs upon a valid <see cref="FlickGesture"/>.
        /// </summary>
        /// <param name="gesture"></param>
        protected override void OnFlick(FlickGesture gesture)
        {
            double velocity = this.View.Orientation == Orientation.Horizontal ? gesture.Velocity.X : gesture.Velocity.Y;
            int    sign     = Math.Sign(velocity);

            this.PerformFlick(sign, sign == Math.Sign(this.OffsetLength));
        }
    void FlickHandler(object sender, System.EventArgs e)
    {
        if (flickReady && flickCooldownTimer > FLICKCOOLDOWN && AnimationSetter.instance.state != MonsterState.Fall && AnimationSetter.instance.state != MonsterState.Dash)
        {
            FlickGesture gesture = sender as FlickGesture;
            TouchHit     hitFlick;
            gesture.GetTargetHitResult(out hitFlick);

            Vector3 direction = hitFlick.Point - pressPoint;
            //print(direction.normalized.x + " , " + direction.normalized.y + " : " + direction.magnitude);
            if (direction.normalized.y < 0)
            {
                player.GetComponent <MonsterController>().SetDashPower(1);
            }
            else if (direction.magnitude > MAXDASHPOWER)
            {
                player.GetComponent <MonsterController>().SetDashPower(MAXDASHPOWER);
            }
            else
            {
                player.GetComponent <MonsterController>().SetDashPower(direction.magnitude);
            }
            //print(direction.magnitude);
            direction.Normalize();
            //print(direction);

            player.GetComponent <MonsterController>().SetSwipeDirection(direction);

            AnimationSetter.instance.state = MonsterState.Dash;

            flickCooldownTimer = 0;
        }
    }
        private void OnGamePageDoubleFlicked(FlickGesture obj)
        {
#if UNITY_EDITOR
            if (OnDoubleTwoFingerFlicked != null)
            {
                OnDoubleTwoFingerFlicked.Invoke(obj.ScreenFlickVector);
                /* 因為此操作會和單指操作衝突,因此加個flag來決定單指操作是否能觸發 */
                isDoubleFlicked = true;
                StartCoroutine(DelayCall(.3f, () =>
                {
                    isDoubleFlicked = false;
                }));
            }
#else
            if (GetTouchCount() == 2)
            {
                if (OnDoubleTwoFingerFlicked != null)
                {
                    OnDoubleTwoFingerFlicked.Invoke(obj.ScreenFlickVector);
                }
                /* 因為此操作會和單指操作衝突,因此加個flag來決定單指操作是否能觸發 */
                isDoubleFlicked = true;
                StartCoroutine(DelayCall(.3f, () =>
                {
                    isDoubleFlicked = false;
                }));
            }
#endif
        }
 public static IObservable <EventPattern <EventArgs> > FlickedAsObservable(this FlickGesture gesture)
 {
     return(Observable.FromEventPattern <EventHandler <EventArgs>, EventArgs>(
                h => h.Invoke,
                h => gesture.Flicked += h,
                h => gesture.Flicked -= h));
 }
示例#5
0
        /// <summary>
        /// Occurs upon a valid <see cref="FlickGesture"/>.
        /// </summary>
        /// <param name="gesture"></param>
        protected override void OnFlick(FlickGesture gesture)
        {
            base.OnFlick(gesture);

            if (this.snapshotState == SnapshotState.None)
            {
                if (this.waitingForFlick)
                {
                    Debug.Assert(false, "Wrong state.");
                    this.waitingForFlick = false;
                }
                return;
            }

            double velocityLength = this.View.Orientation == Orientation.Horizontal ? gesture.Velocity.X : gesture.Velocity.Y;

            this.flickSign = Math.Sign(velocityLength);

            if (this.snapshotState == SnapshotState.Generating)
            {
                this.waitingForFlick = true;
            }
            else
            {
                double to = this.flickSign == this.panSign ? this.MaxRotationAngle : 0;
                this.AnimateRotation(to, SlideViewAnimationState.Flick, AnimationDiration);
            }
        }
        private void OnFlick(FlickGesture gesture)
        {
            if (this.ListSource.Count == 0)
            {
                return;
            }

            Debug.Assert(this.selectedDataSourceItem != null, "Must have selected item at this point");

            IDataSourceItem item = null;

            if (gesture.Velocity.X < 0)
            {
                item = this.ListSource.GetItemAfter(this.selectedDataSourceItem);
                if (item == null)
                {
                    item = this.ListSource.GetFirstItem();
                }
            }
            else if (gesture.Velocity.X > 0)
            {
                item = this.ListSource.GetItemBefore(this.selectedDataSourceItem);
                if (item == null)
                {
                    item = this.ListSource.GetLastItem();
                }
            }

            if (item != null)
            {
                this.selectedDataSourceItem = item;
                this.ChangePropertySilently(SelectedItemProperty, this.selectedDataSourceItem.Value);
            }
        }
 private void OnEnable()
 {
     flickGesture                   = GetComponent <FlickGesture>();
     flickGesture.Flicked          += flickedHandler;
     flickGesture.MinDistance       = 0.5f;
     flickGesture.MovementThreshold = 0.25f;
     print($"FLICK min: {flickGesture.MinDistance} threshold: {flickGesture.MovementThreshold} time: {flickGesture.FlickTime}");
 }
示例#8
0
    public override void FlickedHandler(object sender, EventArgs e)
    {
        base.FlickedHandler(sender, e);

        FlickGesture gestureComponent = sender as FlickGesture;

        Move(gestureComponent.ScreenFlickVector.normalized);
    }
        private void Awake()
        {
            ScaleRange *= Camera.main.orthographicSize;

            HorizontalMoveGesture = GetComponent <ScreenTransformGesture>();
            ScaleGesture          = GetComponent <TransformGesture>();
            PressGesture          = GetComponent <PressGesture>();
            ReleaseGesture        = GetComponent <ReleaseGesture>();
            FlickGesture          = GetComponent <FlickGesture>();
        }
示例#10
0
    private void Start()
    {
        m_player = GameObject.FindWithTag("Player").GetComponent <SamplePlayerController>();
        GetComponent <TapGesture>().Tapped += HandleTap;
        FlickGesture fg = GetComponent <FlickGesture>();

        fg.Flicked      += HandleFlick;
        fg.StateChanged += HandleFlick;
        fg.MinDistance   = 1f;
        fg.FlickTime     = 0.3f;
    }
        protected override void OnStart()
        {
            base.OnStart();

            _flickGesture = GetComponent <FlickGesture>();
            _boxCollider  = GetComponent <BoxCollider>();

            inputController = _controller as InputController;

            inputController.AddFlickGesture(_flickGesture);
        }
示例#12
0
        public override void OnEnter()
        {
            gesture = GestureUtils.GetGesture <FlickGesture>(Fsm, GameObject, Component, true);
            if (gesture == null)
            {
                LogError("Gesture is missing");
                return;
            }

            gesture.Flicked += gestureFlickedHandler;
        }
        /// <summary>
        /// Handle flick events
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void flickHandler(object sender, EventArgs e)
        {
            // get the gesture that was sent to us, which will tell us
            // which object was flicked
            FlickGesture gesture = sender as FlickGesture;

            TouchHit hit;

            // get info about where the hit object was located when the gesture was
            // recognized - i.e., where on the object (in screen dimensions) did
            // the flick occur?
            if (gesture.GetTargetHitResult(out hit))
            {
                Logger.Log("FLICK on " + gesture.gameObject.name + " at " + hit.Point);

                // fire event to logger to log this action
                if (this.logEvent != null)
                {
                    // log the flick
                    this.logEvent(this, new LogEvent(LogEvent.EventType.Action,
                                                     gesture.gameObject.name, "flick", hit.Point));
                }


                if (this.allowTouch)
                {
                    // if flick/swipe was to the right, advance page
                    if (gesture.ScreenFlickVector.x < 0)
                    {
                        ChangePage(Constants.NEXT);
                    }

                    // if to the left, go back a page
                    else if (gesture.ScreenFlickVector.x > 0)
                    {
                        ChangePage(Constants.PREVIOUS);
                    }
                }

                // trigger sound on flick as feedback?
                //if(this.allowTouch && !gesture.gameObject.tag.Contains(Constants.TAG_SIDEKICK))
                //{
                //	Logger.Log("going to play a sound for " + gesture.gameObject.name);
                //	PlaySoundAndPulse(gesture.gameObject);
                //}
            }
            else
            {
                // this probably won't ever happen, but in case it does, we'll log it
                Logger.LogWarning("!! could not register where FLICK was located!");
            }
        }
示例#14
0
    private void flickHandler(object sender, EventArgs e)
    {
        FlickGesture gesture = sender as FlickGesture;

        if (gesture.ScreenFlickVector.x > 0)
        {
            playerDonut.GetComponent <Controls>().flickedHorizontally(1);
        }
        else
        {
            playerDonut.GetComponent <Controls>().flickedHorizontally(-1);
        }
    }
示例#15
0
    private void OnEnable()
    {
        flickGesture                   = GetComponent <FlickGesture>();
        flickGesture.Flicked          += flickedHandler;
        flickGesture.MinDistance       = 0.5f;
        flickGesture.MovementThreshold = 0.25f;
        print($"FLICK min: {flickGesture.MinDistance} threshold: {flickGesture.MovementThreshold} time: {flickGesture.FlickTime}");

        transformGesture = GetComponent <TransformGesture>();
        transformGesture.TransformStarted   += transformedStartedHandler;
        transformGesture.Transformed        += transformedHandler;
        transformGesture.TransformCompleted += transformedEndedHandler;
        //transformGesture.AddFriendlyGesture(flickGesture);
    }
        private void HandleFlick(FlickGesture flickGesture)
        {
            if (this.animationState != SlideViewAnimationState.None)
            {
                return;
            }

            if (this.isStretching)
            {
                this.ResetStretch();
                return;
            }

            this.OnFlick(flickGesture);
        }
示例#17
0
    void FlickVerticalHandler(object sender, EventArgs e)
    {
        FlickGesture flick = (FlickGesture)sender;

        bool isPosi = false;

        if (flick.ScreenFlickVector.y < 0)
        {
            isPosi = true;
        }
        if (activePower && ManagerSlidePower.Instance.DeActivePower())
        {
            ManagerDoors.Instance.OpensDoors((int)door.posMaxtrix.y, false, isPosi);
        }
    }
    private void OnEnable()
    {
        flickGesture                   = GetComponent <FlickGesture>();
        flickGesture.Flicked          += flickedHandler;
        flickGesture.MinDistance       = 0.5f;
        flickGesture.MovementThreshold = 0.25f;

        pressGesture          = GetComponent <PressGesture>();
        pressGesture.Pressed += pressedHandler;

        transformGesture                     = GetComponent <TransformGesture>();
        transformGesture.Transformed        += transformedHandler;
        transformGesture.TransformCompleted += transformedEndedHandler;
        transformGesture.AddFriendlyGesture(flickGesture);
    }
示例#19
0
 private void onFlick(object sender, TouchScript.Events.GestureStateChangeEventArgs e)
 {
     if (e.State == Gesture.GestureState.Recognized)
     {
         FlickGesture gesture = sender as FlickGesture;
         if (Mathf.Abs(gesture.ScreenFlickVector.x) > Mathf.Abs(gesture.ScreenFlickVector.y))
         {
             playerController.SwitchDirection((int)Mathf.Sign(gesture.ScreenFlickVector.x));
         }
         else if (gesture.ScreenFlickVector.y > 0)
         {
             playerController.Jump();
         }
     }
 }
示例#20
0
        private void FlickedHandler(object sender, EventArgs e)
        {
            if (this.IsJoystick())
            {
                return;
            }

            //Debug.LogError("FlickedHandler");
            FlickGesture gesture = sender as FlickGesture;

            if (gesture != null)
            {
                Vector2 flickVector = gesture.ScreenFlickVector;
                this.Human.HandleFlick(flickVector);
            }
        }
示例#21
0
        private void OnEnable()
        {
            if (_targetCamera)
            {
                transform.SetParent(_targetCamera.transform);
            }

            _transformGesture              = GetComponent <TransformGesture>();
            _transformGesture.Transformed += OnTransformed;

            _flickGesture          = GetComponent <FlickGesture>();
            _flickGesture.Flicked += OnFlicked;

            _longPressGesture              = GetComponent <LongPressGesture>();
            _longPressGesture.LongPressed += OnLongPressed;
        }
示例#22
0
//		private float flickError;

        private FlickPlayerController(
            [Inject(Id = "Vertical")] FlickGesture verticalFlickGesture,
            [Inject(Id = "Horizontal")] FlickGesture horizontalFlickGesture,
            PlayerTurnSignal playerTurnSignal,
            WaitForPlayerTurnSignal waitForPlayerTurnSignal,
            Field field,
            MoveTurnAction.PositionFactory moveTurnActionFactory)
        {
            this.verticalFlickGesture    = verticalFlickGesture;
            this.horizontalFlickGesture  = horizontalFlickGesture;
            this.playerTurnSignal        = playerTurnSignal;
            this.waitForPlayerTurnSignal = waitForPlayerTurnSignal;
            this.moveTurnActionFactory   = moveTurnActionFactory;
            this.player = field.Player;
            this.field  = field;
//			this.flickError = flickError;
        }
示例#23
0
    /// <summary>
    /// Initialize all components.
    /// </summary>
    protected virtual void InitializeComponents()
    {
        m_isPressablePrev = m_isPressable;
        m_isDraggablePrev = m_isDraggable;
        m_isFlickablePrev = m_isFlickable;

        // Make sure element has a SpriteRenderer component
        m_spriteRenderer = this.GetComponent <SpriteRenderer>();
        if (m_spriteRenderer == null)
        {
            m_spriteRenderer = this.GetComponentInChildren <SpriteRenderer>();
            if (m_spriteRenderer == null)
            {
                m_spriteRenderer = this.gameObject.AddComponent <SpriteRenderer>();
            }
        }
        // Make sure the elment has a Collider2D component if it needs one
        if (m_isPressable || m_isDraggable || m_isFlickable)
        {
            AddOrGetComponentCollider2D();
        }
        // Make sure element has a PressGesture component if it needs one
        if (m_isPressable)
        {
            m_pressGesture = this.gameObject.AddComponentNoDupe <PressGesture>();
            AddPressDelegate(OnObjectPress);
            AddReleaseDelegate(OnObjectRelease);
        }
        // Make sure element has a SimplePanGesture component if it needs one
        // Make sure element has a Transformer2D component if it needs one
        if (m_isDraggable)
        {
            m_simplePanGesture = this.gameObject.AddComponentNoDupe <SimplePanGesture>();
            m_transformer2D    = this.gameObject.AddComponentNoDupe <Transformer2D>();
        }
        // Make sure element has a FlickGesture component if it needs one
        if (m_isFlickable)
        {
            m_flickGesture = this.gameObject.AddComponentNoDupe <FlickGesture>();
        }

        // No need for ReleaseGesture - this script has a different implementation for release
    }
示例#24
0
        /// <summary>
        /// Handle flick events
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void flickHandler(object sender, EventArgs e)
        {
            // get the gesture that was sent to us, which will tell us
            // which object was flicked
            FlickGesture gesture = sender as FlickGesture;
            HitData      hit     = gesture.GetScreenPositionHitData();

            // get info about where the hit object was located when the gesture was
            // recognized - i.e., where on the object (in screen dimensions) did
            // the flick occur?
            Logger.Log("FLICK on " + gesture.gameObject.name + " at " + hit.Point);

            // fire event to logger to log this action
            if (this.logEvent != null)
            {
                // log the flick
                this.logEvent(this, new LogEvent(LogEvent.EventType.Action,
                                                 gesture.gameObject.name, "flick", hit.Point));
            }

            if (this.allowTouch)
            {
                // if flick/swipe was to the right, advance page
                if (gesture.ScreenFlickVector.x < 0)
                {
                    ChangePage(Constants.NEXT);
                }

                // if to the left, go back a page
                else if (gesture.ScreenFlickVector.x > 0)
                {
                    ChangePage(Constants.PREVIOUS);
                }
            }

            // trigger sound on flick as feedback?
            //if(this.allowTouch && !gesture.gameObject.tag.Contains(Constants.TAG_SIDEKICK))
            //{
            //	Logger.Log("going to play a sound for " + gesture.gameObject.name);
            //	PlaySoundAndPulse(gesture.gameObject);
            //}
        }
示例#25
0
    void Awake()
    {
        horizontalFlick = GetComponent <FlickGesture>();

        horizontalFlick.Flicked += HorizontalFlick_Flicked;

        foreach (Page page in GetComponentsInChildren <Page>())
        {
            if (pages.ContainsKey(page.PageNumber) == true)
            {
                print("2 or more pages with the page number '" + page.PageNumber + "' exist.");

                continue;
            }

            pages.Add(page.PageNumber, page);

            page.gameObject.SetActive(page.PageNumber == 0);
        }
    }
示例#26
0
    private void FlickedHandler(object sender, EventArgs e)
    {
        Debug.LogError("FlickedHandler");
        FlickGesture gesture = sender as FlickGesture;

        if (gesture != null)
        {
            //Debug.LogError("FlickedHandler got FlickGesture Direction=" + gesture.Direction.ToString() + " ScreenFlickVector=" + gesture.ScreenFlickVector.x + "," + gesture.ScreenFlickVector.y);
            if (Mathf.Abs(gesture.ScreenFlickVector.x) >= Mathf.Abs(gesture.ScreenFlickVector.y))
            {
                if (gesture.ScreenFlickVector.x > 0)
                {
                    //Right
                    Debug.LogError("Right");
                }
                else
                {
                    //Left
                    Debug.LogError("Left");
                }
            }
            else
            {
                if (gesture.ScreenFlickVector.y > 0)
                {
                    //Up
                    Debug.LogError("Jump");
                    this.Current.Jump = true;
                }
                else
                {
                    //Down
                    Debug.LogError("Dive");
                    this.Current.Dive = true;
                }
            }
        }
    }
示例#27
0
    /// <summary>
    /// Updates the IsFlickable property
    /// Components are added/enabled/disabled as needed
    /// </summary>
    protected void UpdateIsFlickableField()
    {
        if (m_isFlickable == m_isFlickablePrev)
        {
            return;
        }

        if (m_isFlickable)
        {
            AddOrGetComponentCollider2D();
            m_flickGesture         = this.gameObject.AddComponentNoDupe <FlickGesture>();
            m_flickGesture.enabled = true;
        }
        else
        {
            if (m_flickGesture != null)
            {
                m_flickGesture.enabled = false;
            }
        }

        m_isFlickablePrev = m_isFlickable;
    }
示例#28
0
 public void AddFlickGesture(FlickGesture flickGesture)
 {
     _flickGesture          = flickGesture;
     _flickGesture.Flicked += Flicked;
 }
示例#29
0
    void fullscreenFlickedHandler(object sender, EventArgs e)
    {
        FlickGesture gesture = sender as FlickGesture;

        Vector2 dir = gesture.ScreenFlickVector;

        if (moveSelection)
        {
            int mod = moveList.Count + 1;
            if (takenList.Count > 0)
            {
                mod--;
            }
            if (dir.x > 0)
            {
                selectedMoveIndex++;
                selectedMoveIndex %= mod;
            }
            else
            {
                selectedMoveIndex--;
                if (selectedMoveIndex < 0)
                {
                    selectedMoveIndex = mod - 1;
                }
                selectedMoveIndex %= mod;
            }
            Debug.Log("Move: " + selectedMoveIndex);
            if (selectedMoveIndex == moveList.Count)
            {
                fieldSelector.transform.position = new Vector3(curBoardPosX, curBoardPosY, -2f);
                FindObjectOfType <Camera>().transform.position = new Vector3(curBoardPosX, curBoardPosY, -10);
                //Char xMarker = (Char)(Convert.ToUInt16('a') + curBoardPosX);
                TTSManager.Speak("Powrót", false, TTSManager.STREAM.Music, 1f, 0f, transform.name, "OnSpeechCompleted", "speech_0");
            }
            else
            {
                fieldSelector.transform.position = new Vector3(moveList[selectedMoveIndex].x, moveList[selectedMoveIndex].y, -2f);
                FindObjectOfType <Camera>().transform.position = new Vector3(moveList[selectedMoveIndex].x, moveList[selectedMoveIndex].y, -10);
                Char xMarker = (Char)(Convert.ToUInt16('a') + moveList[selectedMoveIndex].x);
                TTSManager.Speak(xMarker + " " + (moveList[selectedMoveIndex].y + 1).ToString(), false, TTSManager.STREAM.Music, 1f, 0f, transform.name, "OnSpeechCompleted", "speech_0");
            }
        }
        else
        {
            if (Math.Abs(dir.x) > Math.Abs(dir.y))
            {
                if (dir.x > 0)
                {
                    Debug.Log("Swipe Right");
                    curBoardPosX--;
                }
                else
                {
                    Debug.Log("Swipe Left");
                    curBoardPosX++;
                }
            }
            else
            {
                if (dir.y > 0)
                {
                    Debug.Log("Swipe Up");
                    curBoardPosY--;
                }
                else
                {
                    Debug.Log("Swipe Down");
                    curBoardPosY++;
                }
            }

            curBoardPosX = curBoardPosX.Clamp(0, boardSize - 1);
            curBoardPosY = curBoardPosY.Clamp(0, boardSize - 1);
            Char xMarker = (Char)(Convert.ToUInt16('a') + curBoardPosX);
            TTSManager.Speak(xMarker + " " + (curBoardPosY + 1).ToString(), false, TTSManager.STREAM.Music, 1f, 0f, transform.name, "OnSpeechCompleted", "speech_0");
            Debug.Log(xMarker);

            Vector3 selectorPosOnScreen = board[curBoardPosX, curBoardPosY].transform.position;
            fieldSelector.transform.position = new Vector3(selectorPosOnScreen.x, selectorPosOnScreen.y, 0.05f);
            FindObjectOfType <Camera>().transform.position = new Vector3(selectorPosOnScreen.x, selectorPosOnScreen.y, -10);
            Debug.Log(curBoardPosX + "," + curBoardPosY);
        }
    }
示例#30
0
 private void OnEnable()
 {
     this.gesture          = this.GetComponent <FlickGesture>();
     this.gesture.Flicked += this.onFlickedHandler;
 }