protected void stopTimer(Target target) { target.setTargetUnselected(); rightHandTargetID = -1; rightHandTarget = null; rightHandTimer.Dispose(); }
protected void startTimer(Target target, double seconds) { rightHandTargetID = target.id; rightHandTarget = target; rightHandTimer = new Timer(seconds * 1000); rightHandTimer.AutoReset = false; rightHandTimer.Elapsed += new ElapsedEventHandler(rightHandTimer_Elapsed); rightHandTimer.Enabled = true; target.setTargetHighlighted(); }
private static Boolean ballIntersectsTarget(BallModel ball, Target target) { double ballX = ball.X; double ballY = ball.Y; double ballR = ball.R; double targetX = target.getXPosition(); double targetY = target.getYPosition(); double targetR = target.getTargetRadius(); double distance = Math.Sqrt(Math.Pow(ballX - targetX,2) + Math.Pow(ballY - targetY,2)); return distance < targetR+ballR*0.3; }
private int increaseOrDecrease(Joint hand, int lr, Target cur) { double deltaX = hand.Position.X - cur.getXPosition(); double deltaY = - (hand.Position.Y - cur.getYPosition()); double angle = Math.Atan(deltaY/deltaX); if (deltaX < 0) { angle += Math.PI; } if (angle < 0) { angle += (2*Math.PI); } if (thetas[lr] == -1) { thetas[lr] = angle; return 0; } double delta_theta = angle - thetas[lr]; thetas[lr] = angle; if (delta_theta > Math.PI) { return 1; } if (delta_theta < -1 * Math.PI) { return -1; } if (delta_theta > 0) { return -1; } else { return 1; } }
private void handleTargetIntersected(Target t, double value) { int currentValue = Convert.ToInt16(t.getTargetText()); currentValue += (int)value; if (currentValue >= 100) { currentValue = 100; t.setTargetSelected(); } t.setTargetText(currentValue.ToString()); }