diff --git a/CSClub2017/CSClub 2017/Assets/Scripts/ButtonEvent.cs.meta b/CSClub2017/CSClub 2017/Assets/Scripts/ButtonEvent.cs.meta new file mode 100644 index 0000000..c7d2433 --- /dev/null +++ b/CSClub2017/CSClub 2017/Assets/Scripts/ButtonEvent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a0603b49419bf874eab3d7a08240ddea +timeCreated: 1495257395 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CSClub2017/CSClub 2017/Assets/Scripts/GameManager.cs.meta b/CSClub2017/CSClub 2017/Assets/Scripts/GameManager.cs.meta new file mode 100644 index 0000000..c4a21d1 --- /dev/null +++ b/CSClub2017/CSClub 2017/Assets/Scripts/GameManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 15ccfeba95110ec4aae11783c5186092 +timeCreated: 1495257395 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CSClub2017/CSClub 2017/Assets/Scripts/GameSettings.cs.meta b/CSClub2017/CSClub 2017/Assets/Scripts/GameSettings.cs.meta new file mode 100644 index 0000000..de85819 --- /dev/null +++ b/CSClub2017/CSClub 2017/Assets/Scripts/GameSettings.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8ba071a23849261429c48bb8e355e535 +timeCreated: 1495257395 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CSClub2017/CSClub 2017/Assets/Scripts/PlayerControl.cs b/CSClub2017/CSClub 2017/Assets/Scripts/PlayerControl.cs index 890f694..72c7dbd 100755 --- a/CSClub2017/CSClub 2017/Assets/Scripts/PlayerControl.cs +++ b/CSClub2017/CSClub 2017/Assets/Scripts/PlayerControl.cs @@ -1,12 +1,9 @@ /* * * Author: Spencer Wilson - * Date: 3/14/2017 (Happy Pi-Day everyone!) + * Date: 5/31/2017, 7:10 pm * File: PlayerControl.cs * Description: This file contains the code that takes user input in order to control the character. - * Disclaimer: A majority of this code I have gotten from tutorials. I have not been simply copying them, I have been - * trying to understand them and how they effect the gameplay mechanics in the Unity engine so that I may write code on my - * own one day. Simply put, they are a learning aid and have helped guide me along the process of creation. * */ @@ -20,134 +17,138 @@ public class PlayerControl : MonoBehaviour { - public float speed = 3; // Declaring a variable that holds the player's speed. - private Rigidbody rb; // Declaring a Rigidbody variable. + public float speed = 3; // Declaring a variable that holds the player's speed. + private Rigidbody rb; // Declaring a Rigidbody variable. + public GameObject pivotCen; // Area that the player rotates around when leaning. private Text player_ui_text; - float xRotationV = 0.0f; // The velocity along the x-axis. SmoothDamp function requires you to have a saved velocity variable. - float yRotationV = 0.0f; // The velocity along the y-axis. SmoothDamp function requires you to have a saved velocity variable. - float yRotation; // Variable that holds the value that the character rotates along the y-axis. (Where the player turns too) - float xRotation; // Variable that holds the value that the character rotates along the x-axis. (Where the player turns too) - public float currentRotationX; // Variable that holds the current value of the XRotation, prior to the camera movement. - public float currentRotationY; // Variable that holds the current value of the YRotation, priotr to the camera movement. - public float lookSmoothDamp = 0.1f; // Controls the smoothness of the player's look. (controls how smooth or jarring the camera is) - public float lookSensitivityX = 5.0f; // Variable that controls the sensitivity of the horizontal look. - public float lookSensitivityY = 5.0f; // Variable that controls the sensitivty of the vertical look. - public int maxVertical = 90; // Controls the maximum value along the vertical axis that the player can look. - public int minVertical = -90; // Controls the minimum value along the vertical axis that the player can look. - - public Camera mainCamera; - public Light flashlight; + float xRotationV = 0.0f; // The velocity along the x-axis. SmoothDamp function requires you to have a saved velocity variable. + float yRotationV = 0.0f; // The velocity along the y-axis. SmoothDamp function requires you to have a saved velocity variable. + float yRotation; // Variable that holds the value that the character rotates along the y-axis. (Where the player turns too) + float xRotation; // Variable that holds the value that the character rotates along the x-axis. (Where the player turns too) + public float currentRotationX; // Variable that holds the current value of the XRotation, prior to the camera movement. + public float currentRotationY; // Variable that holds the current value of the YRotation, priotr to the camera movement. + public float lookSmoothDamp = 0.1f; // Controls the smoothness of the player's look. (controls how smooth or jarring the camera is) + public float lookSensitivityX = 5.0f; // Variable that controls the sensitivity of the horizontal look. + public float lookSensitivityY = 5.0f; // Variable that controls the sensitivty of the vertical look. + public int maxVertical = 90; // Controls the maximum value along the vertical axis that the player can look. + public int minVertical = -90; // Controls the minimum value along the vertical axis that the player can look. + + public Camera mainCamera; + public Light flashlight; public Shader EffectsShader; - private bool lightOn = false; - private bool mouseBound = true; + private bool lightOn = false; + private bool mouseBound = true; private bool lookEnabled = true; private bool moveEnabled = true; private bool isHiding = false; private float currentTimeScale; - void Start() - { - Cursor.lockState = CursorLockMode.Locked; - Cursor.visible = !mouseBound; - rb = GetComponent(); + void Start() + { + + Cursor.lockState = CursorLockMode.Locked; + Cursor.visible = !mouseBound; + rb = GetComponent(); this.player_ui_text = GetComponentInChildren().GetComponentInChildren(); currentTimeScale = Time.timeScale; - if(mainCamera != null && EffectsShader != null) + if (mainCamera != null && EffectsShader != null) { Debug.Log("Loading Custom Shaders"); mainCamera.SetReplacementShader(EffectsShader, ""); } - } + } - private void Update() - { - if (Input.GetKeyDown(KeyCode.F)) { - lightOn = !lightOn; - } - flashlight.enabled = lightOn; - } + private void Update() + { + if (Input.GetKeyDown(KeyCode.F)) + { + lightOn = !lightOn; + } + flashlight.enabled = lightOn; + } - // Update is called once per frame - void FixedUpdate() // Used a tutorial, hopefully going to be expanding on this method to suit the game's needs and functionalities. - { - PlayerRotation(); // Calls upon the PlayerRotation() function. - //PlayerRun(); // Calls upon the PlayerRun() function. - PlayerMovement(); // Calls upon the PlayerMovement() function. - //PlayerCrouch(); // Calls upon the PlayerCrouch() function. - //PlayerLean(); // Calls upon the PlayerLean() function. - //PlayerProne(); // Calls upon the PlayerProne() function. - PlayerPause(); - } + // Update is called once per frame + void FixedUpdate() // Used a tutorial, hopefully going to be expanding on this method to suit the game's needs and functionalities. + { + PlayerRotation(); // Calls upon the PlayerRotation() function. + PlayerRun(); // Calls upon the PlayerRun() function. + PlayerMovement(); // Calls upon the PlayerMovement() function. + //PlayerCrouch(); // Calls upon the PlayerCrouch() function. + PlayerLean(); // Calls upon the PlayerLean() function. + PlayerProne(); // Calls upon the PlayerProne() function. + PlayerPause(); + } - void PlayerMovement() - { + void PlayerMovement() + { if (!this.moveEnabled) return; - float xAxis = Input.GetAxis("Horizontal"); // Declaring xAxis and assigning the Player's position along the x-axis to it. (My guess) - float zAxis = Input.GetAxis("Vertical"); // Declaring zAxis and assigning the Player's position along the z-axis to it. (My guess) - //Debug.Log( "x: " + xAxis + " z: " + zAxis); - - //Converting EularAngles to Radians, Adding 90 degrees for Left Right Radian converting - float radians = (mainCamera.transform.rotation.eulerAngles.y * Mathf.PI) / 180f ; - float radiansLR = ((mainCamera.transform.rotation.eulerAngles.y + 90) * Mathf.PI) / 180f ; - - //Mathf uses Radians only! - float modCos = Mathf.Cos (radians); - float modSin = Mathf.Sin (radians); - - float modCosLR = Mathf.Cos (radiansLR); - float modSinLR = Mathf.Sin (radiansLR); - - float newXDirec = zAxis * modSin + xAxis * modSinLR; - float newZDirec = zAxis * modCos + xAxis * modCosLR; - - //Debug.Log( "x: " + modCos + " z: " + modSin + " Cam: " + mainCamera.transform.rotation.eulerAngles.y - // + " Cam2: " + radians + " Pos: " + transform.position.x + " " + transform.position.z); - - //Debug.Log( "x: " + newXDirec + " z: " + newZDirec); - //Debug.Log( "Cam Rot: " + mainCamera.transform.rotation.eulerAngles.y); - - Vector3 movement = new Vector3(newXDirec, 0f, newZDirec) * speed * Time.deltaTime; - - //Assigning the player's movement to the movement variable. (My guess) - - //transform.position += transform.forward * xAxis + transform.forward * zAxis; Another way to make the player move, expect it doesn't allow the player to strafe sideways left and right. - - rb.MovePosition(transform.position + movement); // Adding player's input movement to the new position, allowing the player to move. (My guess) - } - - - - void PlayerRotation() - { + float xAxis = Input.GetAxis("Horizontal"); // Declaring xAxis and assigning the Player's position along the x-axis to it. (My guess) + float zAxis = Input.GetAxis("Vertical"); // Declaring zAxis and assigning the Player's position along the z-axis to it. (My guess) + //Debug.Log( "x: " + xAxis + " z: " + zAxis); + + //Converting EularAngles to Radians, Adding 90 degrees for Left Right Radian converting + float radians = (mainCamera.transform.rotation.eulerAngles.y * Mathf.PI) / 180f; + float radiansLR = ((mainCamera.transform.rotation.eulerAngles.y + 90) * Mathf.PI) / 180f; + + //Mathf uses Radians only! + float modCos = Mathf.Cos(radians); + float modSin = Mathf.Sin(radians); + + float modCosLR = Mathf.Cos(radiansLR); + float modSinLR = Mathf.Sin(radiansLR); + + float newXDirec = zAxis * modSin + xAxis * modSinLR; + float newZDirec = zAxis * modCos + xAxis * modCosLR; + + //Debug.Log( "x: " + modCos + " z: " + modSin + " Cam: " + mainCamera.transform.rotation.eulerAngles.y + // + " Cam2: " + radians + " Pos: " + transform.position.x + " " + transform.position.z); + + //Debug.Log( "x: " + newXDirec + " z: " + newZDirec); + //Debug.Log( "Cam Rot: " + mainCamera.transform.rotation.eulerAngles.y); + + Vector3 movement = new Vector3(newXDirec, 0f, newZDirec) * speed * Time.deltaTime; + + //Assigning the player's movement to the movement variable. (My guess) + + //transform.position += transform.forward * xAxis + transform.forward * zAxis; Another way to make the player move, expect it doesn't allow the player to strafe sideways left and right. + + rb.MovePosition(transform.position + movement); // Adding player's input movement to the new position, allowing the player to move. (My guess) + } + + + + void PlayerRotation() + { if (!this.lookEnabled) return; - xRotation += 0 - (Input.GetAxis("Mouse Y") * lookSensitivityY); // Stores the mouse's input along the y-axis (like a hinge, rotating left and right) and multiplying it to the lookSensitivity to get the value for the xRotation. Subtracting from zero corrects the axis from being inversed. - yRotation -= 0 - (Input.GetAxis("Mouse X") * lookSensitivityX); // Stores the mouse's input along the x-axis (like a hinge, rotating up and down) and multiplies it to the lookSensitivity to get the value for the yRotation. Subtracting from zero corrects the axis from being inversed. - - xRotation = Mathf.Clamp(xRotation, minVertical, maxVertical); // Makes sure the character has a realistic range of vertical head movement, clapms between minimumn and maximum. (Look Variable, minimum look, maximum look) - - currentRotationX = Mathf.SmoothDamp(currentRotationX, xRotation, ref xRotationV, lookSmoothDamp); // Gets the new x rotation on the x-axis by accounting for all of the variables that affect it's movement. - currentRotationY = Mathf.SmoothDamp(currentRotationY, yRotation, ref yRotationV, lookSmoothDamp); // Gets the new y rotation on the y-axis by accounting for all of the variables that affect it's movement. - - mainCamera.transform.rotation = Quaternion.Euler(currentRotationX, currentRotationY, 0); // Transforms from the previous rotations to the new rotations. - } - - void PlayerPause() - { - if (Input.GetButtonDown("Cancel")) - { - mouseBound = !mouseBound; - Debug.Log("Escape " + mouseBound); - if(mouseBound) - { + xRotation += 0 - (Input.GetAxis("Mouse Y") * lookSensitivityY); // Stores the mouse's input along the y-axis (like a hinge, rotating left and right) and multiplying it to the lookSensitivity to get the value for the xRotation. Subtracting from zero corrects the axis from being inversed. + yRotation -= 0 - (Input.GetAxis("Mouse X") * lookSensitivityX); // Stores the mouse's input along the x-axis (like a hinge, rotating up and down) and multiplies it to the lookSensitivity to get the value for the yRotation. Subtracting from zero corrects the axis from being inversed. + + xRotation = Mathf.Clamp(xRotation, minVertical, maxVertical); // Makes sure the character has a realistic range of vertical head movement, clapms between minimumn and maximum. (Look Variable, minimum look, maximum look) + + currentRotationX = Mathf.SmoothDamp(currentRotationX, xRotation, ref xRotationV, lookSmoothDamp); // Gets the new x rotation on the x-axis by accounting for all of the variables that affect it's movement. + currentRotationY = Mathf.SmoothDamp(currentRotationY, yRotation, ref yRotationV, lookSmoothDamp); // Gets the new y rotation on the y-axis by accounting for all of the variables that affect it's movement. + + mainCamera.transform.rotation = Quaternion.Euler(currentRotationX, currentRotationY, 0f); // Transforms from the previous rotations to the new rotations. + pivotCen.transform.rotation = Quaternion.Euler(0f, currentRotationY, 0f); // Rotates the Pivot Point gameobject in an attepmt to tie the new rotation with the z rotation in PlayerLean(). + } + + void PlayerPause() + { + if (Input.GetButtonDown("Cancel")) + { + mouseBound = !mouseBound; + Debug.Log("Escape " + mouseBound); + if (mouseBound) + { //In gameplay Cursor.lockState = CursorLockMode.Locked; Cursor.visible = !mouseBound; @@ -156,83 +157,146 @@ void PlayerPause() UI_Clear_Text(); //Time.timeScale = currentTimeScale; } - else - { + else + { //In menu Cursor.lockState = CursorLockMode.None; - Cursor.visible = !mouseBound; + Cursor.visible = !mouseBound; this.LookDisable(); this.MoveDisable(); UI_Set_Text("Menu Mode"); //Time.timeScale = 0.001f; } - } - - } - - - - void PlayerRun() // Creating a function that get's input in order to run. - { - if (Input.GetKey("left shift")) // When user presses down on the left shift, speed is set to 8. - { - speed = 8; - } - if (Input.GetKeyUp("left shift")) // When user lets go of the left shift, speed is set to 3. - { - speed = 3; - } - if (Input.GetKey("right shift")) // When user presses down on the right shift, speed is set to 8. - { - speed = 8; - } - if (Input.GetKeyUp("right shift")) // When user lets go of the right shift, speed is set to 3. - { - speed = 3; - } - } - - - - void PlayerCrouch() - { - if (Input.GetKeyDown("x")) - { - // Insert crouch code here - } - - if (Input.GetKeyUp("x")) - { - // Insert standing up code here - } - } - - - - void PlayerLean() - { - if (Input.GetKeyDown("q")) - { - // Insert Lean Left Code Here - } - if (Input.GetKeyUp("q")) - { - // Insert Return To Normal Posture Code Here - } - if (Input.GetKeyDown("e")) - { - // Insert Lean Right Code Here - } - if (Input.GetKeyUp("e")) - { - // Insert Return To Normal Posture Code Here - } - } - - void PlayerProne() - { - // Insert Player Prone Stuff. Might have to call upon the PlayerMovement function here to change the value of speed so it is slower when crawling. - } + } + + } + + + + void PlayerRun() // Creating a function that get's input in order to run. + { + if (Input.GetKey("left shift")) // When user presses down on the left shift, speed is set to 8. + { + speed = 8; + } + if (Input.GetKeyUp("left shift")) // When user lets go of the left shift, speed is set to 3. + { + speed = 3; + } + if (Input.GetKey("right shift")) // When user presses down on the right shift, speed is set to 8. + { + speed = 8; + } + if (Input.GetKeyUp("right shift")) // When user lets go of the right shift, speed is set to 3. + { + speed = 3; + } + } + + + + void PlayerCrouch() + { + if (Input.GetKeyDown("x")) + { + // Insert crouch code here + } + + if (Input.GetKeyUp("x")) + { + // Insert standing up code here + } + } + + + + void PlayerLean() + { + //float zBodyRotation = 10f; // Holds value for rotation along the z-axis. + //float yBodyRotation = 0; // Holds value for rotation along the y-axis. + //float zHeadRotation; + //float yHeadRotation; + //const float MAXZROTATION = (3f * Mathf.PI) / 2f; + //const float MINZROTATION = (Mathf.PI) / 4f; + //float newXRotation; + + Transform objTransform = pivotCen.GetComponent(); + Vector3 pivotPointPos = objTransform.position; + + bool heldQ = Input.GetKey("q"); + bool heldE = Input.GetKey("e"); + + float currentRotationAng = rb.rotation.eulerAngles.z; + const float MINANGLE = -45; + const float MAXANGLE = 45; + float leanAngle = 10f; + + if (heldQ == true) + { + //if ((currentRotationAng > 0) && (currentRotationAng < 90)) + //{ + Debug.Log("Player Lean Left"); + pivotCen.transform.Rotate(pivotPointPos, 70f); + transform.RotateAround(pivotPointPos, Vector3.forward, leanAngle); // Leans the player to the left. + //rb.freezeRotation; + //} + } + else if (heldE == true) + { + //if ((currentRotationAng < 0) && (currentRotationAng > -90)) + //{ + Debug.Log("Player Lean Right"); + transform.RotateAround(pivotPointPos, Vector3.forward, -leanAngle); // Leans the player to the right. + //} + } + else + { + Debug.Log("Player is upright."); + } + + //if (Input.GetKeyDown("q")) + //{ + // Debug.Log("Lean Left"); + + // transform.Rotate(0f, Time.deltaTime * (1 / 4), 10f); + // //transform.localEulerAngles = new Vector3(0f, 0f, zBodyRotation); // Leans the "body" (a.k.a the capsule) to the left 10 degrees. + // //Camera.transform.localEulerAngles = new Vector3(0f, 0f, zRotation); // Leans the "head" (a.k.a the camera) to simulate head peeking while leaning. + // // Mathf.Clamp(zRotation, MINZROTATION, MAXZROTATION); // Clamps rotation between two values to give a realistic range of leaning. + //} + //if (Input.GetKeyUp("q")) + //{ + // Debug.Log("Upright position"); + // transform.Rotate(0f, 0f, -10f); + // //transform.localEulerAngles = new Vector3(0f, 0f, 0f); + // // Mathf.Clamp(zRotation, MINZROTATION, MAXZROTATION); // Clamps rotation between two values to give a realistic range of leaning. + //} + //if (Input.GetKeyDown("e")) + //{ + // Debug.Log("Lean Right"); + // transform.localEulerAngles = new Vector3(0f, 0f, -zBodyRotation); + // // Mathf.Clamp(zRotation, MINZROTATION, MAXZROTATION); // Clamps rotation between two values to give a realistic range of leaning. + //} + //if (Input.GetKeyUp("e")) + //{ + // Debug.Log("Upright position"); + // transform.localEulerAngles = new Vector3(0f, 0f, 0f); + // // Mathf.Clamp(zRotation, MINZROTATION, MAXZROTATION); // Clamps rotation between two values to give a realistic range of leaning. + //} + } + + void PlayerProne() + { + bool proneKey = Input.GetKey("c"); + + if (proneKey == true) + { + Debug.Log("Player is prone."); + } + else + { + Debug.Log("Player is standing."); + } + } /// /// True when the player is Hiding @@ -271,7 +335,7 @@ public void LookEnable() public void LookDisable() { this.lookEnabled = false; - } + } /// /// Enable Player move controls @@ -296,7 +360,7 @@ public void UI_Clear_Text() this.player_ui_text.text = ""; } } - + /******************************** @@ -306,7 +370,7 @@ public void UI_Clear_Text() public void UI_Set_Text(string input) { - if(this.player_ui_text != null) + if (this.player_ui_text != null) { this.player_ui_text.text = input; } diff --git a/CSClub2017/CSClub 2017/Assets/Scripts/SettingsManager.cs.meta b/CSClub2017/CSClub 2017/Assets/Scripts/SettingsManager.cs.meta new file mode 100644 index 0000000..cbd674e --- /dev/null +++ b/CSClub2017/CSClub 2017/Assets/Scripts/SettingsManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 84bd3fb6671cd1c47925f7d8cc703f81 +timeCreated: 1495257395 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CSClub2017/CSClub 2017/Assets/UI.meta b/CSClub2017/CSClub 2017/Assets/UI.meta new file mode 100644 index 0000000..70a2e88 --- /dev/null +++ b/CSClub2017/CSClub 2017/Assets/UI.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c06cec6e272de244fb9eb9ee638a4200 +folderAsset: yes +timeCreated: 1495257393 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/CSClub2017/CSClub 2017/Assets/_Scenes/Spencer_Test.unity b/CSClub2017/CSClub 2017/Assets/_Scenes/Spencer_Test.unity index d7905b7..ac1d645 100644 Binary files a/CSClub2017/CSClub 2017/Assets/_Scenes/Spencer_Test.unity and b/CSClub2017/CSClub 2017/Assets/_Scenes/Spencer_Test.unity differ diff --git a/CSClub2017/CSClub 2017/ProjectSettings/ProjectVersion.txt b/CSClub2017/CSClub 2017/ProjectSettings/ProjectVersion.txt index ca09a3d..6e4d03d 100644 --- a/CSClub2017/CSClub 2017/ProjectSettings/ProjectVersion.txt +++ b/CSClub2017/CSClub 2017/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 5.6.0f3 +m_EditorVersion: 5.6.1f1