// Controller controller = new Controller (); // Update is called once per frame void Update() { leapController.DrawOnPalm(leapController.GetControllingHand(), gameObject); /* * Frame frame = controller.Frame (); * * if (!frame.Hands.IsEmpty){ * Hand hand = frame.Hands.Frontmost; * * //transform.localEulerAngles = new Vector3 (90, -(((hand.Direction.Yaw * 180) / Mathf.PI) + 90), 0); * //transform.localEulerAngles = new Vector3 ((((hand.Direction.Pitch * 180) / Mathf.PI)), 0, 0); * //transform.localEulerAngles = new Vector3 (0, 0, (((hand.PalmNormal.Roll * 180) / Mathf.PI))); * transform.localEulerAngles = new Vector3 ((((hand.Direction.Pitch * 180) / Mathf.PI)), -(((hand.Direction.Yaw * 180) / Mathf.PI)), (((hand.PalmNormal.Roll * 180) / Mathf.PI))); * } */ }
void Update() { if (leapController.ControllingHandInView() && !tutorial.shipTried) { tutorial.shipTried = true; } ///////--------------------------------------------poloha/pohyb Vector3 position = new Vector3(0, 0, 0); Vector3 controlPosition = Camera.main.ScreenToWorldPoint(leapController.GetControlScreenPosition()); rigidbody.rotation = leapController.GetControlRotation(); transform.rotation = leapController.GetControlRotation(); //position = new Vector3 (controlPosition.x, controlPosition.y, controlPosition.z + playerShift); //aby lod byla kus pred prstem, TAKHLE NE position = controlPosition + transform.forward * playerShift; rigidbody.position = new Vector3 ( //ziskaji se okraje obrazovky podle viewportu Mathf.Clamp(position.x, Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 0.0f, 0.0f)).x + 1, Camera.main.ViewportToWorldPoint(new Vector3(1.0f, 0.0f, 0.0f)).x - 1), 0.0f, Mathf.Clamp(position.z, Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 0.0f, 0.0f)).z + 1, Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 1.0f, 0.0f)).z - 1) ); transform.position = rigidbody.position; ///verze hry hovering if (leapController.ControllingHandInView() && gameController.IsHoveringMethod() && (Time.time > nextFire)) { float angle = leapController.AngleBetweenFingers(leapController.GetControllingHand()); if (angle < fireAngle) { FireShot(); tutorial.PointShot(); } } }
void Update() { ///////--------------------------------------------poloha/pohyb Vector3 position = new Vector3(0, 0, 0); //ovladani klavesnici if (!gameController.UsingLeap()) { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); rigidbody.velocity = movement * speed; rigidbody.rotation = Quaternion.Euler(rigidbody.velocity.z * tilt, 0.0f, rigidbody.velocity.x * -tilt); position = rigidbody.position; } //ovladani leapem else if (gameController.UsingLeap()) { Vector3 controlPosition = Camera.main.ScreenToWorldPoint(leapController.GetControlScreenPosition()); rigidbody.rotation = leapController.GetControlRotation(); transform.rotation = leapController.GetControlRotation(); //position = new Vector3 (controlPosition.x, controlPosition.y, controlPosition.z + playerShift); //aby lod byla kus pred prstem, TAKHLE NE position = controlPosition + transform.forward * playerShift; Vector3 ammoPosition = Camera.main.ScreenToWorldPoint(leapController.GetControlJointPosition()); if (ammoSlider != null) { ammoSlider.SetPosRot(ammoPosition, leapController.GetControlRotation()); ammoSlider.SetValues(); } } //nastaveni pozice lodicky, nesmi se dostat mimo boundaries nebo mimo viewport(to co je videt) if (!screenBoundary) { rigidbody.position = new Vector3 ( Mathf.Clamp(position.x, boundary.xMin, boundary.xMax), 0.0f, Mathf.Clamp(position.z, boundary.zMin, boundary.zMax) ); } else { rigidbody.position = new Vector3 ( //ziskaji se okraje obrazovky podle viewportu Mathf.Clamp(position.x, Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 0.0f, 0.0f)).x + 1, Camera.main.ViewportToWorldPoint(new Vector3(1.0f, 0.0f, 0.0f)).x - 1), 0.0f, Mathf.Clamp(position.z, Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 0.0f, 0.0f)).z + 1, Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 1.0f, 0.0f)).z - 1) ); transform.position = rigidbody.position; } ///////-------------------------------strelba a pauzovani hry if (!gameController.UsingLeap()) { if (Input.GetButton("Fire1") && (Time.time > nextFire)) { FireShot(); } if (Input.GetKeyDown(KeyCode.Space) && !gameController.IsColorPicking()) { gameController.PauseGame(); } /* * if (Input.GetKeyDown (KeyCode.Escape) && !gameController.IsPause()) * gameController.ColorPicking (); * * if (Input.GetKeyDown (KeyCode.G)) { * gameController.colorPicker.SelectDown(); * }*/ } else if (gameController.UsingLeap()) { if (!leapController.ControllingHandInView() && !leapController.SecondaryHandInView()) { //provadet to jenom jednou tzn pokud jeste neni pauza, odpauzovat..etc gameController.PauseOnlyGame(); gameController.ColorPickingOff(); } /* * else if (leapController.SecondaryHandInView()){ * //gameController.UnpauseOnlyGame(); * gameController.PauseOnlyGame(); * GameObject colorpicker = gameController.ColorPickingOn(); * leapController.DrawOnPalm(leapController.GetSecondaryHand(), colorpicker); * } */ else if (leapController.ControllingHandInView()) { //gameController.UnpauseOnlyGame(); //gameController.ColorPickingOff(); if (leapController.ControllingHandGrab() == 1.0f) //sevřená pěst { gameController.PauseOnlyGame(); } ///verze hry hovering if (gameController.IsHoveringMethod() && (Time.time > nextFire)) { float angle = leapController.AngleBetweenFingers(leapController.GetControllingHand()); if (angle < fireAngle) { FireShot(); } } } } }