void selfPivoteRotate(Vector2 touchPosition) { if (Controls2D.horizontalSlider.contains(touchPosition)) { Arthroscope.saveActualState(); this.transform.Rotate(0, -Arthroscope.determineSpeed(touchPosition.x, initialTouchPosition.x, Arthroscope.selfPivotRotationSpeed), 0); } }
// Update is called once per frame void Update() { if (detectCameraCollision()) { this.transform.position = Arthroscope.initialPosition; this.transform.eulerAngles = Arthroscope.initialRotation; Arthroscope.changeCameraRotation(90.0f); this.rigidbody.constraints = RigidbodyConstraints.FreezeAll; StartCoroutine(DenyArthroscopeMovementAndSetInitialPosition()); StartCoroutine(blink()); PortalsMenu.rebootControls2D(); } }
void advance(Vector2 touchPosition) { if (Controls2D.verticalSlider.contains(touchPosition)) { /* * Remember that both, touchPosition (initialTouchPosition passed as parameter) * and initialTouchPosition has been applied the y axis mirror doing *.y = Screen.height - *.y * * Remember too that, the y axis mirror described before, has an inverse y axis in the cartesian system, * thus, the higher is the touch, the lower is its value */ bool goingUp = touchPosition.y > initialTouchPosition.y; bool inRange = (goingUp && Arthroscope.currentPosition.z <= Arthroscope.maximumDeepness) || (!goingUp && Arthroscope.currentPosition.z >= Arthroscope.minimumDeepness) ; if (inRange) { Arthroscope.saveActualState(); Arthroscope.move(this.transform.TransformDirection(Vector3.up), currentTouchPosition.y, initialTouchPosition.y, Arthroscope.advanceSpeed); } } }
void portalPivoteRotate(Vector2 touchPosition) { Circle portalRotationCircle = Controls2D.portalRotationCircle; Circle portalRotationBackgroundCircle = Controls2D.portalRotationBackgroundCircle; /* * Remember that in the Circles, we save the center with a little offset for well printing on screen porpuse. * Then, to get the real centers of a circle, we need to sum its radius in x and y */ Vector2 realPortalRotationBackgroundCircleCenter = new Vector2( portalRotationBackgroundCircle.center.x + portalRotationBackgroundCircle.radius, portalRotationBackgroundCircle.center.y + portalRotationBackgroundCircle.radius ) ; if (portalRotationCircle.contains(touchPosition)) { /* * If the portalRotationCircle is in the portalRotationBackgroundCircle */ if (inCircle(currentTouchPosition, realPortalRotationBackgroundCircleCenter, portalRotationBackgroundCircle.radius, portalRotationCircle.radius)) { Arthroscope.saveActualState(); lastTouchPosition = portalRotationCircle.center; portalRotationCircle.center = new Vector2(touchPosition.x - portalRotationCircle.radius, touchPosition.y - portalRotationCircle.radius); this.transform.Rotate(Arthroscope.determineSpeed(portalRotationCircle.center.y, lastTouchPosition.y, Arthroscope.portalPivotRotationSpeed) * -1, 0, 0); this.transform.Rotate(0, 0, Arthroscope.determineSpeed(portalRotationCircle.center.x, lastTouchPosition.x, Arthroscope.portalPivotRotationSpeed) * -1); } } Controls2D.portalRotationCircle = portalRotationCircle; Controls2D.portalRotationBackgroundCircle = portalRotationBackgroundCircle; }
/* Menu de resultados */ void OnGUI() { Texture2D botonOriginal = new GUIStyle("button").normal.background; if (MainLayout.arthroscope) { GUI.depth = 3; float distance = 2.2f; float LSeparation = 0.3f; float BSeparation = 0.4f; if (portalsSkin) { GUI.skin = portalsSkin; } GUI.Box(new Rect(WIDTH_MENU, HEIGHT_MENU, WIDTH * 0.8f, HEIGHT), "Artroscopio."); GUI.skin.label.fontSize = (int)(Math.Round((double)WIDTH_MENU * 0.7f, 0)); /* * Angle's labels */ GUI.Label(new Rect(WIDTH_MENU * 3.5f, HEIGHT_MENU * 1.5f, WIDTH, HEIGHT_BUTTON), "Angulos "); /* * 0 degrees button */ if ( GUI.Button(new Rect(WIDTH_MENU * 1.1f, HEIGHT_MENU * 1.8f, WIDTH_BUTTON * 0.7f, HEIGHT_BUTTON * 0.7f), "0°") ) { Arthroscope.changeCameraRotation(90.0f); } /* * 30 degrees button */ if ( GUI.Button(new Rect(WIDTH_MENU + WIDTH_BUTTON * 0.7f + 10.0f, HEIGHT_MENU * 1.8f, WIDTH_BUTTON * 0.7f, HEIGHT_BUTTON * 0.7f), "30°") ) { Arthroscope.changeCameraRotation(120.0f); } /* * 70 degrees button */ if ( GUI.Button(new Rect(WIDTH_MENU + ((WIDTH_BUTTON * 0.7f) * 2.0f) + 20.0f, HEIGHT_MENU * 1.8f, WIDTH_BUTTON * 0.7f, HEIGHT_BUTTON * 0.7f), "70°") ) { Arthroscope.changeCameraRotation(160.0f); } /* * End angle's labels */ /* * Portals */ /* * Portal's label */ GUI.Label(new Rect(WIDTH_MENU * 3.5f, HEIGHT_MENU * distance, WIDTH, HEIGHT_BUTTON), "Portales "); if ( GUI.Button(new Rect(WIDTH_MENU * 3.3f, HEIGHT_MENU * (distance = distance + LSeparation), WIDTH_BUTTON, HEIGHT_BUTTON * 0.7f), "Anterocentral") ) { moveArthroscopeToPortal(position0, rotation0); } if ( GUI.Button(new Rect(WIDTH_MENU * 1.1f, HEIGHT_MENU * (distance = distance + BSeparation), WIDTH_BUTTON, HEIGHT_BUTTON * 0.7f), "Anterolateral") ) { moveArthroscopeToPortal(position1, rotation1); } if ( GUI.Button(new Rect(WIDTH_MENU * 5.5f, HEIGHT_MENU * (distance), WIDTH_BUTTON + offset, HEIGHT_BUTTON * 0.7f), "Anteromedial") ) { moveArthroscopeToPortal(position2, rotation2); } if ( GUI.Button(new Rect(WIDTH_MENU * 1.1f, HEIGHT_MENU * (distance = distance + BSeparation), WIDTH_BUTTON, HEIGHT_BUTTON * 0.7f), "Superolateral") ) { moveArthroscopeToPortal(position4, rotation4); } if ( GUI.Button(new Rect(WIDTH_MENU * 5.5f, HEIGHT_MENU * (distance), WIDTH_BUTTON + offset, HEIGHT_BUTTON * 0.7f), "Superomedial") ) { moveArthroscopeToPortal(position3, rotation3); } if ( GUI.Button(new Rect(WIDTH_MENU * 1.1f, HEIGHT_MENU * (distance = distance + BSeparation), WIDTH_BUTTON, HEIGHT_BUTTON * 0.7f), "Posterolateral") ) { moveArthroscopeToPortal(position5, rotation5); } if ( GUI.Button(new Rect(WIDTH_MENU * 5.5f, HEIGHT_MENU * (distance), WIDTH_BUTTON + offset, HEIGHT_BUTTON * 0.7f), "Posteromedial") ) { moveArthroscopeToPortal(position6, rotation6); } /* * Continue button */ if (GUI.Button(new Rect(WIDTH * 0.01f + ANCHO_BUTTON + offset, (HEIGHT + HEIGHT_BUTTON * 1.7f), WIDTH_BUTTON, HEIGHT_BUTTON), "Continuar")) { MainLayout.arthroscope = !MainLayout.arthroscope; } } }