Example #1
0
        private void MouseMovement(object sender, MouseEventArgs e)
        {
            lblMouseLocation.Text = string.Format("x={0}  y={1} wheel={2}", e.X, e.Y, e.Delta);
            lblButtonPressed.Text = $"Button pressed: {e.Button}";

            MouseLocation loc = new MouseLocation
            {
                x = e.X,
                y = e.Y
            };

            if (MouseLocations.ContainsKey(loc))
            {
                MouseLocations[loc]++;
            }
            else
            {
                MouseLocations.Add(loc, 1);
            }

            string currentWindow = GetActiveWindowTitle();

            lblCurrentWindow.Text = $"Active window: {(currentWindow ?? "Unknown")}";

            CanDraw = true;
            pbMouseData.Refresh();
        }
Example #2
0
 /// <summary>
 /// Initializes the <see cref="Common.UI.DockWidgets.DragHandler"/> class.
 /// </summary>
 static DragHandler()
 {
     mDockWidget    = null;
     mHandledByArea = null;
     mMouseLocation = MouseLocation.Outside;
     mMinimum       = float.MaxValue;
 }
    private MouseLocation _mouseLocation;       // Reference to the mouse location script

    //---------------------------------------------------------------------
    // Messages
    //---------------------------------------------------------------------

    private void Awake()
    {
        //Grab the needed component references
        _playerMovement = GetComponent <PlayerMovement>();
        _playerAttack   = GetComponent <PlayerAttack>();
        _mouseLocation  = GetComponent <MouseLocation>();
    }
        /// <summary>
        /// Initializes the <see cref="Common.UI.DockWidgets.DragInfoHolder"/> class.
        /// </summary>
        static DragInfoHolder()
        {
            DebugEx.Verbose("Created DragInfoHolder object");

            sDockWidget    = null;
            sMinimum       = float.MaxValue;
            sDockingArea   = null;
            sMouseLocation = MouseLocation.Outside;
        }
        /// <summary>
        /// Initializes the <see cref="Common.UI.DockWidgets.DragInfoHolder"/> class.
        /// </summary>
        static DragInfoHolder()
        {
            DebugEx.Verbose("Created DragInfoHolder object");

            sDockWidget    = null;
            sMinimum       = float.MaxValue;
            sDockingArea   = null;
            sMouseLocation = MouseLocation.Outside;
        }
Example #6
0
 void Start()
 {
     mLastPos         = new Vector3Int(0, 0, 0);
     mTileSelector    = GameObject.Find("TileSelector");
     mMouseLocation   = transform.parent.gameObject.GetComponent <MouseLocation>();
     mDrawnObjects    = new List <GameObject>();
     mMovementStack   = new List <Vector3>();
     mFlowController  = GameObject.Find("FlowController").GetComponent <FlowController>();
     mActionComponent = mActionSelector.GetComponent <ActionSelector>();
     //GameObject.Find("Allies").GetComponentInChildren<CharacterStats>().UI_SetStats();
     mDialogueController = GameObject.Find("DialogueController");
 }
Example #7
0
    bool isTouchingAiming;         //usado se estiver rodando em mobile.

    void Awake()
    {
        //Garante que exista apenas o Instance, caso seja nulo recebe a si mesmo, caso seja outro código se destroy.
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(this);
        }
    }
        SpanData <ReferenceInfo>?GetReference(MouseEventArgs e)
        {
            var loc = MouseLocation.TryCreateTextOnly(documentViewer.TextView, e);

            if (loc == null)
            {
                return(null);
            }
            if (loc.Position.IsInVirtualSpace)
            {
                return(null);
            }
            return(GetReference(loc.Position.Position.Position));
        }
Example #9
0
        MouseReferenceInfo?GetReferenceCore(MouseEventArgs e)
        {
            if (Keyboard.Modifiers != ModifierKeys.None && Keyboard.Modifiers != ModifierKeys.Control)
            {
                return(null);
            }

            var documentViewer = TryGetDocumentViewer();

            if (documentViewer == null)
            {
                return(null);
            }

            var loc = MouseLocation.Create(documentViewer.TextView, e, insertionPosition: false);

            if (loc == null)
            {
                return(null);
            }
            if (loc.Position.IsInVirtualSpace)
            {
                return(new MouseReferenceInfo(null, null, loc.Position));
            }
            int pos      = loc.Position.Position.Position;
            var spanData = documentViewer.Content.ReferenceCollection.Find(pos, false);

            if (spanData == null)
            {
                return(new MouseReferenceInfo(null, spanData, loc.Position));
            }
            if (spanData.Value.Data.Reference == null)
            {
                return(new MouseReferenceInfo(null, spanData, loc.Position));
            }
            if (Keyboard.Modifiers != ModifierKeys.Control)
            {
                if (spanData.Value.Data.IsDefinition)
                {
                    return(new MouseReferenceInfo(null, spanData, loc.Position));
                }
                if (spanData.Value.Data.IsLocal)
                {
                    return(new MouseReferenceInfo(null, spanData, loc.Position));
                }
            }

            return(new MouseReferenceInfo(spanData, spanData, loc.Position));
        }
Example #10
0
    private Vector2 _screenPosition;                        //Where the mouse is on the screen

    //---------------------------------------------------------------------
    // Messages
    //---------------------------------------------------------------------

    private void Awake()
    {
        //This is a common approach to handling a class with a reference to itself.
        //If instance variable doesn't exist, assign this object to it
        if (Instance == null)
        {
            Instance = this;
        }
        //Otherwise, if the instance variable does exist, but it isn't this object, destroy this object.
        //This is useful so that we cannot have more than one MouseLocation object in a scene at a time.
        else if (Instance != this)
        {
            Destroy(this);
        }
    }
Example #11
0
    bool isTouchAiming;           //Are we using touch to aim? This will be used if we are on a mobile device

    void Awake()
    {
        //这是通过引用自身来处理类的常用方法。
        //This is a common approach to handling a class with a reference to itself.
        //如果实例变量不存在,则将此对象分配给它
        //If instance variable doesn't exist, assign this object to it
        if (Instance == null)
        {
            Instance = this;
        }
        //否则,如果实例变量确实存在,但不是该对象,则销毁该对象。
        //Otherwise, if the instance variable does exist, but it isn't this object, destroy this object.
        //这很有用,这样我们一次在一个场景中不能有多个GameManager对象。
        //This is useful so that we cannot have more than one GameManager object in a scene at a time.
        else if (Instance != this)
        {
            Destroy(this);
        }
    }
Example #12
0
 /// <summary>
 /// Handler for pointer enter event.
 /// </summary>
 /// <param name="eventData">Pointer data.</param>
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (mMouseState == MouseState.NoState)
     {
         mMouseLocation = MouseLocation.Inside;
     }
 }
        /// <summary>
        /// Handler for pointer exit event.
        /// </summary>
        /// <param name="eventData">Pointer data.</param>
        public void OnPointerExit(PointerEventData eventData)
        {
            DebugEx.VerboseFormat("WindowScript.OnPointerExit(eventData = {0})", eventData);

            if (mMouseState == MouseState.NoState)
            {
#if !CURSORLESS_PLATFORM
                RemoveCursorIfNeeded();
#endif

                mMouseLocation = MouseLocation.Outside;
            }
        }
        /// <summary>
        /// Update is called once per frame.
        /// </summary>
        protected virtual void Update()
        {
            DebugEx.VeryVeryVerbose("WindowScript.Update()");

            bool leftMouseButtonPressed = InputControl.GetMouseButtonDown(MouseButton.Left);

            if (IsFramePresent())
            {
                switch (mMouseState)
                {
                    case MouseState.NoState:
                    {
                        if (mMouseLocation != MouseLocation.Outside)
                        {
                            bool isInsideButtons = false;

                            float mouseX = Mouse.scaledX;
                            float mouseY = Mouse.scaledY;

                            if (mMinimizeGameObject != null)
                            {
                                RectTransform buttonTransform = mMinimizeGameObject.transform as RectTransform;
                                Vector3[] corners = Utils.GetWindowCorners(buttonTransform);

                                if (
                                    mouseX >= corners[0].x
                                    &&
                                    mouseX <= corners[3].x
                                    &&
                                    mouseY >= corners[0].y
                                    &&
                                    mouseY <= corners[3].y
                                   )
                                {
                                    isInsideButtons = true;

                                    mMinimizeGameObject.transform.SetAsLastSibling();
                                }
                            }

                            if (mMaximizeGameObject != null)
                            {
                                RectTransform buttonTransform = mMaximizeGameObject.transform as RectTransform;
                                Vector3[] corners = Utils.GetWindowCorners(buttonTransform);

                                if (
                                    mouseX >= corners[0].x
                                    &&
                                    mouseX <= corners[3].x
                                    &&
                                    mouseY >= corners[0].y
                                    &&
                                    mouseY <= corners[3].y
                                   )
                                {
                                    isInsideButtons = true;

                                    mMaximizeGameObject.transform.SetAsLastSibling();
                                }
                            }

                            if (mCloseGameObject != null)
                            {
                                RectTransform buttonTransform = mCloseGameObject.transform as RectTransform;
                                Vector3[] corners = Utils.GetWindowCorners(buttonTransform);

                                if (
                                    mouseX >= corners[0].x
                                    &&
                                    mouseX <= corners[3].x
                                    &&
                                    mouseY >= corners[0].y
                                    &&
                                    mouseY <= corners[3].y
                                   )
                                {
                                    isInsideButtons = true;

                                    mCloseGameObject.transform.SetAsLastSibling();
                                }
                            }

                            switch (mState)
                            {
                                case WindowState.NoState:
                                {
#if !CURSORLESS_PLATFORM
                                    MouseLocation oldLocation = mMouseLocation;
#endif

                                    if (isInsideButtons)
                                    {
                                        mMouseLocation = MouseLocation.Inside;
                                    }
                                    else
                                    {
                                        if (mResizable)
                                        {
                                            if (mouseY <= mY + SHADOW_WIDTH + RESIZING_GAP)
                                            {
                                                if (mouseX <= mX + mBorderLeft)
                                                {
                                                    mMouseLocation = MouseLocation.NorthWest;
                                                }
                                                else
                                                if (mouseX < mX + mWidth - mBorderRight)
                                                {
                                                    mMouseLocation = MouseLocation.North;
                                                }
                                                else
                                                {
                                                    mMouseLocation = MouseLocation.NorthEast;
                                                }
                                            }
                                            else
                                            if (mouseY <= mY + mBorderTop)
                                            {
                                                if (mouseX <= mX + mBorderLeft)
                                                {
                                                    mMouseLocation = MouseLocation.West;
                                                }
                                                else
                                                if (mouseX < mX + mWidth - mBorderRight)
                                                {
                                                    mMouseLocation = MouseLocation.Header;
                                                }
                                                else
                                                {
                                                    mMouseLocation = MouseLocation.East;
                                                }
                                            }
                                            else
                                            if (mouseY < mY + mHeight - mBorderBottom)
                                            {
                                                if (mouseX <= mX + mBorderLeft)
                                                {
                                                    mMouseLocation = MouseLocation.West;
                                                }
                                                else
                                                if (mouseX < mX + mWidth - mBorderRight)
                                                {
                                                    mMouseLocation = MouseLocation.Inside;
                                                }
                                                else
                                                {
                                                    mMouseLocation = MouseLocation.East;
                                                }
                                            }
                                            else
                                            {
                                                if (mouseX <= mX + mBorderLeft)
                                                {
                                                    mMouseLocation = MouseLocation.SouthWest;
                                                }
                                                else
                                                if (mouseX < mX + mWidth - mBorderRight)
                                                {
                                                    mMouseLocation = MouseLocation.South;
                                                }
                                                else
                                                {
                                                    mMouseLocation = MouseLocation.SouthEast;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (mouseY <= mY + mBorderTop)
                                            {
                                                mMouseLocation = MouseLocation.Header;
                                            }
                                            else
                                            {
                                                mMouseLocation = MouseLocation.Inside;
                                            }
                                        }
                                    }

#if !CURSORLESS_PLATFORM
                                    if (mResizable && oldLocation != mMouseLocation)
                                    {
                                        switch (mMouseLocation)
                                        {
                                            case MouseLocation.North:
                                            case MouseLocation.South:
                                            {
                                                Cursor.SetCursor(Assets.Common.Cursors.northSouth.texture, new Vector2(16f * Utils.canvasScale, 16f * Utils.canvasScale), CursorMode.Auto);
                                            }
                                            break;

                                            case MouseLocation.West:
                                            case MouseLocation.East:
                                            {
                                                Cursor.SetCursor(Assets.Common.Cursors.eastWest.texture, new Vector2(16f * Utils.canvasScale, 16f * Utils.canvasScale), CursorMode.Auto);
                                            }
                                            break;

                                            case MouseLocation.NorthWest:
                                            case MouseLocation.SouthEast:
                                            {
                                                Cursor.SetCursor(Assets.Common.Cursors.northWestSouthEast.texture, new Vector2(16f * Utils.canvasScale, 16f * Utils.canvasScale), CursorMode.Auto);
                                            }
                                            break;

                                            case MouseLocation.NorthEast:
                                            case MouseLocation.SouthWest:
                                            {
                                                Cursor.SetCursor(Assets.Common.Cursors.northEastSouthWest.texture, new Vector2(16f * Utils.canvasScale, 16f * Utils.canvasScale), CursorMode.Auto);
                                            }
                                            break;

                                            case MouseLocation.Header:
                                            case MouseLocation.Inside:
                                            {
                                                RemoveCursor();
                                            }
                                            break;

                                            case MouseLocation.Outside:
                                            {
                                                DebugEx.ErrorFormat("Incorrect mouse location: {0}", mMouseLocation);
                                            }
                                            break;

                                            default:
                                            {
                                                DebugEx.ErrorFormat("Unknown mouse location: {0}", mMouseLocation);
                                            }
                                            break;
                                        }
                                    }
#endif
                                }
                                break;

                                case WindowState.Minimized:
                                {
                                    if (isInsideButtons)
                                    {
                                        mMouseLocation = MouseLocation.Inside;
                                    }
                                    else
                                    {
                                        mMouseLocation = MouseLocation.Header;
                                    }
                                }
                                break;

                                case WindowState.Maximized:
                                {
                                    if (isInsideButtons)
                                    {
                                        mMouseLocation = MouseLocation.Inside;
                                    }
                                    else
                                    {
                                        if (mouseY <= mBorderTop - SHADOW_WIDTH - MAXIMIZED_OFFSET)
                                        {
                                            mMouseLocation = MouseLocation.Header;
                                        }
                                        else
                                        {
                                            mMouseLocation = MouseLocation.Inside;
                                        }
                                    }
                                }
                                break;

                                case WindowState.FullScreen:
                                {
                                    DebugEx.ErrorFormat("Incorrect window state: {0}", mState);
                                }
                                break;

                                default:
                                {
                                    DebugEx.ErrorFormat("Unknown window state: {0}", mState);
                                }
                                break;
                            }

                            switch (mMouseLocation)
                            {
                                case MouseLocation.Header:
                                {
                                    if (leftMouseButtonPressed)
                                    {
                                        StartDragging();
                                    }
                                }
                                break;

                                case MouseLocation.North:
                                case MouseLocation.South:
                                case MouseLocation.West:
                                case MouseLocation.East:
                                case MouseLocation.NorthWest:
                                case MouseLocation.SouthEast:
                                case MouseLocation.NorthEast:
                                case MouseLocation.SouthWest:
                                {
                                    if (mResizable && mState == WindowState.NoState)
                                    {
                                        if (leftMouseButtonPressed)
                                        {
                                            mMouseState = MouseState.Resizing;

                                            mMouseContext = new MouseContext(mouseX, mouseY, x, y, width, height, mWindowTransform.offsetMin.x, -mWindowTransform.offsetMax.y);
                                        }
                                    }
                                }
                                break;

                                case MouseLocation.Inside:
                                {
                                    // Nothing
                                }
                                break;

                                case MouseLocation.Outside:
                                {
                                    DebugEx.ErrorFormat("Incorrect mouse location: {0}", mMouseLocation);
                                }
                                break;

                                default:
                                {
                                    DebugEx.ErrorFormat("Unknown mouse location: {0}", mMouseLocation);
                                }
                                break;
                            }
                        }
                    }
                    break;

                    case MouseState.Dragging:
                    {
                        float mouseX = Mouse.scaledX;
                        float mouseY = Mouse.scaledY;

                        #region Calculate new position
                        float screenWidth  = Utils.scaledScreenWidth;
                        float screenHeight = Utils.scaledScreenHeight;

                        if (mState == WindowState.Maximized)
                        {
                            if (
                                mouseX == mMouseContext.previousMouseX
                                &&
                                mouseY == mMouseContext.previousMouseY
                               )
                            {
                                if (InputControl.GetMouseButtonUp(MouseButton.Left))
                                {
                                    mMouseState   = MouseState.NoState;
                                    mMouseContext = null;
                                }

                                return;
                            }

                            state = WindowState.NoState;
                            mMouseContext.previousX = mMouseContext.previousMouseX - (mMouseContext.previousMouseX / screenWidth) * width;
                            mMouseContext.previousY = 0;
                        }

                        float newX = 0f;
                        float newY = 0f;

                        switch (mState)
                        {
                            case WindowState.NoState:
                            {
                                newX = mMouseContext.previousX + mouseX - mMouseContext.previousMouseX;
                                newY = mMouseContext.previousY + mouseY - mMouseContext.previousMouseY;
                            }
                            break;

                            case WindowState.Minimized:
                            {
                                newX = mMouseContext.previousRectX + mouseX - mMouseContext.previousMouseX + SHADOW_WIDTH;
                                newY = mMouseContext.previousRectY + mouseY - mMouseContext.previousMouseY + SHADOW_WIDTH;
                            }
                            break;

                            case WindowState.Maximized:
                            case WindowState.FullScreen:
                            {
                                DebugEx.ErrorFormat("Incorrect window state: {0}", mState);
                            }
                            break;

                            default:
                            {
                                DebugEx.ErrorFormat("Unknown window state: {0}", mState);
                            }
                            break;
                        }

                        float windowWidth = mWindowTransform.sizeDelta.x - 2 * SHADOW_WIDTH;

                        if (newX + windowWidth < DRAGGING_GAP)
                        {
                            newX = -windowWidth + DRAGGING_GAP;
                        }
                        else
                        if (newX > screenWidth - DRAGGING_GAP)
                        {
                            newX = screenWidth - DRAGGING_GAP;
                        }

                        if (newY < -mBorderTop + DRAGGING_GAP + SHADOW_WIDTH)
                        {
                            newY = -mBorderTop + DRAGGING_GAP + SHADOW_WIDTH;
                        }
                        else
                        if (newY > screenHeight - DRAGGING_GAP)
                        {
                            newY = screenHeight - DRAGGING_GAP;
                        }

                        switch (mState)
                        {
                            case WindowState.NoState:
                            {
                                x = newX;
                                y = newY;
                            }
                            break;

                            case WindowState.Minimized:
                            {
                                newX -= SHADOW_WIDTH;
                                newY -= SHADOW_WIDTH;
                                windowWidth += 2 * SHADOW_WIDTH;
                                float windowHeight = mWindowTransform.sizeDelta.y;

                                mWindowTransform.offsetMin = new Vector2(
                                                                           newX
                                                                         , -newY - windowHeight
                                                                        );

                                mWindowTransform.offsetMax = new Vector2(
                                                                           newX + windowWidth
                                                                         , -newY
                                                                        );
                            }
                            break;

                            case WindowState.Maximized:
                            case WindowState.FullScreen:
                            {
                                DebugEx.ErrorFormat("Incorrect window state: {0}", mState);
                            }
                            break;

                            default:
                            {
                                DebugEx.ErrorFormat("Unknown window state: {0}", mState);
                            }
                            break;
                        }
                        #endregion

                        #region Show/Hide replacement
                        bool replacementVisible = false;

                        if (mouseX < DRAGGING_GAP)
                        {
                            if (mResizable)
                            {
                                replacementVisible = true;

                                if (
                                    mReplacementGameObject == null
                                    ||
                                    mReplacementTransform.anchorMin != new Vector2(0f, 0f)
                                    ||
                                    mReplacementTransform.anchorMax != new Vector2(0f, 1f)
                                   )
                                {
                                    CreateReplacementStretchLeft();
                                }
                            }
                        }
                        else
                        if (mouseX > screenWidth - DRAGGING_GAP)
                        {
                            if (mResizable)
                            {
                                replacementVisible = true;

                                if (
                                    mReplacementGameObject == null
                                    ||
                                    mReplacementTransform.anchorMin != new Vector2(1f, 0f)
                                    ||
                                    mReplacementTransform.anchorMax != new Vector2(1f, 1f)
                                    )
                                {
                                    CreateReplacementStretchRight();
                                }
                            }
                        }
                        else
                        if (mouseY < DRAGGING_GAP)
                        {
                            if (mAllowMaximize)
                            {
                                replacementVisible = true;

                                if (
                                    mReplacementGameObject == null
                                    ||
                                    mReplacementTransform.anchorMin != new Vector2(0f, 0f)
                                    ||
                                    mReplacementTransform.anchorMax != new Vector2(1f, 1f)
                                    )
                                {
                                    CreateReplacementStretchStretch();
                                }
                            }
                        }

                        if (!replacementVisible)
                        {
                            DestroyReplacement();
                        }
                        #endregion

                        if (InputControl.GetMouseButtonUp(MouseButton.Left))
                        {
                            if (mReplacementGameObject != null)
                            {
                                if (mouseX < DRAGGING_GAP)
                                {
                                    width  = screenWidth / 2;
                                    height = screenHeight;
                                    x      = 0;
                                    y      = 0;
                                }
                                else
                                if (mouseX > screenWidth - DRAGGING_GAP)
                                {
                                    width  = screenWidth / 2;
                                    height = screenHeight;
                                    x      = screenWidth - width;
                                    y      = 0;
                                }
                                else
                                if (mouseY < DRAGGING_GAP)
                                {
                                    state = WindowState.Maximized;
                                }
                            }

                            DestroyReplacement();

                            mMouseState   = MouseState.NoState;
                            mMouseContext = null;

                            Vector3[] corners = Utils.GetWindowCorners(mWindowTransform);

                            if (
                                mouseX < corners[0].x + SHADOW_WIDTH || mouseX > corners[3].x - SHADOW_WIDTH
                                ||
                                mouseY < corners[0].y + SHADOW_WIDTH || mouseY > corners[3].y - SHADOW_WIDTH
                               )
                            {
                                mMouseLocation = MouseLocation.Outside;
                            }
                        }
                    }
                    break;

                    case MouseState.Resizing:
                    {
                        float mouseX = Mouse.scaledX;
                        float mouseY = Mouse.scaledY;

                        #region Calculate new geometry
                        float screenWidth  = Utils.scaledScreenWidth;
                        float screenHeight = Utils.scaledScreenHeight;

                        #region West
                        if (
                            mMouseLocation == MouseLocation.West
                            ||
                            mMouseLocation == MouseLocation.NorthWest
                            ||
                            mMouseLocation == MouseLocation.SouthWest
                           )
                        {
                            float newX     = mMouseContext.previousX     + mouseX - mMouseContext.previousMouseX;
                            float newWidth = mMouseContext.previousWidth - mouseX + mMouseContext.previousMouseX;

                            if (newWidth < MINIMAL_WIDTH)
                            {
                                newX     -= MINIMAL_WIDTH - newWidth;
                                newWidth  = MINIMAL_WIDTH;
                            }

                            if (mMinimumWidth != 0 && newWidth < mMinimumWidth)
                            {
                                newX     -= mMinimumWidth - newWidth;
                                newWidth  = mMinimumWidth;
                            }

                            if (mMaximumWidth != 0 && newWidth > mMaximumWidth)
                            {
                                newX     -= mMaximumWidth - newWidth;
                                newWidth  = mMaximumWidth;
                            }

                            if (newX > screenWidth - DRAGGING_GAP)
                            {
                                newWidth += newX - (screenWidth - DRAGGING_GAP);
                                newX      = screenWidth - DRAGGING_GAP;
                            }

                            x     = newX;
                            width = newWidth;
                        }
                        #endregion
                        else
                        #region East
                        if (
                            mMouseLocation == MouseLocation.East
                            ||
                            mMouseLocation == MouseLocation.NorthEast
                            ||
                            mMouseLocation == MouseLocation.SouthEast
                           )
                        {
                            float newWidth = mMouseContext.previousWidth + mouseX - mMouseContext.previousMouseX;

                            if (mMouseContext.previousX + newWidth < DRAGGING_GAP)
                            {
                                newWidth = -mMouseContext.previousX + DRAGGING_GAP;
                            }

                            width = newWidth;
                        }
                        #endregion

                        #region North
                        if (
                            mMouseLocation == MouseLocation.North
                            ||
                            mMouseLocation == MouseLocation.NorthWest
                            ||
                            mMouseLocation == MouseLocation.NorthEast
                           )
                        {
                            float newY      = mMouseContext.previousY      + mouseY - mMouseContext.previousMouseY;
                            float newHeight = mMouseContext.previousHeight - mouseY + mMouseContext.previousMouseY;

                            if (newHeight < MINIMAL_HEIGHT)
                            {
                                newY      -= MINIMAL_HEIGHT - newHeight;
                                newHeight  = MINIMAL_HEIGHT;
                            }

                            if (mMinimumHeight != 0 && newHeight < mMinimumHeight)
                            {
                                newY      -= mMinimumHeight - newHeight;
                                newHeight  = mMinimumHeight;
                            }

                            if (mMaximumHeight != 0 && newHeight > mMaximumHeight)
                            {
                                newY      -= mMaximumHeight - newHeight;
                                newHeight  = mMaximumHeight;
                            }

                            if (newY < -mBorderTop + DRAGGING_GAP + SHADOW_WIDTH)
                            {
                                newHeight -= -mBorderTop + DRAGGING_GAP + SHADOW_WIDTH - newY;
                                newY       = -mBorderTop + DRAGGING_GAP + SHADOW_WIDTH;
                            }
                            else
                            if (newY > screenHeight - DRAGGING_GAP)
                            {
                                newHeight += newY - (screenHeight - DRAGGING_GAP);
                                newY       = screenHeight - DRAGGING_GAP;
                            }

                            y      = newY;
                            height = newHeight;
                        }
                        #endregion
                        else
                        #region South
                        if (
                            mMouseLocation == MouseLocation.South
                            ||
                            mMouseLocation == MouseLocation.SouthWest
                            ||
                            mMouseLocation == MouseLocation.SouthEast
                           )
                        {
                            height = mMouseContext.previousHeight + mouseY - mMouseContext.previousMouseY;
                        }
                        #endregion
                        #endregion

                        #region Show/Hide replacement
                        bool replacementVisible = false;

                        if (mouseY < DRAGGING_GAP)
                        {
                            if (
                                mMouseLocation == MouseLocation.North
                                ||
                                mMouseLocation == MouseLocation.NorthWest
                                ||
                                mMouseLocation == MouseLocation.NorthEast
                               )
                            {
                                replacementVisible = true;

                                if (mReplacementGameObject == null)
                                {
                                    CreateReplacementStretchVertical();
                                }
                                else
                                if (
                                    mMouseLocation == MouseLocation.NorthWest
                                    ||
                                    mMouseLocation == MouseLocation.NorthEast
                                   )
                                {
                                    mReplacementTransform.offsetMin = new Vector2(mWindowTransform.offsetMin.x, mReplacementTransform.offsetMin.y);
                                    mReplacementTransform.offsetMax = new Vector2(mWindowTransform.offsetMax.x, mReplacementTransform.offsetMax.y);
                                }
                            }
                        }
                        else
                        if (mouseY > screenHeight - DRAGGING_GAP)
                        {
                            if (
                                mMouseLocation == MouseLocation.South
                                ||
                                mMouseLocation == MouseLocation.SouthWest
                                ||
                                mMouseLocation == MouseLocation.SouthEast
                               )
                            {
                                replacementVisible = true;

                                if (mReplacementGameObject == null)
                                {
                                    CreateReplacementStretchVertical();
                                }
                                else
                                if (
                                    mMouseLocation == MouseLocation.SouthWest
                                    ||
                                    mMouseLocation == MouseLocation.SouthEast
                                   )
                                {
                                    mReplacementTransform.offsetMin = new Vector2(mWindowTransform.offsetMin.x, mReplacementTransform.offsetMin.y);
                                    mReplacementTransform.offsetMax = new Vector2(mWindowTransform.offsetMax.x, mReplacementTransform.offsetMax.y);
                                }
                            }
                        }

                        if (!replacementVisible)
                        {
                            DestroyReplacement();
                        }
                        #endregion

                        if (InputControl.GetMouseButtonUp(MouseButton.Left))
                        {
                            if (mReplacementGameObject != null)
                            {
                                y      = 0;
                                height = screenHeight;
                            }

                            DestroyReplacement();

                            mMouseState   = MouseState.NoState;
                            mMouseContext = null;

                            if (mouseX < mX + SHADOW_WIDTH || mouseX > mX + mWidth  - SHADOW_WIDTH
                                ||
                                mouseY < mY + SHADOW_WIDTH || mouseY > mY + mHeight - SHADOW_WIDTH)
                            {
#if !CURSORLESS_PLATFORM
                                RemoveCursor();
#endif

                                mMouseLocation = MouseLocation.Outside;
                            }
                        }
                    }
                    break;

                    default:
                    {
                        DebugEx.ErrorFormat("Unknown mouse state: {0}", mMouseState);
                    }
                    break;
                }
            }

            if (leftMouseButtonPressed)
            {
                List<RaycastResult> hits = new List<RaycastResult>();
                Mouse.RaycastAll(hits);

                bool isOk       = true;
                bool isSelected = false;

                if (hits.Count > 0)
                {
                    Transform curTransform = hits[0].gameObject.transform;

                    while (curTransform != null)
                    {
                        if (curTransform == transform)
                        {
                            isSelected = true;

                            break;
                        }

                        if (curTransform.GetComponent<WindowScript>() != null)
                        {
                            break;
                        }

                        if (curTransform.GetComponent<PopupMenuAreaScript>() != null)
                        {
                            isOk = false;

                            break;
                        }

                        curTransform = curTransform.parent;
                    }
                }

                if (isOk)
                {
                    SetSelected(isSelected);
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Common.UI.Windows.WindowScript"/> class.
        /// </summary>
        public WindowScript()
            : base()
        {
            DebugEx.Verbose("Created WindowScript object");

            sInstances.Add(this);

            mFrame           = WindowFrameType.Window;
            mState           = WindowState.NoState;
            mX               = -SHADOW_WIDTH;
            mY               = -SHADOW_WIDTH;
            mWidth           = 0f;
            mHeight          = 0f;
            mBackgroundColor = Assets.Common.Windows.Colors.background;
            mResizable       = true;
            mMinimumWidth    = 0f;
            mMinimumHeight   = 0f;
            mMaximumWidth    = 0f;
            mMaximumHeight   = 0f;
            mAllowMinimize   = true;
            mAllowMaximize   = true;
            mAllowClose      = true;
            mTokenId         = R.sections.WindowTitles.strings.Count;

            mWindowTransform        = null;
            mBorderGameObject       = null;
            mBorderImage            = null;
            mTitleGameObject        = null;
            mTitleText              = null;
            mMinimizeGameObject     = null;
            mMinimizeImage          = null;
            mMaximizeGameObject     = null;
            mMaximizeImage          = null;
            mCloseGameObject        = null;
            mCloseImage             = null;
            mContentTransform       = null;
            mContentBackgroundImage = null;
            mReplacementGameObject  = null;
            mReplacementTransform   = null;
            mBorderLeft             = 0f;
            mBorderTop              = 0f;
            mBorderRight            = 0f;
            mBorderBottom           = 0f;
            mMouseLocation          = MouseLocation.Outside;
            mMouseState             = MouseState.NoState;
            mMouseContext           = null;

            Hide();
        }
        /// <summary>
        /// Handler for pointer enter event.
        /// </summary>
        /// <param name="eventData">Pointer data.</param>
        public void OnPointerEnter(PointerEventData eventData)
        {
            DebugEx.VerboseFormat("WindowScript.OnPointerEnter(eventData = {0})", eventData);

            if (mMouseState == MouseState.NoState)
            {
                mMouseLocation = MouseLocation.Inside;
            }
        }
        /// <summary>
        /// LateUpdate is called once per frame after all Updates.
        /// </summary>
        void LateUpdate()
        {
            DebugEx.VeryVeryVerbose("DockingAreaScript.LateUpdate()");

#if !CURSORLESS_PLATFORM
            if (sPreviousMouseLocation != sMouseLocation)
            {
                MouseLocation oldLocation = sPreviousMouseLocation;
                sPreviousMouseLocation    = sMouseLocation;

                if (
                    (oldLocation != MouseLocation.North   || sMouseLocation != MouseLocation.South)
                    &&
                    (oldLocation != MouseLocation.South   || sMouseLocation != MouseLocation.North)
                    &&
                    (oldLocation != MouseLocation.East    || sMouseLocation != MouseLocation.West)
                    &&
                    (oldLocation != MouseLocation.West    || sMouseLocation != MouseLocation.East)
                    &&
                    (oldLocation != MouseLocation.Inside  || sMouseLocation != MouseLocation.Outside)
                    &&
                    (oldLocation != MouseLocation.Outside || sMouseLocation != MouseLocation.Inside)
                   )
                {
                    switch (sMouseLocation)
                    {
                        case MouseLocation.North:
                        case MouseLocation.South:
                        {
                            Cursor.SetCursor(Assets.Common.Cursors.northSouth.texture, new Vector2(16f * Utils.canvasScale, 16f * Utils.canvasScale), CursorMode.Auto);
                        }
                        break;

                        case MouseLocation.West:
                        case MouseLocation.East:
                        {
                            Cursor.SetCursor(Assets.Common.Cursors.eastWest.texture, new Vector2(16f * Utils.canvasScale, 16f * Utils.canvasScale), CursorMode.Auto);
                        }
                        break;

                        case MouseLocation.Inside:
                        case MouseLocation.Outside:
                        {
                            RemoveCursor();
                        }
                        break;

                        default:
                        {
                            DebugEx.ErrorFormat("Unknown mouse location: {0}", sMouseLocation);
                        }
                        break;
                    }
                }
            }
#endif

            if (sResizingArea == this)
            {
                if (InputControl.GetMouseButtonDown(MouseButton.Left))
                {
                    sMouseState = MouseState.Resizing;
                }
            }
        }
        /// <summary>
        /// Handler for destroy event.
        /// </summary>
        void OnDestroy()
        {
            DebugEx.Verbose("DockingAreaScript.OnDestroy()");

            if (sResizingArea == this)
            {
#if !CURSORLESS_PLATFORM
                RemoveCursorIfNeeded();

                sPreviousMouseLocation = MouseLocation.Outside;
#endif

                sResizingArea  = null;
                sMouseLocation = MouseLocation.Outside;
                sMouseState    = MouseState.NoState;
            }

            if (!sInstances.Remove(this))
            {
                DebugEx.Error("Failed to remove docking area");
            }
        }
        /// <summary>
        /// Update is called once per frame.
        /// </summary>
        void Update()
        {
            DebugEx.VeryVeryVerbose("DockingAreaScript.Update()");

            if (
                mParent != null
                &&
                mCachedDragCorners == null
               )
            {
                switch (sMouseState)
                {
                    case MouseState.NoState:
                    {
                        if (sLastUpdate != Time.frameCount)
                        {
                            sLastUpdate = Time.frameCount;

                            sResizingArea  = null;
                            sMouseLocation = MouseLocation.Outside;
                        }

                        if (sResizingArea == null)
                        {
                            Vector3[] corners = Utils.GetWindowCorners(transform as RectTransform);

                            float left   = corners[0].x - GAP;
                            float top    = corners[0].y - GAP;
                            float right  = corners[3].x + GAP;
                            float bottom = corners[3].y + GAP;

                            float mouseX = Mouse.scaledX;
                            float mouseY = Mouse.scaledY;

                            if (
                                mouseX >= left && mouseX <= right
                                &&
                                mouseY >= top  && mouseY <= bottom
                               )
                            {
                                List<RaycastResult> hits = new List<RaycastResult>();
                                Mouse.RaycastAll(hits);

                                bool isInSameHierarchy = false;

                                if (hits.Count > 0)
                                {
                                    Transform baseTransform = hits[0].gameObject.transform;
                                    Transform curTransform  = transform;

                                    while (curTransform != null)
                                    {
                                        if (curTransform == baseTransform)
                                        {
                                            isInSameHierarchy = true;
                                            break;
                                        }

                                        curTransform = curTransform.parent;
                                    }
                                }

                                if (isInSameHierarchy)
                                {
                                    if (mouseY <= top + GAP)
                                    {
                                        if (
                                            mParent.mOrientation == DockingAreaOrientation.Vertical
                                            &&
                                            mParent.mChildren.Count > 1
                                            &&
                                            mParent.mChildren[0] != this
                                           )
                                        {
                                            sResizingArea  = this;
                                            sMouseLocation = MouseLocation.North;
                                        }
                                    }
                                    else
                                    if (mouseY >= bottom - GAP)
                                    {
                                        if (
                                            mParent.mOrientation == DockingAreaOrientation.Vertical
                                            &&
                                            mParent.mChildren.Count > 1
                                            &&
                                            mParent.mChildren[mParent.mChildren.Count - 1] != this
                                           )
                                        {
                                            sResizingArea  = this;
                                            sMouseLocation = MouseLocation.South;
                                        }
                                    }
                                    else
                                    {
                                        if (mouseX <= left + GAP)
                                        {
                                            if (
                                                mParent.mOrientation == DockingAreaOrientation.Horizontal
                                                &&
                                                mParent.mChildren.Count > 1
                                                &&
                                                mParent.mChildren[0] != this
                                               )
                                            {
                                                sResizingArea  = this;
                                                sMouseLocation = MouseLocation.West;
                                            }
                                        }
                                        else
                                        if (mouseX >= right - GAP)
                                        {
                                            if (
                                                mParent.mOrientation == DockingAreaOrientation.Horizontal
                                                &&
                                                mParent.mChildren.Count > 1
                                                &&
                                                mParent.mChildren[mParent.mChildren.Count - 1] != this
                                               )
                                            {
                                                sResizingArea  = this;
                                                sMouseLocation = MouseLocation.East;
                                            }
                                        }
                                        else
                                        {
                                            sMouseLocation = MouseLocation.Inside;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;

                    case MouseState.Resizing:
                    {
                        if (sResizingArea == this)
                        {
                            if (
                                mParent != null
                                &&
                                mParent.mChildren.Count > 1
                               )
                            {
                                int index = mParent.mChildren.IndexOf(this);

                                if (index >= 0)
                                {
                                    MouseLocation usedLocation = sMouseLocation;

                                    float mouseX = Mouse.scaledX;
                                    float mouseY = Mouse.scaledY;

                                    float oldWidth  = 0f;
                                    float oldHeight = 0f;
                                    float newWidth  = 0f;
                                    float newHeight = 0f;

                                    float oldSize = 0f;
                                    float newSize = 0f;

                                    for (int attempt = 1; attempt <= 2; ++attempt)
                                    {
                                        Vector3[] corners = Utils.GetWindowCorners(mParent.mChildren[index].transform as RectTransform);

                                        float left   = corners[0].x;
                                        float top    = corners[0].y;
                                        float right  = corners[3].x;
                                        float bottom = corners[3].y;

                                        oldWidth  = right  - left;
                                        oldHeight = bottom - top;
                                        newWidth  = oldWidth;
                                        newHeight = oldHeight;

                                        oldSize = mParent.mSizes[index];
                                        newSize = oldSize;

                                        switch (usedLocation)
                                        {
                                            case MouseLocation.North:
                                            {
                                                newHeight = bottom - mouseY;

                                                newSize = newHeight / oldHeight * oldSize;
                                            }
                                            break;

                                            case MouseLocation.South:
                                            {
                                                newHeight = mouseY - top;

                                                newSize = newHeight / oldHeight * oldSize;
                                            }
                                            break;

                                            case MouseLocation.West:
                                            {
                                                newWidth = right - mouseX;

                                                newSize = newWidth / oldWidth * oldSize;
                                            }
                                            break;

                                            case MouseLocation.East:
                                            {
                                                newWidth = mouseX - left;

                                                newSize = newWidth / oldWidth * oldSize;
                                            }
                                            break;

                                            case MouseLocation.Inside:
                                            case MouseLocation.Outside:
                                            {
                                                DebugEx.ErrorFormat("Incorrect mouse location: {0}", usedLocation);
                                            }
                                            break;

                                            default:
                                            {
                                                DebugEx.ErrorFormat("Unknown mouse location: {0}", usedLocation);
                                            }
                                            break;
                                        }

                                        if (
                                            newWidth  >= oldWidth  - 0.1f
                                            &&
                                            newHeight >= oldHeight - 0.1f
                                           )
                                        {
                                            break;
                                        }

                                        if (attempt == 2)
                                        {
                                            DebugEx.Fatal("Unexpected behaviour in DockingAreaScript.Update()");
                                            return;
                                        }

                                        switch (usedLocation)
                                        {
                                            case MouseLocation.North:
                                            {
                                                usedLocation = MouseLocation.South;

                                                if (index > 0)
                                                {
                                                    --index;
                                                }
                                                else
                                                {
                                                    DebugEx.Fatal("Unexpected behaviour in DockingAreaScript.Update()");
                                                    return;
                                                }
                                            }
                                            break;

                                            case MouseLocation.South:
                                            {
                                                usedLocation = MouseLocation.North;

                                                if (index < mParent.mChildren.Count - 1)
                                                {
                                                    ++index;
                                                }
                                                else
                                                {
                                                    DebugEx.Fatal("Unexpected behaviour in DockingAreaScript.Update()");
                                                    return;
                                                }
                                            }
                                            break;

                                            case MouseLocation.West:
                                            {
                                                usedLocation = MouseLocation.East;

                                                if (index > 0)
                                                {
                                                    --index;
                                                }
                                                else
                                                {
                                                    DebugEx.Fatal("Unexpected behaviour in DockingAreaScript.Update()");
                                                    return;
                                                }
                                            }
                                            break;

                                            case MouseLocation.East:
                                            {
                                                usedLocation = MouseLocation.West;

                                                if (index < mParent.mChildren.Count - 1)
                                                {
                                                    ++index;
                                                }
                                                else
                                                {
                                                    DebugEx.Fatal("Unexpected behaviour in DockingAreaScript.Update()");
                                                    return;
                                                }
                                            }
                                            break;

                                            case MouseLocation.Inside:
                                            case MouseLocation.Outside:
                                            {
                                                DebugEx.ErrorFormat("Incorrect mouse location: {0}", usedLocation);
                                            }
                                            break;

                                            default:
                                            {
                                                DebugEx.ErrorFormat("Unknown mouse location: {0}", usedLocation);
                                            }
                                            break;
                                        }
                                    }

                                    if (
                                        newWidth  > oldWidth  - 0.1f
                                        ||
                                        newHeight > oldHeight - 0.1f
                                       )
                                    {
                                        float delta = newSize - oldSize;

                                        switch (usedLocation)
                                        {
                                            case MouseLocation.North:
                                            case MouseLocation.West:
                                            {
                                                for (int i = index - 1; i >= 0; --i)
                                                {
                                                    float nextSize = mParent.mSizes[i] - delta;

                                                    if (nextSize < MINIMUM_SIZE)
                                                    {
                                                        nextSize = MINIMUM_SIZE;
                                                    }

                                                    float localDelta  = mParent.mSizes[i] - nextSize;
                                                    mParent.mSizes[i] = nextSize;

                                                    delta -= localDelta;

                                                    if (delta == 0f)
                                                    {
                                                        break;
                                                    }
                                                }

                                                newSize -= delta;
                                            }
                                            break;

                                            case MouseLocation.South:
                                            case MouseLocation.East:
                                            {
                                                for (int i = index + 1; i < mParent.mChildren.Count; ++i)
                                                {
                                                    float nextSize = mParent.mSizes[i] - delta;

                                                    if (nextSize < MINIMUM_SIZE)
                                                    {
                                                        nextSize = MINIMUM_SIZE;
                                                    }

                                                    float localDelta  = mParent.mSizes[i] - nextSize;
                                                    mParent.mSizes[i] = nextSize;

                                                    delta -= localDelta;

                                                    if (delta == 0f)
                                                    {
                                                        break;
                                                    }
                                                }

                                                newSize -= delta;
                                            }
                                            break;

                                            case MouseLocation.Inside:
                                            case MouseLocation.Outside:
                                            {
                                                DebugEx.ErrorFormat("Incorrect mouse location: {0}", usedLocation);
                                            }
                                            break;

                                            default:
                                            {
                                                DebugEx.ErrorFormat("Unknown mouse location: {0}", usedLocation);
                                            }
                                            break;
                                        }

                                        mParent.mSizes[index] = newSize;
                                        mParent.OnResize();
                                    }

                                    if (InputControl.GetMouseButtonUp(MouseButton.Left))
                                    {
                                        sMouseState = MouseState.NoState;
                                    }
                                }
                                else
                                {
                                    DebugEx.Fatal("Unexpected behaviour in DockingAreaScript.Update()");
                                }
                            }
                            else
                            {
                                DebugEx.Fatal("Unexpected behaviour in DockingAreaScript.Update()");
                            }
                        }
                    }
                    break;

                    default:
                    {
                        DebugEx.ErrorFormat("Unknown mouse state: {0}", sMouseState);
                    }
                    break;
                }
            }
        }
Example #20
0
        /// <summary>
        /// Handler for pointer exit event.
        /// </summary>
        /// <param name="eventData">Pointer data.</param>
        public void OnPointerExit(PointerEventData eventData)
        {
            if (mMouseState == MouseState.NoState)
            {
                if (
                    mResizable
                    &&
                    (
                     mMouseLocation == MouseLocation.North
                     ||
                     mMouseLocation == MouseLocation.South
                     ||
                     mMouseLocation == MouseLocation.West
                     ||
                     mMouseLocation == MouseLocation.East
                     ||
                     mMouseLocation == MouseLocation.NorthWest
                     ||
                     mMouseLocation == MouseLocation.NorthEast
                     ||
                     mMouseLocation == MouseLocation.SouthWest
                     ||
                     mMouseLocation == MouseLocation.SouthEast
                    )
                   )
                {
                    Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
                }

                mMouseLocation = MouseLocation.Outside;
            }
        }
Example #21
0
 public Schedule(Timer timer)
 {
     this.timer = timer;
     this.timer.Tick += timer_Tick;
     this.mouseLocation = new MouseLocation();
 }
Example #22
0
        private void map_MouseMove(object sender, MouseEventArgs e)
        {
            MouseLocation.fromImage(e.Location.X, e.Location.Y);

            statusText.Text = " Map[x:" + MouseLocation.map_x.ToString() + " y:" + MouseLocation.map_y.ToString() + "] - Real[x:" + MouseLocation.real_x.ToString() + " y:" + MouseLocation.real_y.ToString() + "] - Image[x:" + MouseLocation.image_x.ToString() + " y:" + MouseLocation.image_y.ToString() + "]";
        }
Example #23
0
        /// <summary>
        /// Called when the game determines it is time to draw a frame.
        /// </summary>
        public override void Draw()
        {
            Display.ClearBuffers();

            Batch.Begin();

            // Draw map
            for (int y = 0; y < MapSize.Height; y++)
            {
                for (int x = 0; x < MapSize.Width; x++)
                {
                    PathNode node  = PathFinder.GetNode(x, y);
                    Color    color = node.IsWalkable ? Color.White : Color.Black;

                    Batch.FillRectangle(new Rectangle(x * BlockSize.Width, y * BlockSize.Height, BlockSize.Width, BlockSize.Height), color);

                    if (!node.IsOpen)
                    {
                        Batch.FillRectangle(new Rectangle(x * BlockSize.Width, y * BlockSize.Height, BlockSize.Width, BlockSize.Height), Color.FromArgb(128, Color.LightBlue));
                    }
                }
            }


            // Draw path
            if (Path != null)
            {
                foreach (PathNode node in Path)
                {
                    Point location = new Point(node.Location.X * BlockSize.Width, node.Location.Y * BlockSize.Height);

                    // Draw rectangle
                    Batch.FillRectangle(new Rectangle(location.X, location.Y, BlockSize.Width, BlockSize.Height), Color.FromArgb(128, Color.Red));
                }
            }



            //	DebugPath();



            if (!Start.IsEmpty)
            {
                Batch.FillRectangle(new Rectangle(Start.X * BlockSize.Width, Start.Y * BlockSize.Height, BlockSize.Width, BlockSize.Height), Color.Red);
            }
            if (!Destination.IsEmpty)
            {
                Batch.FillRectangle(new Rectangle(Destination.X * BlockSize.Width, Destination.Y * BlockSize.Height, BlockSize.Width, BlockSize.Height), Color.Green);
            }

            // Draw mouse
            int mousex = Mouse.Location.X - (Mouse.Location.X % BlockSize.Width);
            int mousey = Mouse.Location.Y - (Mouse.Location.Y % BlockSize.Height);

            if (mousex < BlockSize.Width * MapSize.Width && mousey < BlockSize.Height * MapSize.Height)
            {
                Batch.DrawRectangle(new Rectangle(mousex, mousey, BlockSize.Width, BlockSize.Height), Color.FromArgb(128, Color.Red));
            }

            // some debug text
            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 10), Color.Black, "Mouse location : " + MouseLocation.ToString());
            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 25), Color.Red, "Start location : " + Start.ToString());
            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 40), Color.Green, "Destination location : " + Destination.ToString());

            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 100), Color.Black, "Press spacebar to reset Start and Destination.");
            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 115), Color.Black, "Press enter to find the path.");
            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 130), Color.Black, "Press R to make some random unwakable block.");
            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 145), Color.Black, "Press C to clear map.");

            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 200), Color.Black, "F = G + H.");
            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 215), Color.Black, "G = Movement cost to move from the starting point.");
            Batch.DrawString(Font, new Point(MapSize.Width * BlockSize.Width + 50, 230), Color.Black, "H = Estimated movement cost to move to the final destination.");

            Batch.End();
        }