Exemplo n.º 1
0
    public void StartAtPosition(CanvasPosition pos)
    {
        switch (pos)
        {
        case CanvasPosition.Main:
            desiredCanvasPosition = menuPosition [0];
            break;

        case CanvasPosition.LevelSelection:
            desiredCanvasPosition = menuPosition [1];
            break;

        case CanvasPosition.Progress:
            desiredCanvasPosition = menuPosition [2];
            if (!hasProgressPlayed)
            {
                isProgressPlaying = true;
            }
            break;

        case CanvasPosition.Shop:
            desiredCanvasPosition = menuPosition [3];
            break;
        }
        GameObject.FindGameObjectWithTag("UIRoot").GetComponent <RectTransform>().anchoredPosition = desiredCanvasPosition;
    }
Exemplo n.º 2
0
    public void PositionCanvas(CanvasPosition pos)
    {
        isInPositionTransition = true;
        positionStartPosition  = thisTransform.anchoredPosition;


        switch (pos)
        {
        case CanvasPosition.Main:
            desiredCanvasPosition = menuPosition [0];
            break;

        case CanvasPosition.LevelSelection:
            desiredCanvasPosition = menuPosition [1];
            break;

        case CanvasPosition.Progress:
            desiredCanvasPosition = menuPosition [2];
            if (!hasProgressPlayed)
            {
                isProgressPlaying = true;
            }
            break;

        case CanvasPosition.Shop:
            desiredCanvasPosition = menuPosition [3];
            break;
        }
    }
        /// <summary>
        /// Image pointer pressed event handler
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="e">Pointer down event args</param>
        void Image_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            //Break if we have an active image or the slider happens to be active
            if (m_activeImage != null || m_sliderActive)
            {
                return;
            }
            //Cast the sender to get an image instance
            Image img = sender as Image;

            //Check if we got a valid image instance
            if (img != null)
            {
                //Set the current active image instance
                m_activeImage = img;
                //Set the image's z Index to 1 so it's rendered over other images
                Canvas.SetZIndex(m_activeImage, 1);
                //Store the images position
                m_activePosition = m_imagePositions[m_activeImage];
                //Feed the gesture recognizer a pointer point relative to the image instance
                m_gestureRecognizer.ProcessDownEvent(e.GetCurrentPoint(img));
                //Mark the event as handled
                e.Handled = true;
            }
        }
 /// <summary>
 /// A helper method used to position the picker's images
 /// </summary>
 void UpdateImagePositions()
 {
     //Iterate over all of the picker's images
     foreach (Image img in m_images)
     {
         //Get the image's CanvasPosition
         CanvasPosition p = m_imagePositions[img];
         //Set the image's y position taking the global offset into account
         Canvas.SetTop(img, p.Y - m_itemOffset);
     }
 }
        /// <summary>
        /// Image pointer released event handler
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="e">Pointer released event args</param>
        void Image_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            //Break if we have no active image
            if (m_activeImage == null || m_sliderActive)
            {
                return;
            }
            //Cast the sender to get an image instance
            Image img = sender as Image;

            //Check if we got a valid image instance
            if (img != null)
            {
                //Get the pointer point relative to the image
                PointerPoint imgPoint = e.GetCurrentPoint(img);
                if (!imgPoint.IsInContact)
                {
                    //Feed the up pointer point to the gesture recognizer
                    m_gestureRecognizer.ProcessUpEvent(imgPoint);
                }
                //Make the gesture recognizer complete the gesture
                m_gestureRecognizer.CompleteGesture();
                //Mark the event as handled
                e.Handled = true;

                //Check if we have a drop target and a PictureDrop delegate is registered
                if (m_droppingTarget != null &&
                    PictureDropped != null)
                {
                    //Get the pointer points relative to the target and picker
                    PointerPoint canvasPoint = e.GetCurrentPoint(m_droppingTarget);
                    PointerPoint pickerPoint = e.GetCurrentPoint(this);
                    //Produce the target's and pickers bounding rectangles
                    Rect canvasRect = new Rect(0.0, 0.0, this.DropTarget.ActualWidth, this.DropTarget.ActualHeight);
                    Rect pickerRect = new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight);

                    //Verify the pointer points position, making sure it's contained in the target but not in the picker
                    if (ContainedIn(canvasPoint, canvasRect) && !ContainedIn(pickerPoint, pickerRect))
                    {
                        //Adjust the drop position to compensate for the user's finger position relative to the image
                        Point imgPos = new Point(canvasPoint.Position.X - imgPoint.Position.X, canvasPoint.Position.Y - imgPoint.Position.Y);
                        //Raise the image dropped event
                        this.PictureDropped(this, new PictureDropEventArgs(img.Source, imgPos));
                    }
                }
                //Restore the images z index
                Canvas.SetZIndex(m_activeImage, 0);
                //Clear state
                m_activeImage    = null;
                m_activePosition = null;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Renders the game actor.
        /// </summary>
        public void Draw(SpriteBatch spriteBatch)
        {
            Animation animation;

            Animations.TryGetValue(AnimationIndex, out animation);

            if (animation == null)
            {
                return;
            }

            eventManager.Notify(new TextureDrawReadyEvent(animation.Spritesheet, CanvasPosition.ToVector2(), animation.SpriteSourceRectangle, DrawLayer.Game));
        }
Exemplo n.º 7
0
        private void AddDiskToWhiteEatens(DiskElement disk)
        {
            var position = CanvasPosition.CreateBottomLeft(85, 92.5);

            if (EatenWhites.Count > 0)
            {
                position =
                    EatenWhites.First()
                    .CanvasPosition
                    .AddVertical(-15)
                    .NormalizeVertically(eatensColumNormalization);
            }
            disk.CanvasPosition = position;
            EatenWhites.AddFirst(disk);
        }
Exemplo n.º 8
0
 private CanvasPosition InitialCanvasPosition(int columnIndex)
 {
     if (columnIndex < 6)
     {
         return(CanvasPosition.CreateTopLeft(5, 5 + columnIndex * 15));
     }
     if (columnIndex < 12)
     {
         return(CanvasPosition.CreateTopRight(5, 5 + (11 - columnIndex) * 15));
     }
     if (columnIndex < 18)
     {
         return(CanvasPosition.CreateBottomRight(5, 5 + (columnIndex - 12) * 15));
     }
     //if (columnIndex < 24)
     return(CanvasPosition.CreateBottomLeft(5, 5 + (23 - columnIndex) * 15));
 }
Exemplo n.º 9
0
 public void LoadMenuAt(CanvasPosition pos)
 {
     SceneManager.LoadScene("Menu");
     isLoadMenuAt = true;
     menuPos      = pos;
 }