Esempio n. 1
0
        private List <Shape> LevelOne()
        {
            List <Shape> newShapes;

            newShapes = BuildDragDropShapePair <Ellipse>();

            foreach (Shape sh in newShapes)
            {
                if (sh.IsTapEnabled == true) //shape, not drop
                {
                    DragShapes.Add(sh);
                    canvas.Children.Add(sh);

                    Canvas.SetLeft(sh, _rnd.Next((GameWidth / 2) - (int)sh.Width));  //keeps it on the left half of the screen
                    Canvas.SetTop(sh, _rnd.Next(GameHeight - (int)sh.Height));
                    CurrentShapeCount++;
                }
                else
                {
                    DropShapes.Add(sh);
                    canvas.Children.Add(sh);

                    Canvas.SetLeft(sh, _rnd.Next(GameWidth / 2, GameWidth - (int)sh.Width));  //keeps it on the bottom half of the screen
                    Canvas.SetTop(sh, _rnd.Next(GameHeight - (int)sh.Height));
                }
            }

            return(newShapes);
        }
Esempio n. 2
0
        private void Shape_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var el = sender as Shape;

            el.CapturePointer(e.Pointer);

            ActiveDragShape = el;
            ActiveDropShape = DropShapes.Find(d => (el.Fill as SolidColorBrush).Color == (d.Stroke as SolidColorBrush).Color);
        }
Esempio n. 3
0
        /// <summary>
        /// Clean up the game and progress to the next level.
        /// </summary>
        private void LevelComplete()
        {
            //todo: animation for winning
            PlayClap();

            List <Shape> shapes = canvas.Children.OfType <Shape>().ToList();

            shapes.AddRange(canvas.Children.OfType <Ellipse>().ToList());
            shapes.AddRange(canvas.Children.OfType <Polygon>().ToList());
            shapes.AddRange(canvas.Children.OfType <Rectangle>().ToList());

            foreach (Object ob in shapes)
            {
                canvas.Children.Remove(ob as UIElement);
            }

            DragShapes.Clear();
            DropShapes.Clear();

            GameStart(++CurrentLevel);
        }
Esempio n. 4
0
        private List <Shape> LevelTwo()
        {
            List <Shape> newShapes;

            newShapes = BuildDragDropShapePair <Ellipse>();

            foreach (Shape el in newShapes)
            {
                if (el.IsTapEnabled == true) //shape, not drop
                {
                    DragShapes.Add(el);
                    canvas.Children.Add(el);

                    do
                    {
                        Canvas.SetLeft(el, _rnd.Next((GameWidth / 3) * 2, GameWidth - (int)el.Width)); //far right third of screen
                        Canvas.SetTop(el, _rnd.Next(0, (GameHeight / 2) - (int)el.Height));            //keeps it on the bottom half of the screen
                    } while (CheckForOverlaps(el));

                    CurrentShapeCount++;
                }
                else
                {
                    DropShapes.Add(el);
                    canvas.Children.Add(el);

                    do
                    {
                        Canvas.SetLeft(el, _rnd.Next(0, (GameWidth / 3) - (int)el.Width));         //far left third of screen
                        Canvas.SetTop(el, _rnd.Next(GameHeight / 2, GameHeight - (int)el.Height)); //keeps it on the top half of the screen
                    } while (CheckForOverlaps(el));
                }
            }

            newShapes.AddRange(LevelOne()); //another simple left/right ellipse pair

            return(newShapes);
        }
Esempio n. 5
0
        private List <Shape> LevelThree()
        {
            List <Shape> newShapes;

            newShapes = BuildDragDropShapePair <Rectangle>();

            foreach (Rectangle polyShape in newShapes)
            {
                //polyShape.Points.Add(new Point(0, 100)); //bottomLeft);
                //polyShape.Points.Add(new Point(20, 100)); //bottomRight);
                //polyShape.Points.Add(new Point(30, 3)); //top);
                //polyShape.Height = 100;
                //polyShape.Width = 100;

                canvas.Children.Add(polyShape);

                Canvas.SetLeft(polyShape, _rnd.Next(0, GameWidth - (int)polyShape.Width));
                Canvas.SetTop(polyShape, _rnd.Next(0, GameHeight - (int)polyShape.Height));

                if (polyShape.IsTapEnabled == true) //shape, not drop
                {
                    DragShapes.Add(polyShape);
                    CurrentShapeCount++;
                }
                else
                {
                    DropShapes.Add(polyShape);
                }
            }

            newShapes.AddRange(LevelOne());
            newShapes.AddRange(LevelTwo());

            //todo: tapping on shapes will grow/shrink its drop to help show the difference

            return(newShapes);
        }