예제 #1
0
    IEnumerator GetPalmPlane()
    {
        /*zjsteni roviny dlane pro urceni klikaci roviny - nepouziva se, nepresne*/
        Plane plane;
        Plane firstPlane;

        firstPlane = leapController.ControllingHandPlane();

        while (true)
        {
            plane = leapController.ControllingHandPlane();


            if (!leapController.ControllingHandInView() || (plane.normal - firstPlane.normal).magnitude > 0.1)
            {
                loadingHand.Restart();
                firstPlane = plane;
            }

            if (loadingHand.HasFinished())
            {
                //print (leapController.ControllingHandInView());
                plane = leapController.ControllingHandPlane();
                //print (plane.distance);
                //print (plane.normal);
                ClickPlaneScanned(plane);
                break;
            }

            yield return(null);
        }
    }
예제 #2
0
    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();
            }
        }
    }
예제 #3
0
 // Update is called once per frame
 void Update()
 {
     if (gameController.UsingLeap() && !gameController.IsColorPicking() && leapController.ControllingHandInView())          //PlayerLeapController je active
     {
         if (selectMethod == PermanentSelectMethod.Hovering)
         {
             CheckHovering();
         }
         else if (gameController.IsHoveringMethod() && selectMethod == PermanentSelectMethod.ChosenFromMenu)
         {
             CheckHovering();
         }
     }
 }
    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();
                    }
                }
            }
        }
    }