예제 #1
0
 public Vector2 PixelPosToWorldPos(Vector2 posPixel)
 {
     if (Ref.mapView && Ref.currentScene == Ref.SceneType.Game)
     {
         Double3 a   = Double3.ToDouble3((posPixel - new Vector2((float)(Screen.width / 2), (float)(Screen.height / 2))) / (float)Screen.height);
         float   f   = Ref.cam.fieldOfView * 0.0174532924f;
         float   num = Mathf.Sin(f) / ((1f + Mathf.Cos(f)) * 0.5f);
         return(Ref.cam.transform.position + (Vector3)(a * -Ref.map.mapPosition.z * (double)num).RotateZ((double)(Ref.cam.transform.eulerAngles.z * 0.0174532924f)).toVector2);
     }
     return(Camera.main.ScreenToWorldPoint((Vector3)posPixel + Vector3.forward * -Ref.cam.transform.position.z));
 }
예제 #2
0
    private void LateUpdate()
    {
        if (Input.mouseScrollDelta.y != 0f)
        {
            this.ApplyZoom(1f - Input.mouseScrollDelta.y / 10f);
        }
        this.horizontalAxis = Input.GetAxisRaw("Horizontal");
        Vector2 posWorld = base.PixelPosToWorldPos(Input.mousePosition);

        if (Input.GetMouseButtonDown(0))
        {
            this.StartTouchEmpty(posWorld, 0);
            this.oldPos = Input.mousePosition;
        }
        if ((Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) && !this.ClickUI(Input.mousePosition))
        {
            this.EndTouchEmpty(posWorld, 0, true);
        }
        if (Input.GetKey("q"))
        {
            this.ApplyZoom(1.015f);
        }
        if (Input.GetMouseButton(0))
        {
            this.TouchStayEmpty(posWorld, this.oldPos - Input.mousePosition, 0);
            if (Ref.mapView && !Input.GetMouseButtonDown(0))
            {
                this.ApplyDraging(Double3.ToDouble3(this.oldPos - Input.mousePosition));
            }
            this.oldPos = Input.mousePosition;
        }
        float num = (float)((Screen.height <= Screen.width) ? 1334 : 750);

        if (this.canvasScaler.referenceResolution.x != num)
        {
            if (Ref.currentScene == Ref.SceneType.MainMenu)
            {
                return;
            }
            this.canvasScaler.referenceResolution = new Vector2(num, 1f);
            if (Ref.currentScene == Ref.SceneType.Game && this.recoverMenuHolder.activeSelf)
            {
                Ref.controller.StartRecovery();
            }
            if (Ref.saving != null && Ref.saving.loadingMenuHolder.activeSelf)
            {
                Ref.saving.TryStartLoadProcess();
            }
        }
    }
예제 #3
0
    private void LateUpdate()
    {
        if (Input.mouseScrollDelta.y != 0f)
        {
            this.ApplyZoom(1f - Input.mouseScrollDelta.y / 5f);
        }
        this.horizontalAxis = Input.GetAxisRaw("Horizontal");
        Vector2 posWorld = base.PixelPosToWorldPos(Input.mousePosition);

        if (Input.GetMouseButtonDown(0))
        {
            GameObject x = this.PointCastUI(Input.mousePosition, this.uIColliders);
            if (!(x != null))
            {
                this.StartTouchEmpty(posWorld, 0);
            }
            this.oldPos = Input.mousePosition;
        }
        if ((Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) && !this.ClickUI(Input.mousePosition))
        {
            this.EndTouchEmpty(posWorld, 0, true);
        }
        if (Input.GetKey("q"))
        {
            this.ApplyZoom(1.02f);
        }
        if (Input.GetKey("e"))
        {
            this.ApplyZoom(0.98f);
        }
        if (Input.GetMouseButton(0))
        {
            this.TouchStayEmpty(posWorld, this.oldPos - Input.mousePosition, 0);
            if (!Input.GetMouseButtonDown(0))
            {
                this.ApplyDraging(Double3.ToDouble3(this.oldPos - Input.mousePosition));
            }
            this.oldPos = Input.mousePosition;
        }
    }