protected override GestureRecognitionState OnRecognize(LongPressGesture gesture, TouchManager.IFingerList touches) { if (touches.Count != RequiredFingerCount) { return(GestureRecognitionState.Failed); } if (HasTimedOut(gesture)) { return(GestureRecognitionState.Failed); } if (gesture.ElapsedTime >= Duration) { return(GestureRecognitionState.Recognized); } // Æ«Àë³õʼλÖÃÌ«Ô¶ if (touches.GetAverageDistanceFromStart() > ToPixels(MoveTolerance)) { return(GestureRecognitionState.Failed); } return(GestureRecognitionState.InProgress); }
protected override bool CanBegin(CustomGesture gesture, TouchManager.IFingerList touches) { if (touches.Count != RequiredFingerCount) { return(false); } if (IsExclusive && TouchManager.Touches.Count != RequiredFingerCount) { return(false); } if (ArkCrossEngine.TouchType.Regognizer != TouchManager.curTouchState) { return(false); } if ((int)CurActiveSection >= SectionNumber - 1) { return(false); } if (CurActiveSection != Section.Invalid && gesture.IsInvalid) { return(false); } Section MediSection = (CurActiveSection == Section.Invalid ? Section.First : CurActiveSection + 1); float ActiveDistance = SkillSection[(int)MediSection].ActiveDistance; if (ActiveDistance > 0) { float Distance = 0; if (MediSection == Section.First) { gesture.IsInvalid = false; Distance = touches.GetAverageDistanceFromStart(); } else if (MediSection == Section.Second) { if (UnityEngine.Vector2.zero == SkillSection[(int)MediSection].StartPos) { if (UnityEngine.Vector2.zero == LastInputPos) { LastInputPos = touches.GetAveragePosition(); return(false); } Point cp = new Point(0, touches.GetAveragePosition()); Point lp = new Point(0, LastInputPos); if (SkillCategory.kSkillA == ActiveSkill) { if (cp.Position.x < lp.Position.x) { SkillSection[(int)MediSection].StartPos = touches.GetAveragePosition(); } } else if (SkillCategory.kSkillB == ActiveSkill) { if (cp.Position.y > lp.Position.y) { SkillSection[(int)MediSection].StartPos = touches.GetAveragePosition(); } } else if (SkillCategory.kSkillC == ActiveSkill) { if (cp.Position.x > lp.Position.x) { SkillSection[(int)MediSection].StartPos = touches.GetAveragePosition(); } } else if (SkillCategory.kSkillD == ActiveSkill) { if (cp.Position.y < lp.Position.y) { SkillSection[(int)MediSection].StartPos = touches.GetAveragePosition(); } } return(false); } else { Distance = UnityEngine.Vector2.Distance(touches.GetAveragePosition(), SkillSection[(int)MediSection].StartPos); } } else if (MediSection == Section.Third) { if (UnityEngine.Vector2.zero == SkillSection[(int)MediSection].StartPos) { if (UnityEngine.Vector2.zero == LastInputPos) { LastInputPos = touches.GetAveragePosition(); return(false); } Point cp = new Point(0, touches.GetAveragePosition()); Point lp = new Point(0, LastInputPos); if (SkillCategory.kSkillA == ActiveSkill) { if (cp.Position.x > lp.Position.x) { SkillSection[(int)MediSection].StartPos = touches.GetAveragePosition(); } } else if (SkillCategory.kSkillB == ActiveSkill) { if (cp.Position.y < lp.Position.y) { SkillSection[(int)MediSection].StartPos = touches.GetAveragePosition(); } } else if (SkillCategory.kSkillC == ActiveSkill) { if (cp.Position.x < lp.Position.x) { SkillSection[(int)MediSection].StartPos = touches.GetAveragePosition(); } } else if (SkillCategory.kSkillD == ActiveSkill) { if (cp.Position.y > lp.Position.y) { SkillSection[(int)MediSection].StartPos = touches.GetAveragePosition(); } } return(false); } else { Distance = UnityEngine.Vector2.Distance(touches.GetAveragePosition(), SkillSection[(int)MediSection].StartPos); } } if (Distance < ActiveDistance) { return(false); } else { if (!gesture.IsActive) { gesture.HintFlag = HintType.Hint; gesture.StartPosition = touches.GetAverageStartPosition(); RaiseHintEvent(gesture); gesture.IsActive = true; } } } return(true); }
protected override bool CanBegin(EasyGesture gesture, TouchManager.IFingerList touches) { if (touches.Count != RequiredFingerCount) { return(false); } if ("MouseInput" == TouchManager.Instance.InputProvider.name) { if (!Input.GetMouseButton(0)) { return(false); } } if (IsExclusive && TouchManager.Touches.Count != RequiredFingerCount) { return(false); } if (TouchType.Regognizer != TouchManager.curTouchState) { return(false); } if ((int)CurActiveSection >= SectionNumber - 1) { return(false); } if (CurActiveSection != Section.Invalid && gesture.IsInvalid) { return(false); } Section medi_section = (CurActiveSection == Section.Invalid ? Section.First : CurActiveSection + 1); float hint_distance = SkillSection[(int)medi_section].HintDistance; float tolerance_distance = SkillSection[(int)medi_section].ToleranceDistance; if (tolerance_distance > 0) { float cur_distance = 0; if (medi_section == Section.First) { gesture.IsInvalid = false; cur_distance = touches.GetAverageDistanceFromStart(); } else if (medi_section == Section.Second || medi_section == Section.Third) { if (Vector2.zero == SkillSection[(int)medi_section].StartPos) { if (Vector2.zero == LastInputPos) { LastInputPos = touches.GetAveragePosition(); return(false); } Vector2 cp = touches.GetAveragePosition(); Vector2 lp = LastInputPos; SkillSection[(int)medi_section].StartPos = CalcSectionStartPos(gesture, cp, lp, medi_section, SkillSection[(int)(medi_section - 1)].EndPos); LastInputPos = cp; /// if (Vector2.zero != WasInputPos) { SkillSection[(int)CurActiveSection].PathLength += Vector2.Distance(WasInputPos, cp); } else { SkillSection[(int)CurActiveSection].PathLength += Vector2.Distance(SkillSection[(int)(medi_section - 1)].EndPos, cp); } WasInputPos = cp; return(false); } else { cur_distance = Vector2.Distance(touches.GetAveragePosition(), SkillSection[(int)medi_section].StartPos); } } if (cur_distance < hint_distance) { return(false); } else { if (!gesture.IsHint) { gesture.HintFlag = HintType.Hint; gesture.StartPosition = touches.GetAverageStartPosition(); RaiseHintEvent(gesture); gesture.IsHint = true; } } if (cur_distance < tolerance_distance && EasySectionArg.SkillMode.Normal == SkillSection[(int)medi_section].skillmode) { return(false); } else { if (!gesture.IsActive) { gesture.IsActive = true; } } } return(true); }