Esempio n. 1
0
    private void Update()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (touched)
        {
            if (Input.touchCount == 1)
            {
                Touch t = Input.GetTouch(0);

                Vector2 move = t.deltaPosition / Screen.width;
                //float direction = t.position.y / Screen.height;
                //move.x *= (0.5f - direction) * 2;

                cam.Movement(move);
            }

            if (Input.touchCount == 2)
            {
                Touch   t1       = Input.GetTouch(0);
                Touch   t2       = Input.GetTouch(1);
                Vector2 lastPos1 = t1.position - t1.deltaPosition;
                Vector2 lastPos2 = t2.position - t2.deltaPosition;
                float   lastDist = (lastPos1 - lastPos2).magnitude / Screen.width;
                float   curDist  = (t1.position - t2.position).magnitude / Screen.width;

                cam.Zoom(curDist / lastDist);
            }
        }
    }
Esempio n. 2
0
 public void SetsCameraBoundsToTilemap()
 {
     Debug.Log("camera bounds: " + mapCamera.CalculateCameraBounds());
     gameMap.UpdateMapToRadius(1);
     Debug.Log("new camera bounds: " + mapCamera.CalculateCameraBounds());
     Debug.Log("ortho size before: " + mapCamera.camera.orthographicSize);
     mapCamera.Zoom(140);
     Debug.Log("ortho size after: " + mapCamera.camera.orthographicSize);
     Debug.Log("newer camera bounds: " + mapCamera.CalculateCameraBounds());
 }
 public void CameraZoomsIn()
 {
     mapCamera.Zoom(2);
     Assert.AreEqual(initialOrthographicSize - 1, mapCamera.camera.orthographicSize);
 }