Example #1
0
        public async void AnalyzeTouch()
        {
            var touchDiff  = LastTouch.Y - FirstTouch.Y;
            var touchDiffX = LastTouch.X - FirstTouch.X;

            if (touchDiff > 66)
            {
                var sprite = new SKSpriteNode("dart_blue")
                {
                    Position = new CGPoint(
                        FirstTouch.X, -5f)
                };


                //dart_blue
//				var sprite1 = new SKSpriteNode ("knife1") {
//					Position = new CGPoint(
//						FirstTouch.X,-5f )
//				};



                sprite.SetScale(1.5f);
                AddChild(sprite);

                var finaldest = new CGPoint();
                var action    = SKAction.MoveTo(finaldest, 0.3);

                if (touchDiff < 150)
                {
                    finaldest = new CGPoint(LastTouch.X + (touchDiffX * 0.5f), LastTouch.Y + (touchDiff * 0.3f));
                    action    = SKAction.MoveTo(finaldest, 0.3);                //FollowPath (np, 3.0);
                }
                else
                {
                    finaldest = new CGPoint(LastTouch.X + (touchDiffX * 0.5f),
                                            LastTouch.Y + (touchDiff * 0.6f));

                    action = SKAction.MoveTo(finaldest, 0.2);
                }

                nfloat rotatingAngle = touchDiffX / 333;

                Console.WriteLine("touchDiff:::" + touchDiffX);
                Console.WriteLine("toRadians:::" + rotatingAngle);

                //to radians
                var RotAction = SKAction.RotateToAngle(-rotatingAngle, 0);

                //to small size
                var scaleAction = SKAction.ScaleTo(0.8f, 0.1555);

                sprite.RunAction(action);
                sprite.RunAction(RotAction);
                sprite.RunAction(scaleAction);

                SpriteCount++;

                //COLLISION
                if (PhotoNode.ContainsPoint(finaldest))
                {
                    CurrentScore++;
                    System.Diagnostics.Debug.WriteLine("POINTS:    " + CurrentScore);
                    System.Diagnostics.Debug.WriteLine("collideddddddd::::::::::::::::::::::");

                    await System.Threading.Tasks.Task.Delay(200);

                    await System.Threading.Tasks.Task.Delay(200);

                    var displayScoreNode = new SKLabelNode();

                    displayScoreNode.Text      = "" + CurrentScore;                    //.ToString ();
                    displayScoreNode.Position  = new CGPoint(Size.Width / 2, (Size.Height / 2) - 200);
                    displayScoreNode.FontSize  = 80;
                    displayScoreNode.FontColor = UIColor.Red;
                    displayScoreNode.FontName  = "GillSans-Bold";
                    displayScoreNode.SetScale(0.1f);

                    var moveUpAction  = SKAction.MoveTo((new CGPoint(Size.Width / 2, Size.Height / 2)), 0.5);
                    var scaleUpAction = SKAction.ScaleBy(9f, 0.5);
                    AddChild(displayScoreNode);

                    displayScoreNode.RunAction(moveUpAction);
                    displayScoreNode.RunAction(scaleUpAction);

                    await System.Threading.Tasks.Task.Delay(1000);

                    displayScoreNode.RemoveFromParent();
                }
                else
                {
                    await System.Threading.Tasks.Task.Delay(300);

                    SystemSound.Vibrate.PlaySystemSound();                     //.PlayAlertSound();
                    SystemSound.Vibrate.Close();
                }

                //REMOVE SLOW DART
                if (touchDiff < 100)
                {
                    await System.Threading.Tasks.Task.Delay(200);

                    sprite.RemoveFromParent();
                    SpriteCount--;
                }

                if (touchDiff > 120 && (!PhotoFrameNode.ContainsPoint(finaldest)))
                {
                    await System.Threading.Tasks.Task.Delay(300);

                    SystemSound.Vibrate.PlaySystemSound();                     //.PlayAlertSound();
                    SystemSound.Vibrate.Close();
                    await System.Threading.Tasks.Task.Delay(200);
                }
            }
        }