Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if ((playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Vanilla) && (playerManagerScript.returnSwinging() == false))
        {
            /*foreach (Collider col in ChildColliders)
             * {
             *  col.GetComponent<Collider>().enabled = true;
             * }*/

            if (Input.GetKey("joystick button 5"))
            {
                transform.localRotation = Quaternion.Euler(rotationVector);
            }
            else
            {
                transform.localRotation = Quaternion.Euler(startingVector);
            }
        }
        else
        {
            /*foreach (Collider col in ChildColliders)
             * {
             *  col.GetComponent<Collider>().enabled = false;
             * }*/
        }
    }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BallFlying)
     {
         GetComponent <Behaviour>().enabled = true;
         GetComponent <Renderer>().enabled  = false;
         GetComponent <Collider>().enabled  = false;
     }
     else
     {
         GetComponent <Renderer>().enabled = true;
         GetComponent <Collider>().enabled = true;
     }
 }
    // Update is called once per frame
    void Update()
    {
        /*if (!isLocalPlayer)
         * {
         *  return;
         * }*/

        if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Dead)
        {
            return;
        }

        if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Vanilla)
        {
            if (goBackToRotation == true)
            {
                goBackToRotation = false;
                Quaternion newRotationValue = new Quaternion(0, 0, 0, 0);
                newRotationValue.Set(originalRotationValue.x, transform.rotation.y, originalRotationValue.x, originalRotationValue.w);
                transform.rotation = Quaternion.Slerp(transform.rotation, newRotationValue, Time.time * 1.0f);
            }

            float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f;
            float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f;
            transform.Translate(0, 0, y);
            transform.Translate(x * 2.0f, 0, 0);

            float z = Input.GetAxis("CameraHorizontal") * Time.deltaTime * 35.0f;
            transform.Rotate(0, z * 4.0f, 0);
        }
        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Weapon)
        {
            goBackToRotation = true;

            float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f;
            float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f;
            transform.Translate(x, 0, y);

            //this needs to rotate through the values so that if you are facing forward it is not as senstive as turning around quickly
            float z = Input.GetAxis("CameraHorizontal") * Time.deltaTime * 35.0f;
            float h = Input.GetAxis("CameraVertical") * Time.deltaTime * 35.0f;
            transform.Rotate(h, z * 7.0f, 0);
        }
        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingOutsideRing)
        {
            float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f;
            float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f;
            transform.Translate(0, 0, y);
            transform.Rotate(0, x * 6.0f, 0);
        }
        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingInsideRing)
        {
            //???
            float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f;
            float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f;
            transform.Translate(0, 0, y);
            transform.Rotate(0, x * 6.0f, 0);
            //transform.RotateAround(actualGolfBall.transform.position, Vector3.up, speed * Time.deltaTime);
        }
        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BallFlying)
        {
            if (playerManagerScript.ShowCurrentClub() == Player_Manager.CurrentClub.Putter)
            {
                float x = Input.GetAxis("Horizontal") * Time.deltaTime * 10.0f;
                //float y = Input.GetAxis("Vertical") * Time.deltaTime * 10.0f;
                //actualGolfBall.transform.Translate(0, 0, y);
                //actualGolfBall.transform.Translate(0, 0, x * 10.0f);
                //actualGolfBall.transform.Rotate(x * 10.0f, 0, 0);
            }
            else
            {
                //REMEMBER HOW TO RESEARCH TO MAKE THE GAME FEEL LIKE IT IS IN SLOW MOTION LIKE HEAVENLY SWORD
                float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f;
                float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f;
                actualGolfBall.transform.Translate(x, 0, y);
                actualGolfBall.transform.Rotate(0, x * 2.0f, 0);
            }
        }
        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BirdsEye)
        {
        }
    }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Weapon)
        {
            currentWeapon.SetActive(true);
            Club_Driver.SetActive(false);
            Club_Iron.SetActive(false);
            Club_Putter.SetActive(false);
            foreach (GameObject unusedWeapon in UnusedWeapons)
            {
                unusedWeapon.SetActive(false);
            }

            if (Input.GetKeyDown("joystick button 5"))
            {
                Fire();
            }
        }

        if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Vanilla)
        {
            currentClub.SetActive(true);
            Weapon_Driver.SetActive(false);
            Weapon_Iron.SetActive(false);
            Weapon_Putter.SetActive(false);
            foreach (GameObject unusedClub in UnusedClubs)
            {
                unusedClub.SetActive(false);
            }
        }

        //Driver
        if (Input.GetKeyDown("joystick button 2"))
        {
            currentClub   = Club_Driver;
            currentWeapon = Weapon_Driver;
            UnusedClubs.Clear();
            UnusedClubs.Add(Club_Iron);
            UnusedClubs.Add(Club_Putter);
            UnusedWeapons.Clear();
            UnusedWeapons.Add(Weapon_Iron);
            UnusedWeapons.Add(Weapon_Putter);
            currentBulletState = BulletStates.DriverBullet;
            playerManagerScript.CurrentClubIsDriver();
        }

        //Iron
        if (Input.GetKeyDown("joystick button 3"))
        {
            currentClub   = Club_Iron;
            currentWeapon = Weapon_Iron;
            UnusedClubs.Clear();
            UnusedClubs.Add(Club_Driver);
            UnusedClubs.Add(Club_Putter);
            UnusedWeapons.Clear();
            UnusedWeapons.Add(Weapon_Driver);
            UnusedWeapons.Add(Weapon_Putter);
            currentBulletState = BulletStates.IronBullet;
            playerManagerScript.CurrentClubIsIron();
        }

        //Putter
        if (Input.GetKeyDown("joystick button 1"))
        {
            currentClub   = Club_Putter;
            currentWeapon = Weapon_Putter;
            UnusedClubs.Clear();
            UnusedClubs.Add(Club_Driver);
            UnusedClubs.Add(Club_Iron);
            UnusedWeapons.Clear();
            UnusedWeapons.Add(Weapon_Driver);
            UnusedWeapons.Add(Weapon_Iron);
            currentBulletState = BulletStates.PutterBullet;
            playerManagerScript.CurrentClubIsPutter();
        }
    }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Dead)
        {
            return;
        }

        if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Vanilla)
        {
            GolfBallCamera.SetActive(false);
            OverWorldCamera.SetActive(false);
            GolfBallCamera2.SetActive(false);

            Vector3 actualPlayerPosition = actualPlayer.transform.position;
            Vector3 eye           = actualPlayer.transform.position - actualPlayer.transform.forward * -100.0f + actualPlayer.transform.up * +25.0f;
            Vector3 cameraForward = actualPlayer.transform.position - eye;
            cameraForward.Normalize();
            Vector3 cameraLeft = Vector3.Cross(actualPlayer.transform.up, cameraForward).normalized;
            Vector3 cameraUp   = Vector3.Cross(cameraForward, cameraLeft).normalized;
            transform.position = Vector3.MoveTowards(transform.position, VanillaCameraFollow.transform.position, 50.0f * Time.deltaTime);
            transform.LookAt(eye, cameraUp);

            //Camera FOV
            if (currentFOV != VanillaFOV)
            {
                if (currentFOV < VanillaFOV)
                {
                    GetComponent <Camera>().fieldOfView = currentFOV + 1.0f;
                    currentFOV = GetComponent <Camera>().fieldOfView;
                }
                else
                {
                    GetComponent <Camera>().fieldOfView = currentFOV - 1.0f;
                    currentFOV = GetComponent <Camera>().fieldOfView;
                }
            }
        }
        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Weapon)
        {
            Vector3 actualPlayerPosition = actualPlayer.transform.position;
            Vector3 eye           = actualPlayer.transform.position - actualPlayer.transform.forward * -100.0f + actualPlayer.transform.up * +25.0f;
            Vector3 cameraForward = actualPlayer.transform.position - eye;
            cameraForward.Normalize();
            Vector3 cameraLeft = Vector3.Cross(actualPlayer.transform.up, cameraForward).normalized;
            Vector3 cameraUp   = Vector3.Cross(cameraForward, cameraLeft).normalized;
            transform.position = Vector3.MoveTowards(transform.position, WeaponCameraFollow.transform.position, 50.0f * Time.deltaTime);
            transform.LookAt(eye, cameraUp);

            //Camera FOV
            if (currentFOV < WeaponFOV)
            {
                //currentFOV = currentFOV + 1.0f;
                GetComponent <Camera>().fieldOfView = currentFOV + 1.0f;
                currentFOV = GetComponent <Camera>().fieldOfView;
            }

            /*Vector3 actualPlayerPosition = actualPlayer.transform.position;
             * actualPlayerPosition.x = actualPlayerPosition.x + 0.5f;
             * actualPlayerPosition.y = actualPlayerPosition.y + 3.0f;
             * actualPlayerPosition.z = actualPlayerPosition.z + 4.0f;
             * transform.position = Vector3.MoveTowards(transform.position, actualPlayerPosition, 75.0f * Time.deltaTime);
             *
             * //Camera Movement
             * float x = Input.GetAxis("CameraHorizontal") * Time.deltaTime * 35.0f;
             * float y = Input.GetAxis("CameraVertical") * Time.deltaTime * 35.0f;
             * transform.Rotate(y * 2.0f, x * 2.0f, 0);*/
        }
        else if ((playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingOutsideRing) ||
                 (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingInsideRing))
        {
            if (currentFOV > GolfClubFOV)
            {
                GetComponent <Camera>().fieldOfView = currentFOV - 1.0f;
                currentFOV = GetComponent <Camera>().fieldOfView;
            }

            Vector3 actualPlayerPosition = actualPlayer.transform.position;
            Vector3 eye           = actualPlayer.transform.position - actualPlayer.transform.forward * -100.0f + actualPlayer.transform.up * -10.0f;
            Vector3 cameraForward = actualPlayer.transform.position - eye;
            cameraForward.Normalize();
            Vector3 cameraLeft = Vector3.Cross(actualPlayer.transform.up, cameraForward).normalized;
            Vector3 cameraUp   = Vector3.Cross(cameraForward, cameraLeft).normalized;
            transform.position = Vector3.MoveTowards(transform.position, GolfingCameraFollow.transform.position, 50.0f * Time.deltaTime);

            if ((horAndVertCameraMoving == false) && (horAndVertCameraMoved == false))
            {
                transform.LookAt(eye, cameraUp);
            }
            if ((horAndVertCameraMoving == false) && (horAndVertCameraMoved == true))
            {
                //Quaternion rotation = Quaternion.LookRotation(actualPlayer.transform.position - transform.position);
                //transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime);
                //transform.rotation = Quaternion.Slerp
            }


            float x = Input.GetAxis("CameraHorizontal") * Time.deltaTime * 35.0f;
            if (x != 0.0f)
            {
                previousX = x;
                horAndVertCameraMoving = true;
                transform.Rotate(0, x * 1.0f, 0);
            }

            if ((x == 0.0f) && (previousX != 0.0f))
            {
                horAndVertCameraMoving = false;
                horAndVertCameraMoving = true;
            }

            if ((x == 0.0f) && previousX == 0.0f)
            {
                horAndVertCameraMoving = false;
                horAndVertCameraMoved  = false;
            }

            //print(x);
            //float y = Input.GetAxis("CameraVertical") * Time.deltaTime * 35.0f;
            //transform.Rotate(y * 0.5f, x * 0.5f, 0);
        }

        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BallFlying)
        {
            if (playerManagerScript.ReturnGolfBallHasStruckTerrain() == true)
            {
                GolfBallCamera2.SetActive(true);
                Vector3 pos = actualGolfBall.transform.position;
                pos.z -= 5.0f;
                pos.y += 50.0f;
                GolfBallCamera2.transform.position = pos;
                GolfBallCamera2.transform.RotateAround(actualGolfBall.transform.position, -Vector3.up, 32.0f * Time.deltaTime);
                GolfBallCamera.SetActive(false);
            }
            else
            {
                if (playerManagerScript.ShowCurrentClub() != Player_Manager.CurrentClub.Putter)
                {
                    GolfBallCamera2.SetActive(false);
                    GolfBallCamera.SetActive(true);
                }
                else
                {
                    transform.position = Vector3.MoveTowards(transform.position, actualGolfBall.transform.position, 100.0f * Time.deltaTime);
                }
            }
        }
        else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BirdsEye)
        {
            OverWorldCamera.SetActive(true);
        }
    }
Exemple #6
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;
                }
            }
        }
    }