예제 #1
0
        public void Enqueue(CustomInput currentInput)
        {
            if (!(currentInput.IsDown || currentInput.IsDrag || currentInput.IsUp))
            {
                return;
            }
            this.pastInputs.Add(currentInput);

            if (this.pastInputs.Count == 1)
            {
                //First Input
                currentInput.MovedDistance             = Vector3.zero;
                currentInput.LevelingTime              = 0;
                currentInput.LevelingOriginSpeedVector = Vector3.zero;
            }
            else
            {
                //currentInputからLevelingFrame数だけ古いフレームのInput
                CustomInput levelingOriginInput = this.pastInputs [0];
                currentInput.MovedDistance             = currentInput.ScreenPosition - levelingOriginInput.ScreenPosition;
                currentInput.LevelingTime              = currentInput.Time - levelingOriginInput.Time;   // this.LevelingFrameCount;
                currentInput.LevelingOriginSpeedVector = levelingOriginInput.SpeedVector;

                //フリック開始&継続判定
                var lastInput = this.pastInputs [this.pastInputs.Count - 2];
                if (lastInput.IsFlicking)
                {
                    //継続判定
                    if (currentInput.SpeedVector.magnitude > this.DefeatSpeed)
                    {
                        currentInput.IsFlicking = true;
                    }
                    else
                    {
                        //フリック中止
                        this.FlickStartInput = null;

                        currentInput.IsFlicking = false;
                        this.FlickStartInput    = null;
                    }
                }
                else
                {
                    //フリック開始判定
                    if (currentInput.AccelerationVector.magnitude > this.DetectAcceleration)
                    {
                        if (currentInput.SpeedVector.magnitude > 0.0001f)
                        {
                            if (!this.ContinuousDetect && this.IsDetected)
                            {
                                //指を離すまで再検知しない
                            }
                            else
                            {
                                currentInput.IsFlicking = true;
                                this.FlickStartInput    = currentInput;
                                this.IsDetected         = true;
                                //フリック開始イベント
                                TouchManager.Instance.OnFlickStart(new FlickEventArgs(levelingOriginInput, currentInput));
                            }
                        }
                    }
                }

                //フリック完了判定
                if (currentInput.IsFlicking && currentInput.IsUp)
                {
                    Vector3 flickDistance = currentInput.ScreenPosition - this.FlickStartInput.ScreenPosition;
                    if (flickDistance.magnitude > MinFlickDistancePx)
                    {
                        //フリック成立
                        TouchManager.Instance.OnFlickComplete(new FlickEventArgs(this.pastInputs [this.pastInputs.Count - 2], currentInput));
                        //TouchManager.Instance.OnFlickComplete (new FlickEventArgs (this.FlickStartInput, currentInput));

                        currentInput.IsFlicking = false;
                        this.FlickStartInput    = null;
                    }
                }

                //指が離れた
                if (currentInput.IsUp)
                {
                    this.IsDetected = false;
                    this.pastInputs.Clear();
                }
            }

            while (this.pastInputs.Count > TransDetectTimeToFrame(DetectTime))
            {
                this.pastInputs.RemoveAt(0);
            }
        }
예제 #2
0
 public void OnTouchStart(CustomInput input)
 {
     if (this.TouchStart != null)
                 this.TouchStart (this.gameObject, new CustomInputEventArgs (input));
 }
예제 #3
0
 public void OnTouchNavigationBack(CustomInput input)
 {
     if (this.NavigationAction != null) {
         this.NavigationAction (this.gameObject, new CustomInputEventArgs (input));
     }
 }
예제 #4
0
 public void OnDrag(CustomInput input)
 {
     if (this.Drag != null)
                 this.Drag (this.gameObject, new CustomInputEventArgs (input));
 }
예제 #5
0
 public CustomInputEventArgs(CustomInput input)
 {
     this.Input = input;
 }
예제 #6
0
 public FlickEventArgs(CustomInput startInput, CustomInput endInput)
 {
     this.StartInput = startInput;
     this.EndInput   = endInput;
 }