Beispiel #1
0
    // Update is called once per frame

    void Update()
    {
        if ((playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Vanilla) ||
            (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingOutsideRing))
        {
            if (Input.GetKey("joystick button 0"))
            {
                playerManagerScript.Swinging();
                if (swingPower < 5.0f)
                {
                    swingPower       = swingPower + 0.1f;
                    swingPowerActual = swingPower;
                    transform.Rotate(swingPower + 1.0f * Time.deltaTime, 0, 0);
                }
            }

            if (Input.GetKeyUp("joystick button 0"))
            {
                releaseSwing = true;
            }

            if (releaseSwing == true)
            {
                if (swingPower > 0.0f)
                {
                    i          = i + 1;
                    swingPower = swingPower - 0.1f;
                    transform.Rotate((-1 * swingPower) - 100.0f * (Time.deltaTime * 2), 0, 0);
                }
                else
                {
                    swingPower   = 0.0f;
                    releaseSwing = false;
                    playerManagerScript.NotSwinging();
                }
            }
        }

        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingInsideRing)
        {
            if (Input.GetKey("joystick button 0"))
            {
                playerManagerScript.Swinging();
                if (swingPower < 5.0f)
                {
                    swingPower       = swingPower + 0.1f;
                    swingPowerActual = swingPower;
                    transform.Rotate(swingPower + 1.0f * Time.deltaTime, 0, 0);
                }
            }

            if (Input.GetKeyUp("joystick button 0"))
            {
                releaseSwing = true;
            }

            if (releaseSwing == true)
            {
                if (swingPower > 0.0f)
                {
                    swingPower = swingPower - 0.1f;
                    transform.Rotate((-1 * swingPower) - 100.0f * (Time.deltaTime * 2), 0, 0);
                }
                else
                {
                    playerManagerScript.recieveSwingPower(swingPowerActual);
                    releaseSwing = false;
                    playerManagerScript.NotSwinging();
                    swingPower = 0.0f;
                }
            }
        }
    }