示例#1
0
文件: Zoom.cs 项目: red-pencil/ISWC18
    protected internal void ChangeZoom(int zoom)
    {
        if (OnChangeZoom != null)
        {
            OnChangeZoom();
        }
        Manager mg = GameObject.Find("Manager").GetComponent <Manager> ();

        if (!(mg.sy_OtherOption.ScreenSetting.platform == Variables.OtherOptionGroup.Platform.Mobile && mg.sy_CurrentStatus.is3DCam))
        {
            Camera.main.transform.position = new Vector3(0, 1, 0);
        }
        GameObject tileGroup = GameObject.Find("TileGroup");

        for (int i = 0; i < tileGroup.transform.childCount; i++)
        {
            GameObject.Destroy(tileGroup.transform.GetChild(i).gameObject);
        }

        ct.InitiCreateTile();
        RefreshMark();
        MarkCorrections();

        if (mg.sy_Map.activeMarkBuilding && mg.sy_CurrentStatus.is3DCam)
        {
            SetModeling("");
            Test7();
            if (mg.sy_OtherOption.ScreenSetting.platform == Variables.OtherOptionGroup.Platform.Mobile)
            {
                mg.StartDelete();
            }
        }
    }
示例#2
0
    IEnumerator Start()
    {
        if (sy_OtherOption.ScreenSetting.platform != Variables.OtherOptionGroup.Platform.Mobile)
        {
            if (sy_Map.activeMarkBuilding)
            {
                if (sy_OtherOption.ScreenSetting.platform != Variables.OtherOptionGroup.Platform.WebPlayer)
                {
                    if (sy_Config.Access.building == Variables.ConfigGroup.BuildingAccess.Local)
                    {
                        buildingLocal();
                    }
                    else if (sy_Config.Access.building == Variables.ConfigGroup.BuildingAccess.Web)
                    {
                        yield return(StartCoroutine(buildingWeb(sy_Config.phpurl)));
                    }
                    if (sy_Config.Access.mark == Variables.ConfigGroup.MarkAccess.Local)
                    {
                        initiLocal();
                    }
                    else if (sy_Config.Access.mark == Variables.ConfigGroup.MarkAccess.Web)
                    {
                        yield return(StartCoroutine(initiWeb()));
                    }
                }
                else
                {
                    if (!Application.isEditor)
                    {
                        yield return(StartCoroutine(buildingWeb(sy_Config.phpurl)));

                        yield return(StartCoroutine(initiWeb()));
                    }
                    else
                    {
                        //	Debug.Log ("WebPlayer: 에디터 모드에서 마크와 모델링을 가져올수 없습니다.");
                        sy_CurrentStatus.isReady = true;
                    }
                }
            }
            else
            {
                sy_CurrentStatus.isReady = true;
            }

            if (sy_CurrentStatus.isReady && (sy_Map.apikey [0].Length != 0 || sy_Map.apikey [1].Length != 0 && sy_Map.apikey [2].Length != 0))
            {
                mark.MarkSet();
                OrthSizeSetting();
                ct.InitiCreateTile();
            }
        }
        else               // -----------------------------------------------------------------------------------------------------------------------------------Mobile
        {
            if (sy_Map.activeMarkBuilding)
            {
                yield return(StartCoroutine(buildingWeb(sy_Config.phpurl)));

                yield return(StartCoroutine(initiWeb()));
            }
            else
            {
                sy_CurrentStatus.isReady = true;
            }
            if (sy_CurrentStatus.isReady && (sy_Map.apikey [0].Length != 0 || sy_Map.apikey [1].Length != 0 && sy_Map.apikey [2].Length != 0))
            {
                mark.MarkSet();
                OrthSizeSetting();
                ct.InitiCreateTile();
            }
        }
    }
示例#3
0
    public void Run(bool mouseDragging)
    {
        BaseOrthSize();
        Manager mg = GameObject.Find("Manager").GetComponent <Manager> ();

        float wheelSpeed = mg.sy_Map.wheelSpeed * 0.15f;

        if (!mouseDragging)
        {
            if (mg.sy_CurrentStatus.isChangeKey || Input.GetKey(mg.sy_OtherOption.UserKey.vrModeKey))
            {
                if (Input.GetMouseButton(0))
                {
                    if (!isInitiCreateTile)
                    {
                        isInitiCreateTile = true;
                        ct.InitiCreateTile();
                    }

                    xDeg += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
                    yDeg -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;

                    yDeg = ClampAngle(yDeg, mg.sy_OtherOption.Camera.angleMin, mg.sy_OtherOption.Camera.angleMax);

                    desiredRotation = Quaternion.Euler(yDeg, xDeg, 0);
                    currentRotation = vrCamera.transform.rotation;

                    rotation = Quaternion.Lerp(currentRotation, desiredRotation, Time.deltaTime * zoomDampening);
                    vrCamera.transform.rotation = rotation;
                }
            }
        }

        // Mouse ScrolWheel => Zoom In/Out
        float orthsizeOrigin = 0;
        float orthsizeAfter  = 0;

        ZoomLimits();
        if (Input.GetAxis("Mouse ScrollWheel") < 0 && max.Equals(false) && !(mg.sy_CurrentStatus.isMenu) && mg.sy_CurrentStatus.isSearchbar.Equals(false))
        {
            desiredDistance -= Input.GetAxis("Mouse ScrollWheel") * Mathf.Abs(desiredDistance) * wheelSpeed;
            orthsizeOrigin   = ((desiredDistance - 2.253f) / 0.173f) * 0.1f + 1.3f;
            if (orthsizeOrigin >= baseOrthSize)
            {
                Camera.main.orthographicSize = orthsizeOrigin;
                orthsizeAfter   = zm.OrthSize(orthsizeOrigin);
                desiredDistance = ((((orthsizeAfter - 1.3f) / 0.1f) * 0.173f) + 2.253f);
                zm.ZoomStep();
            }
        }
        else if (Input.GetAxis("Mouse ScrollWheel") > 0 && min.Equals(false) && !(mg.sy_CurrentStatus.isMenu) && mg.sy_CurrentStatus.isSearchbar.Equals(false))
        {
            desiredDistance -= Input.GetAxis("Mouse ScrollWheel") * Mathf.Abs(desiredDistance) * wheelSpeed;
            orthsizeOrigin   = ((desiredDistance - 2.253f) / 0.173f) * 0.1f + 1.3f;
            if (orthsizeOrigin <= baseOrthSize * 0.5f)
            {
                Camera.main.orthographicSize = orthsizeOrigin;
                orthsizeAfter   = zm.OrthSize(orthsizeOrigin);
                desiredDistance = ((((orthsizeAfter - 1.3f) / 0.1f) * 0.173f) + 2.253f);
                zm.ZoomStep();
            }
        }
        desiredDistance             = Mathf.Clamp(desiredDistance, 1, baseOrthSize * 2);
        position                    = target.position - (rotation * Vector3.forward * desiredDistance);
        vrCamera.transform.position = position;
        gbuilding.CalDistance(false);
    }
示例#4
0
    protected internal void Run(bool mouseDragging)
    {
        BaseOrthSize();
        Manager mg = GameObject.Find("Manager").GetComponent <Manager> ();

        target   = GameObject.Find("3D Target").transform;
        vrCamera = GameObject.Find("3D Camera").GetComponent <Camera> ();
        float zoomRate    = mg.sy_OtherOption.Mobile.zoomRate * 0.001f;
        float panSpeed    = mg.sy_OtherOption.Mobile.panSpeed * 0.001f;
        float rotateSpeed = mg.sy_OtherOption.Mobile.rotateSpeed * 5f;

        if (one)
        {
            Init();
            one = false;
        }

        if (Input.touchCount == 1)
        {
            Touch _touch = Input.GetTouch(0);
            if (_touch.phase == TouchPhase.Moved)
            {
                Vector3 _touch_delta = new Vector3(_touch.deltaPosition.x, -_touch.deltaPosition.y, 0);

                xDeg += Mathf.Deg2Rad * _touch_delta.x * rotateSpeed;
                yDeg += Mathf.Deg2Rad * _touch_delta.y * rotateSpeed;

                if (!isInitiCreateTile)
                {
                    isInitiCreateTile = true;
                    ct.InitiCreateTile();
                }

                yDeg = ClampAngle(yDeg, mg.sy_OtherOption.Camera.angleMin, mg.sy_OtherOption.Camera.angleMax);

                desiredRotation = Quaternion.Euler(yDeg, xDeg, 0);
                currentRotation = vrCamera.transform.rotation;

                rotation = Quaternion.Lerp(currentRotation, desiredRotation, Time.deltaTime * zoomDampening);
                vrCamera.transform.rotation    = rotation;
                Camera.main.transform.rotation = Quaternion.Euler(90, vrCamera.transform.eulerAngles.y, 0);
            }
        }

        if (Input.touchCount > 1)
        {
            ZoomLimits();
            if (Input.GetTouch(0).phase == TouchPhase.Began && Input.GetTouch(1).phase == TouchPhase.Began)
            {
                test = mg.sy_Map.zoom;
            }

            Vector3 touch1Dir  = Input.touches [0].deltaPosition.normalized;
            Vector3 touch2Dir  = Input.touches [1].deltaPosition.normalized;
            float   dotProduct = Vector2.Dot(touch1Dir, touch2Dir);

            if (dotProduct > 0)
            {
                isPanning = true;
                isZooming = false;
            }
            if (dotProduct < 0)
            {
                isZooming = true;
                isPanning = false;
            }
            Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
            if (isPanning)
            {
                Camera.main.transform.Translate(-touchDeltaPosition.x * panSpeed, -touchDeltaPosition.y * panSpeed, 0);
                if (touchDeltaPosition.magnitude > 5)
                {
                    mg.sy_CurrentStatus.isMarkPoint = false;
                }
            }

            if (isZooming)
            {
                float orthsizeOrigin = 0;
                float orthsizeAfter  = 0;
                //------------------------------------------------------------------------------Zoom
                curDist  = Input.GetTouch(0).position - Input.GetTouch(1).position;
                prevDist = (Input.GetTouch(0).position - Input.GetTouch(0).deltaPosition) - (Input.GetTouch(1).position - Input.GetTouch(1).deltaPosition);
                float deltaValue    = curDist.magnitude - prevDist.magnitude;
                float currentDistSq = curDist.sqrMagnitude;
                float prevDistSq    = prevDist.sqrMagnitude;


                if (currentDistSq > prevDistSq + 0.5f && min.Equals(false) && !(mg.sy_CurrentStatus.isMenu) && mg.sy_CurrentStatus.isSearchbar.Equals(false))
                {
                    desiredDistance -= Mathf.Abs(deltaValue) * zoomRate;
                    orthsizeOrigin   = ((desiredDistance - 2.253f) / 0.173f) * 0.1f + 1.3f;

                    orthsizeAfter = mg.zm.OrthSize(orthsizeOrigin);
                    Camera.main.orthographicSize = orthsizeAfter;
                    desiredDistance = ((((orthsizeAfter - 1.3f) / 0.1f) * 0.173f) + 2.253f);
                    mg.zm.MobileZoomStep(orthsizeOrigin);
                }

                if (currentDistSq < prevDistSq - 0.5f && max.Equals(false) && !(mg.sy_CurrentStatus.isMenu) && mg.sy_CurrentStatus.isSearchbar.Equals(false))
                {
                    desiredDistance -= -(Mathf.Abs(deltaValue) * zoomRate);
                    orthsizeOrigin   = ((desiredDistance - 2.253f) / 0.173f) * 0.1f + 1.3f;

                    orthsizeAfter = mg.zm.OrthSize(orthsizeOrigin);
                    Camera.main.orthographicSize = orthsizeAfter;
                    desiredDistance = ((((orthsizeAfter - 1.3f) / 0.1f) * 0.173f) + 2.253f);
                    mg.zm.MobileZoomStep(orthsizeOrigin);
                }
            }
            if (Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(1).phase == TouchPhase.Ended)
            {
                mg.gbuilding.CalDistance(true);
                if (test != mg.sy_Map.zoom)
                {
                    mg.Vr_Mobile_ChangeTheMap();
                }
            }
        }

        desiredDistance             = Mathf.Clamp(desiredDistance, 1, baseOrthSize * 2);
        position                    = target.position - (rotation * Vector3.forward * desiredDistance);
        vrCamera.transform.position = position;
    }