コード例 #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
ファイル: TouchManager.cs プロジェクト: Yumamama/Sleeim_App
 public void OnTouchStart(CustomInput input)
 {
     if (this.TouchStart != null)
                 this.TouchStart (this.gameObject, new CustomInputEventArgs (input));
 }
コード例 #3
0
ファイル: TouchManager.cs プロジェクト: Yumamama/Sleeim_App
 public void OnTouchNavigationBack(CustomInput input)
 {
     if (this.NavigationAction != null) {
         this.NavigationAction (this.gameObject, new CustomInputEventArgs (input));
     }
 }
コード例 #4
0
ファイル: TouchManager.cs プロジェクト: Yumamama/Sleeim_App
 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;
 }