Exemplo n.º 1
0
        void UpdateGeocellSelection()
        {
            bool shift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
            bool ctrl  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);

            if (Input.GetMouseButton(0))
            {
                if (shift)
                {
                    if (Physics.Raycast(Camera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
                    {
                        GeodeticForVector3(hit.collider.transform.TransformPoint(hit.point), out double latitude, out double longitude);
                        GeocellTexture.Set(latitude, longitude, GeocellColor);
                    }
                }
            }
            if (Input.GetMouseButtonDown(0))
            {
                if (Physics.Raycast(Camera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
                {
                    GeodeticForVector3(hit.collider.transform.TransformPoint(hit.point), out double latitude, out double longitude);
                    bool is_set = GeocellTexture.Color(latitude, longitude).a != 0;
                    if (!ctrl)
                    {
                        GeocellTexture.Clear();
                    }
                    if (is_set)
                    {
                        GeocellTexture.Set(latitude, longitude, Color.clear);
                    }
                    else
                    {
                        GeocellTexture.Set(latitude, longitude, GeocellColor);
                    }
                    Debug.LogFormat("{0}, {1}", latitude, longitude);
                }
            }
        }
Exemplo n.º 2
0
        void Update()
        {
            if (Input.touchCount == 1)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    BeginDragging();
                }
                if (Input.GetTouch(0).phase == TouchPhase.Moved)
                {
                    DoDragging();
                }
                if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    EndDragging();
                }
            }
            if (Input.touchCount == 2)
            {
                Touch touch1             = Input.touches[0];
                Touch touch2             = Input.touches[1];
                float pinchDistanceDelta =
                    Vector2.Distance(touch1.position, touch2.position)
                    - Vector2.Distance(touch1.position - touch1.deltaPosition, touch2.position - touch2.deltaPosition);
                Zoom(-pinchDistanceDelta * .4f);
            }
            if (Input.touchCount == 0)
            {
                if (Input.GetKeyDown(KeyCode.Mouse1))
                {
                    BeginDragging();
                }
                if (Input.GetKey(KeyCode.Mouse1))
                {
                    DoDragging();
                }
                if (Input.GetKeyUp(KeyCode.Mouse1))
                {
                    EndDragging();
                }

                Zoom(-Input.mouseScrollDelta.y);
            }

            UpdateGeocellSelection();
            //Testing
            if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButtonDown(0))
            {
                #region Wide Section

                /*
                 * CenterCameraOnLocation(Camera, new Vector3((float)((-18 + -8) * 0.5), (float)((54 + 52) * 0.5), 0.0f));
                 * FitBoundsToScreen(Camera, 52, -8, 54, -18);
                 *
                 *
                 * GeocellTexture.Set((float)52.5, (float)-8.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-9.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-10.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-11.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-12.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-13.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-14.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-15.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-16.5, GeocellColor);
                 * GeocellTexture.Set((float)52.5, (float)-17.5, GeocellColor);
                 *
                 * GeocellTexture.Set((float)53.5, (float)-8.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-9.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-10.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-11.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-12.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-13.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-14.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-15.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-16.5, GeocellColor);
                 * GeocellTexture.Set((float)53.5, (float)-17.5, GeocellColor);*/

                #endregion

                #region Tall Section

                CenterCameraOnLocation(Camera, new Vector3((float)((-10 + -8) * 0.5), (float)((56 + 52) * 0.5), 0.0f));
                FitBoundsToScreen(Camera, 52, -8, 56, -10);
                GeocellTexture.Set((float)52.5, (float)-8.5, GeocellColor);
                GeocellTexture.Set((float)52.5, (float)-9.5, GeocellColor);

                GeocellTexture.Set((float)53.5, (float)-8.5, GeocellColor);
                GeocellTexture.Set((float)53.5, (float)-9.5, GeocellColor);

                GeocellTexture.Set((float)54.5, (float)-8.5, GeocellColor);
                GeocellTexture.Set((float)54.5, (float)-9.5, GeocellColor);

                GeocellTexture.Set((float)55.5, (float)-8.5, GeocellColor);
                GeocellTexture.Set((float)55.5, (float)-9.5, GeocellColor);
                #endregion
            }
        }