private void OnTouchAction(object sender, TouchTracking.TouchActionEventArgs args) { if (args.Type == TouchTracking.TouchActionType.Pressed && !m_Pause) { Point loc = args.Location; loc.X -= (MainGrid.Width - FieldCol.Width.Value) / 2; foreach (var ball in view.Children.OfType <Ball>()) { if ((ball.State != Ball.St.Rolling) && (ball.State != Ball.St.Demo)) { continue; } var b = ball.Bounds; if (b.Contains(loc)) { ball.EnterShoot((b.Center.X - loc.X) / b.Width, (b.Center.Y - loc.Y) / b.Height); Sound[snd_foot + foot_stereo].Play(); foot_stereo = 1 - foot_stereo; if (m_GameOver) { NewGame(); return; } } } } }
void TouchEffect_TouchAction(System.Object sender, TouchTracking.TouchActionEventArgs args) { if (args.Type == TouchTracking.TouchActionType.Cancelled || args.Type == TouchTracking.TouchActionType.Exited || args.Type == TouchTracking.TouchActionType.Released) { return; } Point pt = args.Location; SKPoint point = new SKPoint((float)(GameGrid.CanvasSize.Width * pt.X / GameGrid.Width), (float)(GameGrid.CanvasSize.Height * pt.Y / GameGrid.Height)); var x = point.X; var y = point.Y; var row = (int)y / CellSize; var col = (int)x / CellSize; if (row >= rows) { return; } if (gamedata[row, col] == null) { gamedata[row, col] = new GridCell(); } gamedata[row, col].Tapped(args.Id); GameGrid.InvalidateSurface(); }
private void OnTouch(object sender, TouchTracking.TouchActionEventArgs args) { var viewPoint = args.Location; SKPoint point = new SKPoint((float)(_canvasView.CanvasSize.Width * viewPoint.X / _canvasView.Frame.Width), (float)(_canvasView.CanvasSize.Height * viewPoint.Y / _canvasView.Frame.Height)); var actionType = args.Type; _touchGestureRecognizer.ProcessTouchEvent(args.Id, actionType, point); }
private void OnTouch(object sender, TouchTracking.TouchActionEventArgs args) { if (args.Type == TouchTracking.TouchActionType.Pressed) { var x = args.Location.X * _density; var y = args.Location.Y * _density; var ppi = new PointParticleInitializer(new Window(Height, Width), new Vector2((float)x, (float)y)); var emitter = new Emitter <SKParticle2D>(ppi, 100) { //AvgLife = 5, Forces = new List <IApplyForce>() { new Gravity() } }; _renderer.AddEmitter(emitter); } }
private void TouchEffect_TouchAction(object sender, TouchTracking.TouchActionEventArgs args) { print("TOUCH ACCTION0"); bool lockActionOnly = false; void CheckLock() { if (Player == null) { lockActionOnly = true; return; } else if (Player.State == VLCState.Error) { lockActionOnly = true; return; } else if (Player.State == VLCState.Opening) { lockActionOnly = true; return; } else if (Player.Length == -1) { lockActionOnly = true; return; } else if (!Player.IsSeekable) { lockActionOnly = true; return; } } try { CheckLock(); } catch (Exception _ex) { print("ERRORIN TOUCH: " + _ex); lockActionOnly = true; } if (args.Type == TouchTracking.TouchActionType.Pressed || args.Type == TouchTracking.TouchActionType.Moved || args.Type == TouchTracking.TouchActionType.Entered) { CurrentTap++; } else if (args.Type == TouchTracking.TouchActionType.Cancelled || args.Type == TouchTracking.TouchActionType.Exited || args.Type == TouchTracking.TouchActionType.Released) { StartFade(); } // ========================================== LOCKED LOGIC ========================================== if (isLocked || lockActionOnly) { if (args.Type == TouchTracking.TouchActionType.Pressed) { startPressTime = System.DateTime.Now; } if (args.Type == TouchTracking.TouchActionType.Released && System.DateTime.Now.Subtract(startPressTime).TotalSeconds < 0.4) { if (TotalOpasity == 1) { FadeEverything(true); } else { FadeEverything(false); } } return; } ; if (lockActionOnly) { return; } // ========================================== NORMAL LOGIC ========================================== if (args.Type == TouchTracking.TouchActionType.Pressed) { if (DateTime.Now.Subtract(lastClick).TotalSeconds < 0.25) // Doubble click { lastRelease = DateTime.Now; bool forward = (TapRec.Width / 2.0 < args.Location.X); SeekMedia(SKIPTIME * (forward ? 1 : -1)); if (forward) { SkipFor(); } else { SkipBac(); } } lastClick = DateTime.Now; FadeEverything(false); startCursorPosition = args.Location; isMovingFromLeftSide = (TapRec.Width / 2.0 > args.Location.X); isMovingStartTime = Player.Time; isMovingSkipTime = 0; isMovingCursor = false; cursorPosition = args.Location; maxVol = Volyme >= 100 ? 200 : 100; } else if (args.Type == TouchTracking.TouchActionType.Moved) { print(startCursorPosition.X - args.Location.X); if ((minimumDistance < Math.Abs(startCursorPosition.X - args.Location.X) || minimumDistance < Math.Abs(startCursorPosition.X - args.Location.X)) && !isMovingCursor) { // STARTED FIRST TIME isMovingHorozontal = Math.Abs(startCursorPosition.X - args.Location.X) > Math.Abs(startCursorPosition.Y - args.Location.Y); isMovingCursor = true; } else if (isMovingCursor) // DRAGINS SKIPING TIME { if (isMovingHorozontal) { double diffX = (args.Location.X - startCursorPosition.X) * 2.0 / TapRec.Width; isMovingSkipTime = (long)((Player.Length * (diffX * diffX) / 10) * (diffX < 0 ? -1 : 1)); // EXPONENTIAL SKIP LIKE VLC if (isMovingSkipTime + isMovingStartTime > Player.Length) // SKIP TO END { isMovingSkipTime = Player.Length - isMovingStartTime; } else if (isMovingSkipTime + isMovingStartTime < 0) // SKIP TO FRONT { isMovingSkipTime = -isMovingStartTime; } SkiptimeLabel.Text = $"{CloudStreamCore.ConvertTimeToString((isMovingStartTime + isMovingSkipTime) / 1000)} [{ (Math.Abs(isMovingSkipTime) < 1000 ? "" : (isMovingSkipTime > 0 ? "+" : "-"))}{CloudStreamCore.ConvertTimeToString(Math.Abs(isMovingSkipTime / 1000))}]"; } else { if (isMovingFromLeftSide) { if (canChangeBrightness) { BrightnessProcentage -= (args.Location.Y - cursorPosition.Y) / 2.0; BrightnessProcentage = Math.Max(Math.Min(BrightnessProcentage, 100), 0); // CLAM SkiptimeLabel.Text = $"Brightness {(int)BrightnessProcentage}%"; } } else { Volyme -= (args.Location.Y - cursorPosition.Y) / 2.0; Volyme = Math.Max(Math.Min(Volyme, maxVol), 0); // CLAM SkiptimeLabel.Text = $"Volyme {(int)Volyme}%"; } } cursorPosition = args.Location; } } else if (args.Type == TouchTracking.TouchActionType.Released) { if (isMovingCursor && isMovingHorozontal && Math.Abs(isMovingSkipTime) > 1000) // SKIP TIME { FadeEverything(true); SeekMedia(isMovingSkipTime - Player.Time + isMovingStartTime); } else { SkiptimeLabel.Text = ""; isMovingCursor = false; if ((DateTime.Now.Subtract(lastClick).TotalSeconds < 0.25) && TotalOpasity == 1 && DateTime.Now.Subtract(lastRelease).TotalSeconds > 0.25) // FADE WHEN REALEASED { FadeEverything(true); } } } print("LEFT TIGHT " + (TapRec.Width / 2.0 < args.Location.X) + TapRec.Width + "|" + TapRec.X); print("TOUCHED::D:A::A" + args.Location.X + "|" + args.Type.ToString()); }
private void TouchHandlerOnTouch(object sender, TouchTracking.TouchActionEventArgs args) { _touchEffect.OnTouchAction(sender, args); }