// Methoden public override void update(TimeSpan deltaTime) { // Bewegung aufrufen moveBehavior.move(this, deltaTime); // Bereich der Bitmap bestimmen, die gezeichnet werden soll. Dabei alle 10 Frames den Bereich wechseln. if (_frameswitch <= 10) { srcRectangle = new structRectangle(0, 0, 100, 100); } else { srcRectangle = new structRectangle(100, 0, 100, 100); } if (_frameswitch >= 20) { _frameswitch = 0; } destRectangle = new structRectangle((int)X, (int)Y, 100, 100); _frameswitch += 1; base.update(deltaTime); }
void InteractionRectangle(ref structRectangle rectangle, Joint joint) { if ((countdown.Elapsed - rectangle.beginTime).Seconds > 1) { canvas.Children.Add(rectangle.rect); if (joint.Intersection(rectangle.rect)) { switch (joint.JointType) { case JointType.HandLeft: if (rectangle.handState == leftHandState) UpdateRectangleThingsMain(ref rectangle); break; case JointType.HandRight: if (rectangle.handState == rightHandState) UpdateRectangleThingsMain(ref rectangle); break; } } } }
void UpdateUIRectangleMain(ref structRectangle rectangle) { Rectangle rect = rectangle.rect; double rectWidth = rect.ActualWidth == 0 ? rect.Width : rect.ActualWidth; double rectHeight = rect.ActualHeight == 0 ? rect.Height : rect.ActualHeight; positionList.Add(rectangle.position); string cadena = positionList[0]; positionList.RemoveAt(0); int x = (int)(rectWidth * char.GetNumericValue(cadena[0])); int y = (int)(rectHeight * char.GetNumericValue(cadena[2])); rectangle.position = cadena; Canvas.SetLeft(rect, x); Canvas.SetTop(rect, y); }
// Methods only used in the Main Screen void UpdateRectangleThingsMain(ref structRectangle rectangle) { UpdateUIRectangleMain(ref rectangle); canvas.Children.Remove(rectangle.rect); rectangle.beginTime = countdown.Elapsed; }
void InteractionRectangle(ref structRectangle rectangle, Joint[] joints) { if ((countdown.Elapsed - rectangle.beginTime).Seconds > 1) { if ((countdown.Elapsed - rectangle.beginTime).Seconds > randomGenerator.Next(lowRandom, 20)) { if (rectangle.gestureTried) score += 10; else score -= score - 20 < 0 ? score : 20; UpdateRectangleThings(ref rectangle); return; } canvas.Children.Add(rectangle.rect); //Countdown.Text = "Nope"; foreach (Joint joint in joints) { if (joint.Intersection(rectangle.rect)) { switch (joint.JointType) { case JointType.HandLeft: if (rectangle.handState != leftHandState) { rectangle.gestureTried = true; continue; } break; case JointType.HandRight: if (rectangle.handState != rightHandState) { rectangle.gestureTried = true; continue; } break; } // Countdown.Text = "Intersection!!!!!"; score += 20; UpdateRectangleThings(ref rectangle); break; } } } }
void UpdateRectangleThings(ref structRectangle rectangle) { UpdateUIRectangle(ref rectangle); canvas.Children.Remove(rectangle.rect); rectangle.beginTime = countdown.Elapsed; rectangle.gestureTried = false; }
// Methods only used in the actual game (not main screen) void UpdateUIRectangle(ref structRectangle rectangle) { double width = canvas.ActualWidth == 0 ? canvas.Width : canvas.ActualWidth; double height = canvas.ActualHeight == 0 ? canvas.Height : canvas.ActualHeight; //int x = randomGenerator.Next(0, 2) == 0 ? randomGenerator.Next((int)(width / 10), (int)(2 * width / 10)) : randomGenerator.Next((int)(7 * width / 10), (int)(9 * width / 10)); //int y = randomGenerator.Next((int)(height / 10), (int)(8 * height / 10 )); Rectangle rect = rectangle.rect; double rectWidth = rect.ActualWidth == 0 ? rect.Width : rect.ActualWidth; double rectHeight = rect.ActualHeight == 0 ? rect.Height : rect.ActualHeight; double maxX = width / rectWidth; double maxY = height / rectHeight; int x = randomGenerator.Next(0, 2) == 0 ? (int)rectWidth * randomGenerator.Next((int)(maxX / 10), (int)(2 * maxX / 10)) : (int)rectWidth * randomGenerator.Next((int)(8 * maxX / 10), (int)(maxX)); int y = (int)rectHeight * randomGenerator.Next((int)(2 * maxY / 10), (int)(9 * maxY / 10)); positionList.Remove(rectangle.position); string cadena = x.ToString() + ":" + y.ToString(); while (positionList.Contains(cadena)) { x = randomGenerator.Next(0, 2) == 0 ? (int)rectWidth * randomGenerator.Next((int)(maxX / 10), (int)(2 * maxX / 10)) : (int)rectWidth * randomGenerator.Next((int)(8 * maxX / 10), (int)(maxX)); y = (int)rectHeight * randomGenerator.Next((int)(2 * maxY / 10), (int)(9 * maxY / 10)); cadena = x.ToString() + ":" + y.ToString(); } positionList.Add(cadena); rectangle.position = cadena; Canvas.SetLeft(rect, x); Canvas.SetTop(rect, y); }
public MainWindow() { InitializeComponent(); countdownIsStored = false; actualState = GameState.Initialize; countdown = new Stopwatch(); //Hello World gesture waveRightHand = new WaveHand(); waveRightHand.waveRight = false; waveRightHand.waveLeft = false; waveRightHand.waveCount = 0; waveRightHand.waveWatch = new Stopwatch(); waveLeftHand = new WaveHand(); waveLeftHand.waveRight = false; waveLeftHand.waveLeft = false; waveLeftHand.waveCount = 0; waveLeftHand.waveWatch = new Stopwatch(); WaveHand.isWaving = false; randomGenerator = new Random(); structRectangleArray = new structRectangle[3]; bodyRect = new Rect(new Size(40, 40)); intersectionSize = new Size(0,0); intersectionRect = new Rect(0,0,0,0); structRectangleArray[0] = new structRectangle(Colors.Pink); structRectangleArray[0].handState = HandState.Closed; structRectangleArray[0].position = "3:4"; structRectangleArray[1] = new structRectangle(Colors.Blue); structRectangleArray[1].handState = HandState.Lasso; structRectangleArray[1].position = "5:4"; structRectangleArray[2] = new structRectangle(Colors.Green); structRectangleArray[2].handState = HandState.Open; structRectangleArray[0].position = "7:4"; jointArray = new Joint[3]; positionList = new List<string>(); score = 0; lowRandom = 11; }
public MainWindow() { InitializeComponent(); countdownIsStored = false; actualState = GameState.Initialize; countdown = new Stopwatch(); //Hello World gesture waveRightHand = new WaveHand(); waveRightHand.waveRight = false; waveRightHand.waveLeft = false; waveRightHand.waveCount = 0; waveRightHand.waveWatch = new Stopwatch(); waveLeftHand = new WaveHand(); waveLeftHand.waveRight = false; waveLeftHand.waveLeft = false; waveLeftHand.waveCount = 0; waveLeftHand.waveWatch = new Stopwatch(); WaveHand.isWaving = false; randomGenerator = new Random(); structRectangleArray = new structRectangle[3]; bodyRect = new Rect(new Size(40, 40)); intersectionSize = new Size(0,0); intersectionRect = new Rect(0,0,0,0); Image image = new Image(); BitmapImage bp = new BitmapImage(); image.Width = 200; image.Height = 200; structRectangleArray[0] = new structRectangle(Colors.Pink); structRectangleArray[0].handState = HandState.Closed; structRectangleArray[0].position = "2:3"; structRectangleArray[0].icon = image; bp.UriSource = new Uri(@"D:\STUDIUM\Auslandssemester\NPI\NPI_Übung\NPI---Kinect-2.0\Designstuff\fist.png"); structRectangleArray[0].icon.Source = bp; structRectangleArray[1] = new structRectangle(Colors.Blue); structRectangleArray[1].handState = HandState.Lasso; structRectangleArray[1].position = "4:3"; structRectangleArray[1].icon = image; bp.UriSource = new Uri(@"D:\STUDIUM\Auslandssemester\NPI\NPI_Übung\NPI---Kinect-2.0\Designstuff\lasso.png"); structRectangleArray[1].icon.Source = bp; structRectangleArray[2] = new structRectangle(Colors.Green); structRectangleArray[2].handState = HandState.Open; structRectangleArray[2].position = "7:3"; structRectangleArray[2].icon = image; bp.UriSource = new Uri(@"D:\STUDIUM\Auslandssemester\NPI\NPI_Übung\NPI---Kinect-2.0\Designstuff\open.png"); structRectangleArray[2].icon.Source = bp; jointArray = new Joint[3]; positionList = new List<string>(); score = 0; lowRandom = 11; //Clau start /* PictureBox pic = new PictureBox { Name = "pictureBox", Size = new Size(50, 50), Location = new Point(14, 17), ImageLocation = @"D:\STUDIUM\Auslandssemester\NPI\NPI_Übung\NPI---Kinect-2.0\Designstuff\fist.png" }; */ //Clau end }
// Methoden public override void update(TimeSpan deltaTime) { moveBehavior.move(this, deltaTime); destRectangle = new structRectangle(X, Y, Width, Height); base.update(deltaTime); }