Beispiel #1
0
        ScreenPart ExtractPart(Vector2 pos)
        {
            ScreenPart part = ScreenPart.None;

            if (pos.x > Screen.width / 2f)
            {
                part |= ScreenPart.Right;
            }
            else
            {
                part |= ScreenPart.Left;
            }
            if (pos.y > Screen.height / 2f)
            {
                part |= ScreenPart.Bottom;
            }
            else
            {
                part |= ScreenPart.Top;
            }
            return(part);
        }
 public ScreenPartCoordinates(ScreenPart screenPart, Point upperLeftCorner, Point lowerRightCorner)
 {
     ScreenPart       = screenPart;
     UpperLeftCorner  = upperLeftCorner;
     LowerRightCorner = lowerRightCorner;
 }
Beispiel #3
0
    void Update()
    {
        float horizontalEn = Input.GetAxisRaw("Horizontal");
        float horizontalFr = Input.GetAxisRaw("HorizontalFR");
        float verticalEn   = Input.GetAxisRaw("Vertical");
        float verticalFr   = Input.GetAxisRaw("VerticalFR");

        //Keys
        if (verticalEn == 1 || verticalFr == 1)
        {
            if (horizontalEn == -1 || horizontalFr == -1)
            {
                currentScreenPart = ScreenPart.UPLEFT;
            }
            else if (horizontalEn == 1 || horizontalFr == 1)
            {
                currentScreenPart = ScreenPart.UPRIGHT;
            }
            else
            {
                currentScreenPart = ScreenPart.UP;
            }
        }
        else if (verticalEn == -1 || verticalFr == -1)
        {
            if (horizontalEn == -1 || horizontalFr == -1)
            {
                currentScreenPart = ScreenPart.DOWNLEFT;
            }
            else if (horizontalEn == 1 || horizontalFr == 1)
            {
                currentScreenPart = ScreenPart.DOWNRIGHT;
            }
            else
            {
                currentScreenPart = ScreenPart.DOWN;
            }
        }
        else
        {
            if (horizontalEn == -1 || horizontalFr == -1)
            {
                currentScreenPart = ScreenPart.LEFT;
            }
            else if (horizontalEn == 1 || horizontalFr == 1)
            {
                currentScreenPart = ScreenPart.RIGHT;
            }
            else
            {
                //Mouse
                Vector3 mousePosition = Input.mousePosition;
                float   mouseXPercent = mousePosition.x / Screen.width;
                float   mouseYPercent = mousePosition.y / Screen.height;
                if (mouseYPercent > movementDectectionLimit)
                {
                    if (mouseXPercent < (1 - movementDectectionLimit))
                    {
                        currentScreenPart = ScreenPart.UPLEFT;
                    }
                    else if (mouseXPercent > movementDectectionLimit)
                    {
                        currentScreenPart = ScreenPart.UPRIGHT;
                    }
                    else
                    {
                        currentScreenPart = ScreenPart.UP;
                    }
                }
                else if (mouseYPercent < (1 - movementDectectionLimit))
                {
                    if (mouseXPercent < (1 - movementDectectionLimit))
                    {
                        currentScreenPart = ScreenPart.DOWNLEFT;
                    }
                    else if (mouseXPercent > movementDectectionLimit)
                    {
                        currentScreenPart = ScreenPart.DOWNRIGHT;
                    }
                    else
                    {
                        currentScreenPart = ScreenPart.DOWN;
                    }
                }
                else
                {
                    if (mouseXPercent < (1 - movementDectectionLimit))
                    {
                        currentScreenPart = ScreenPart.LEFT;
                    }
                    else if (mouseXPercent > movementDectectionLimit)
                    {
                        currentScreenPart = ScreenPart.RIGHT;
                    }
                    else
                    {
                        currentScreenPart = ScreenPart.NONE;
                    }
                }
            }
        }

        float scrollWheel = Input.GetAxis("Mouse ScrollWheel");
        float newPosY     = transform.position.y + scrollWheel * Time.deltaTime * zoomSpeed * -1;

        newPosY = Mathf.Min(Mathf.Max(newPosY, zoomBoundaries.x), zoomBoundaries.y);
        // More the zoom is far, more the speed is
        customSpeed = Mathf.Max(speed, newPosY);

        Move();

        transform.position = new Vector3(transform.position.x, newPosY, transform.position.z);
    }
Beispiel #4
0
 void Start()
 {
     currentScreenPart = ScreenPart.NONE;
     Init();
 }