diff --git a/OdysseyNow/.idea/.idea.OdysseyNow/.idea/workspace.xml b/OdysseyNow/.idea/.idea.OdysseyNow/.idea/workspace.xml index c866cdd..fefcb19 100644 --- a/OdysseyNow/.idea/.idea.OdysseyNow/.idea/workspace.xml +++ b/OdysseyNow/.idea/.idea.OdysseyNow/.idea/workspace.xml @@ -12,17 +12,38 @@ - + - + diff --git a/OdysseyNow/Assets/CalibrationSceneDirector.cs b/OdysseyNow/Assets/CalibrationSceneDirector.cs index 31f3d3b..e7cdf5d 100644 --- a/OdysseyNow/Assets/CalibrationSceneDirector.cs +++ b/OdysseyNow/Assets/CalibrationSceneDirector.cs @@ -1,9 +1,9 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using UnityEngine; -public class CalibrationSceneDirector : MonoBehaviour -{ +public class CalibrationSceneDirector : MonoBehaviour { public Transform p1; public Transform p2; @@ -36,7 +36,9 @@ public class CalibrationSceneDirector : MonoBehaviour public float _calib_votage_x_left = 617; public float _calib_votage_x_right = 300; public float _calib_votage_y_top = 711; + public float _calib_votage_y_bottom = 379; + // -- Calibration parameters for Writing to Arduino public float _calib_write_votage_x_left = 420; public float _calib_write_votage_x_right = 302; @@ -44,8 +46,7 @@ public class CalibrationSceneDirector : MonoBehaviour public float _calib_write_votage_y_bottom = 80; // Think of the process of calibration is a state-machine - private enum CalibrationStates - { + private enum CalibrationStates { NOT_STARTED = 0, ANIMMOTION_START = 1, @@ -69,8 +70,7 @@ private enum CalibrationStates private float mOriginalPlayerTargetSpeed; // Start is called before the first frame update - void Start() - { + private void Start() { // Preserve the target camera position m3DSceneCameraPosition = camera3DScene.transform.position; m3DSceneCameraRotation = camera3DScene.transform.rotation; @@ -107,30 +107,24 @@ void Start() float distCovered, progress; // Update is called once per frame - void Update() - { - calibration_state_update(false, false); + private void Update() { + CalibrationStateUpdate(false, false); } CalibrationOdysseySettings calibrationSettings; - void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) - { - - bool cancel_calibration = (enableCalibrationScene == false); + private void CalibrationStateUpdate(bool extraBtnPrev, bool extraBtnNext) { + bool cancelCalibration = (enableCalibrationScene == false); HardwareInterface.ConsoleData cData = consoleMirror.readControllerRawData(); - if (cData != null) - { - textDBP1.text = string.Format("({0},{1})", cData.P1_X_READ, cData.P1_Y_READ); - textDBP2.text = string.Format("({0},{1})", cData.P2_X_READ, cData.P2_Y_READ); + if (cData != null) { + textDBP1.text = $"({cData.P1_X_READ},{cData.P1_Y_READ})"; + textDBP2.text = $"({cData.P2_X_READ},{cData.P2_Y_READ})"; } // Again, the process of calibration is a state-machine - switch (mCalibStates) - { + switch (mCalibStates) { case CalibrationStates.NOT_STARTED: - if (enableCalibrationScene) - { + if (enableCalibrationScene) { cameraInGame.enabled = false; camera3DScene.enabled = true; // Keep a note of the time the movement started. @@ -141,6 +135,7 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) mCalibStates += 1; } + break; case CalibrationStates.ANIMMOTION_START: mTextInstruction.text = "Calibrate your Odyssey Input"; @@ -151,13 +146,12 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) progress = cameraTimeCurve.Evaluate(distCovered / mAnimJourneyLength); // Set our position as a fraction of the distance between the start-end. - camera3DScene.transform.position = Vector3.Slerp( - cameraInGame.transform.position, m3DSceneCameraPosition, progress); - camera3DScene.transform.rotation = Quaternion.Slerp( - cameraInGame.transform.rotation, m3DSceneCameraRotation, progress); + camera3DScene.transform.position = + Vector3.Slerp(cameraInGame.transform.position, m3DSceneCameraPosition, progress); + camera3DScene.transform.rotation = + Quaternion.Slerp(cameraInGame.transform.rotation, m3DSceneCameraRotation, progress); - if (progress >= 1) - { + if (progress >= 1) { mCalibStates += 1; mPlayerBlinkAnimation.enabled = true; } @@ -175,12 +169,11 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) case CalibrationStates.CALIB_LEFT_TOP: mTextInstruction.text = "Please use the controller on Odessey, \n" + - "move player 1 to the upper-left corner\n" + - "Hit RESET on the controller to continue...\n" + - "(1/4)"; + "move player 1 to the upper-left corner\n" + + "Hit RESET on the controller to continue...\n" + + "(1/4)"; - if (cancel_calibration) - { + if (cancelCalibration) { // Allow go back to the game scene any time // Keep a note of the time the movement started. mAnimStartTime = Time.time; @@ -191,13 +184,14 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) // Move the p1 to top-left corner p1.position = new Vector2(consoleMirror._calib_unity_x_left, consoleMirror._calib_unity_y_top); - if (Input.GetKeyUp(KeyCode.Return) || extra_btn_next) { + if (Input.GetKeyUp(KeyCode.Return) || extraBtnNext) { // Save the calibration value _calib_votage_x_left = cData.P1_X_READ; _calib_votage_y_top = cData.P1_Y_READ; mCalibStates++; - } else if (extra_btn_prev) { + } + else if (extraBtnPrev) { exit_scene(); } @@ -207,11 +201,10 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) case CalibrationStates.CALIB_RIGHT_BOTTOM: mTextInstruction.text = "Now, move player 1 to the LOWER-RIGHT corner\n" + - "Hit RESET on the controller to continue...\n" + - "(2/4)"; + "Hit RESET on the controller to continue...\n" + + "(2/4)"; - if (cancel_calibration) - { + if (cancelCalibration) { // Keep a note of the time the movement started. mAnimStartTime = Time.time; mCalibStates = CalibrationStates.ANIMATION_FINISH; @@ -220,8 +213,7 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) p1.position = new Vector2(consoleMirror._calib_unity_x_right, consoleMirror._calib_unity_y_bottom); - if (Input.GetKeyUp(KeyCode.Return) || extra_btn_next) - { + if (Input.GetKeyUp(KeyCode.Return) || extraBtnNext) { // Save the calibration value _calib_votage_x_right = cData.P1_X_READ; _calib_votage_y_bottom = cData.P1_Y_READ; @@ -229,8 +221,7 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) mCalibStates++; textLeft.text = textRight.text = ""; } - else if (extra_btn_prev) - { + else if (extraBtnPrev) { mCalibStates--; } @@ -247,44 +238,39 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) mCalibStates = CalibrationStates.CALIB_WRITE_LEFT_TOP; // Set the p1 to an initial position (so that has some visibility on the screen) - p1.position = new Vector2( - (consoleMirror._calib_unity_x_right + consoleMirror._calib_unity_x_left) / 2, - (consoleMirror._calib_unity_y_bottom + consoleMirror._calib_unity_y_top) / 2 - ); + p1.position = new Vector2((consoleMirror._calib_unity_x_right + consoleMirror._calib_unity_x_left) / 2, + (consoleMirror._calib_unity_y_bottom + consoleMirror._calib_unity_y_top) / 2); break; case CalibrationStates.CALIB_WRITE_LEFT_TOP: - mTextInstruction.text = "Use the controller on HAL," + - "move the player to the upper-left corner\n" + - "Hit RESET on the controller to continue...\n" + - "(3/4)"; + mTextInstruction.text = "Use the controller on HAL," + "move the player to the upper-left corner\n" + + "Hit RESET on the controller to continue...\n" + + "(3/4)"; - if (cancel_calibration) - { + if (cancelCalibration) { // Keep a note of the time the movement started. mAnimStartTime = Time.time; mCalibStates = CalibrationStates.ANIMATION_FINISH; break; } - if (Input.GetKeyUp(KeyCode.Return) || extra_btn_next) - { + if (Input.GetKeyUp(KeyCode.Return) || extraBtnNext) { // Save the calibration value - _calib_write_votage_x_left = consoleMirror.xConvertToConsole(p1.position.x); - _calib_write_votage_y_top = consoleMirror.xConvertToConsole(p1.position.y); + var position = p1.position; + _calib_write_votage_x_left = consoleMirror.xConvertToConsole(position.x); + _calib_write_votage_y_top = consoleMirror.xConvertToConsole(position.y); mCalibStates++; textLeft.text = textRight.text = ""; // Again, set the p1 to an initial position for visibility - p1.position = new Vector2( - (consoleMirror._calib_unity_x_right + consoleMirror._calib_unity_x_left) / 2, - (consoleMirror._calib_unity_y_bottom + consoleMirror._calib_unity_y_top) / 2 - ); + position = new Vector2((consoleMirror._calib_unity_x_right + consoleMirror._calib_unity_x_left) / 2, + (consoleMirror._calib_unity_y_bottom + consoleMirror._calib_unity_y_top) / + 2); + p1.position = position; } - else if (extra_btn_prev) - { + else if (extraBtnPrev) { mCalibStates = CalibrationStates.PRE_CALIB; } @@ -293,29 +279,27 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) case CalibrationStates.CALIB_WRITE_RIGHT_BOTTOM: mTextInstruction.text = "Now, use the controller on HAL," + - "move the player to the lower-right corner\n" + - "Hit RESET on the controller to continue...\n" + - "(4/4)"; + "move the player to the lower-right corner\n" + + "Hit RESET on the controller to continue...\n" + + "(4/4)"; - if (cancel_calibration) - { + if (cancelCalibration) { // Keep a note of the time the movement started. mAnimStartTime = Time.time; mCalibStates = CalibrationStates.ANIMATION_FINISH; break; } - if (Input.GetKeyUp(KeyCode.Return) || extra_btn_next) - { + if (Input.GetKeyUp(KeyCode.Return) || extraBtnNext) { // Save the calibration value - _calib_write_votage_x_right = consoleMirror.xConvertToConsole(p1.position.x); - _calib_write_votage_y_bottom = consoleMirror.xConvertToConsole(p1.position.y); + var position = p1.position; + _calib_write_votage_x_right = consoleMirror.xConvertToConsole(position.x); + _calib_write_votage_y_bottom = consoleMirror.xConvertToConsole(position.y); mCalibStates++; textLeft.text = textRight.text = ""; } - else if (extra_btn_prev) - { + else if (extraBtnPrev) { mCalibStates--; } @@ -324,19 +308,16 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) case CalibrationStates.CALIB_FINISH: - mTextInstruction.text = "How well does the blocks on the TV follow?\n" + - ""; + mTextInstruction.text = "How well does the blocks on the TV follow?\n" + ""; - if (cancel_calibration || extra_btn_next) - { + if (cancelCalibration || extraBtnNext) { // Keep a note of the time the movement started. mTextInstruction.text = ""; mAnimStartTime = Time.time; mCalibStates = CalibrationStates.ANIMATION_FINISH; } - if (extra_btn_next) - { + if (extraBtnNext) { // On confirm, write the calibration data consoleMirror._calib_votage_x_left = _calib_votage_x_left; consoleMirror._calib_votage_x_right = _calib_votage_x_right; @@ -350,8 +331,7 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) // restore the player target speed p1.GetComponent().speed = mOriginalPlayerTargetSpeed; } - else if (extra_btn_prev) - { + else if (extraBtnPrev) { mCalibStates--; } @@ -364,13 +344,12 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) progress = cameraTimeCurve.Evaluate(distCovered / mAnimJourneyLength); // Set our position as a fraction of the distance between the start-end. - camera3DScene.transform.position = Vector3.Slerp( - m3DSceneCameraPosition, cameraInGame.transform.position, progress); - camera3DScene.transform.rotation = Quaternion.Slerp( - m3DSceneCameraRotation, cameraInGame.transform.rotation, progress); + camera3DScene.transform.position = + Vector3.Slerp(m3DSceneCameraPosition, cameraInGame.transform.position, progress); + camera3DScene.transform.rotation = + Quaternion.Slerp(m3DSceneCameraRotation, cameraInGame.transform.rotation, progress); - if (progress >= 1) - { + if (progress >= 1) { cameraInGame.enabled = true; camera3DScene.enabled = false; @@ -382,11 +361,12 @@ void calibration_state_update(bool extra_btn_prev, bool extra_btn_next) } break; + default: + throw new ArgumentOutOfRangeException(); } } - void update_camera_look() - { + void update_camera_look() { mCamLookRotation.y += Input.GetAxis("Mouse X"); mCamLookRotation.x += -Input.GetAxis("Mouse Y"); mCamLookRotation.y = Mathf.Clamp(mCamLookRotation.y, -1.5f, 1.5f); @@ -394,21 +374,18 @@ void update_camera_look() camera3DScene.transform.localEulerAngles = mCamLookRotation * CamLookRate; } - public void on_prev_button() - { - calibration_state_update(true, false); + public void on_prev_button() { + CalibrationStateUpdate(true, false); } - - public void on_next_button() - { - calibration_state_update(false, true); + + public void on_next_button() { + CalibrationStateUpdate(false, true); } /// /// Exit the calibration scene /// - void exit_scene() - { + void exit_scene() { // Go back to the main menu UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenu"); } diff --git a/OdysseyNow/Assets/ModeDirector.cs b/OdysseyNow/Assets/ModeDirector.cs index 6a68ce2..770fece 100644 --- a/OdysseyNow/Assets/ModeDirector.cs +++ b/OdysseyNow/Assets/ModeDirector.cs @@ -1,113 +1,106 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using CardDirection; using UnityEngine; using UnityEngine.AI; using UnityEngine.EventSystems; +using UnityEngine.Serialization; -public class ModeDirector : MonoBehaviour -{ - public GameObject go_calibration; - public GameObject go_AI; +public class ModeDirector : MonoBehaviour { + public GameObject calibration; + public GameObject AI; - void Awake() - { + private void Awake() { Debug.Log(PlayerPrefs.GetInt("ai1")); Debug.Log(PlayerPrefs.GetInt("ai2")); Debug.Log(PlayerPrefs.GetString("game")); } // Start is called before the first frame update - void Start() - { + private void Start() { //if (localInputManager.isdirty) //{ // Enable calibration - if (LocalInputManager.instance == null) - { - switch(PlayerPrefs.GetString("game")){ + if (LocalInputManager.instance == null) { + switch (PlayerPrefs.GetString("game")) { case "Cat and Mouse": - go_calibration.GetComponent() - .afterCalibration - .AddListener(startCatAndMouse); - break; + calibration.GetComponent().afterCalibration.AddListener(StartCatAndMouse); + break; case "Super Cat and Mouse": - break; + break; case "Haunted House": - break; + break; case "Zoo Breakout": - break; + break; case "Football: Running": - break; + break; } // fixme // if p1 is ai, don't read calibration - if(PlayerPrefs.GetInt("ai1") != -1) - go_calibration.GetComponent().p1_read = false; + if (PlayerPrefs.GetInt("ai1") != -1) + calibration.GetComponent().p1_read = false; // if p2 is ai, don't read calibration - if(PlayerPrefs.GetInt("ai2") != -1) - go_calibration.GetComponent().p2_read = false; + if (PlayerPrefs.GetInt("ai2") != -1) + calibration.GetComponent().p2_read = false; StartCalibration(); return; } - if (LocalInputManager.instance.p1Scheme == LocalInputManager.ControlScheme.AI) - { - go_calibration.GetComponent() - .afterCalibration - .AddListener(startCatAndMouse); - } - if (LocalInputManager.instance.p1Scheme == LocalInputManager.ControlScheme.OriginalConsole) - { - go_calibration.GetComponent().p1_read = true; + switch (LocalInputManager.instance.p1Scheme) { + case LocalInputManager.ControlScheme.AI: + calibration.GetComponent().afterCalibration.AddListener(StartCatAndMouse); + break; + case LocalInputManager.ControlScheme.OriginalConsole: + calibration.GetComponent().p1_read = true; + break; + case LocalInputManager.ControlScheme.Keyboard: + break; + case LocalInputManager.ControlScheme.Traditional: + break; + case LocalInputManager.ControlScheme.OdysseyCon: + break; + case LocalInputManager.ControlScheme.OdysseyConLegacy: + break; + default: + throw new ArgumentOutOfRangeException(); } - if (LocalInputManager.instance.p2Scheme == LocalInputManager.ControlScheme.OriginalConsole) - { - go_calibration.GetComponent().p2_read = true; + + if (LocalInputManager.instance.p2Scheme == LocalInputManager.ControlScheme.OriginalConsole) { + calibration.GetComponent().p2_read = true; } StartCalibration(); - - //} - } - - // Update is called once per frame - void Update() - { - } - public void startCatAndMouse() - { - go_calibration.SetActive(false); + private void StartCatAndMouse() { + calibration.SetActive(false); GameObject p1 = ElementSettings.FindFromNameAndTag("PlayerTarget", "Player1"); GameObject p2 = ElementSettings.FindFromNameAndTag("PlayerTarget", "Player2"); int player1AI = PlayerPrefs.GetInt("ai1"); int player2AI = PlayerPrefs.GetInt("ai2"); - if(player1AI != -1) { + if (player1AI != -1) { p1.GetComponent().enabled = true; p1.GetComponent().enabled = true; p1.GetComponent().level = player1AI; } - if(player2AI != -1) { + + if (player2AI != -1) { p2.GetComponent().enabled = true; p2.GetComponent().enabled = true; p2.GetComponent().level = player2AI; } - go_AI.SetActive(true); - } - public void StartCalibration() - { - go_AI.SetActive(false); - go_calibration.SetActive(true); + AI.SetActive(true); } - public void StartGame_2p() - { - + private void StartCalibration() { + AI.SetActive(false); + calibration.SetActive(true); } + + public void StartGame_2p() { } } diff --git a/OdysseyNow/Assets/Scenes/MainMenu.unity b/OdysseyNow/Assets/Scenes/MainMenu.unity index ecdb872..c6d0592 100644 --- a/OdysseyNow/Assets/Scenes/MainMenu.unity +++ b/OdysseyNow/Assets/Scenes/MainMenu.unity @@ -13925,7 +13925,7 @@ MonoBehaviour: m_PersistentCalls: m_Calls: - m_Target: {fileID: 1707679380} - m_MethodName: loadCalibrationScene + m_MethodName: LoadCalibrationScene m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} diff --git a/OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/cat/CatAI.cs b/OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/cat/CatAI.cs index 9d4f921..c63af48 100644 --- a/OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/cat/CatAI.cs +++ b/OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/cat/CatAI.cs @@ -1,20 +1,16 @@ -using System.Collections; -using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; -public class CatAI : MonoBehaviour -{ - +public class CatAI : MonoBehaviour { private float nextActionTime = 0.0f; private float period = 2f; - public GameObject target; private NavMeshAgent agent; + + public GameObject target; public int level; // Start is called before the first frame update - void Start() - { + private void Start() { // Agent tend to rotate game object, that can be // undesirable agent = GetComponent(); @@ -23,26 +19,28 @@ void Start() } // Update is called once per frame - void Update() - { - if ( ! agent.enabled) { return; } + private void Update() { + if (!agent.enabled) { + return; + } - if ((transform.position - target.transform.position).magnitude < 1) - { + if ((transform.position - target.transform.position).magnitude < 1) { Debug.Log("Cat has the mouse."); } - switch(level){ + + switch (level) { case 1: - if (Time.time > nextActionTime ) { - nextActionTime += Time.time + period; - agent.SetDestination(new Vector3(Random.Range(-4, 4), Random.Range(-4, 4), 0)); - } - break; + if (Time.time > nextActionTime) { + nextActionTime += Time.time + period; + agent.SetDestination(new Vector3(Random.Range(-4, 4), Random.Range(-4, 4), 0)); + } + + break; case 2: - break; + break; case 3: - agent.SetDestination(target.transform.position); - break; + agent.SetDestination(target.transform.position); + break; } } } diff --git a/OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/mouse/MouseAI.cs b/OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/mouse/MouseAI.cs index 2563fdb..7e81087 100644 --- a/OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/mouse/MouseAI.cs +++ b/OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/mouse/MouseAI.cs @@ -1,18 +1,14 @@ -using System.Collections; -using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; -public class MouseAI : MonoBehaviour -{ +public class MouseAI : MonoBehaviour { + private NavMeshAgent agent; public Transform target; - private NavMeshAgent agent; public int level; // Start is called before the first frame update - private void Start() - { + private void Start() { // Agent tend to rotate game object, that can be // undesirable agent = GetComponent(); @@ -21,22 +17,23 @@ private void Start() } // Update is called once per frame - private void Update() - { - if ( ! agent.enabled) { return; } + private void Update() { + if (!agent.enabled) { + return; + } - if ((transform.position - target.position).magnitude < 1) - { + if ((transform.position - target.position).magnitude < 1) { Debug.Log("Mouse has the cheese"); } - switch(level){ + + switch (level) { case 1: - break; + break; case 2: - agent.SetDestination(target.position); - break; + agent.SetDestination(target.position); + break; case 3: - break; + break; } } } diff --git a/OdysseyNow/Assets/Scripts/Graphics/CalibrationButtonBehaviour.cs b/OdysseyNow/Assets/Scripts/Graphics/CalibrationButtonBehaviour.cs index c4a701d..1594622 100644 --- a/OdysseyNow/Assets/Scripts/Graphics/CalibrationButtonBehaviour.cs +++ b/OdysseyNow/Assets/Scripts/Graphics/CalibrationButtonBehaviour.cs @@ -3,21 +3,8 @@ using UnityEngine; using UnityEngine.SceneManagement; -public class CalibrationButtonBehaviour : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } - - public void loadCalibrationScene() { +public class CalibrationButtonBehaviour : MonoBehaviour { + public void LoadCalibrationScene() { SceneManager.LoadScene("Calibration"); } } diff --git a/OdysseyNow/Assets/Scripts/Graphics/HoverText.cs b/OdysseyNow/Assets/Scripts/Graphics/HoverText.cs index 9ed8ba4..a4fca14 100644 --- a/OdysseyNow/Assets/Scripts/Graphics/HoverText.cs +++ b/OdysseyNow/Assets/Scripts/Graphics/HoverText.cs @@ -2,55 +2,46 @@ using System.Collections.Generic; using UnityEngine; -namespace Graphics -{ +namespace Graphics { /// /// Handles the slight moving HAL logo in the main menu. /// This isn't complicated enough to warrent additional documentation - it works! /// - public class HoverText : MonoBehaviour - { + public class HoverText : MonoBehaviour { float startY; public float yRange; public float speed; bool goUp; // Start is called before the first frame update - void Start() - { + private void Start() { startY = transform.position.y; goUp = true; } // Update is called once per frame - void Update() - { + private void Update() { float tempSpeed; - if (goUp) - { + if (goUp) { tempSpeed = speed * ((startY + yRange) - transform.position.y); if (tempSpeed <= speed * 0.4f) tempSpeed = speed * 0.4f; transform.Translate(tempSpeed * transform.up); - if (transform.position.y > (startY + yRange)) - { + if (transform.position.y > (startY + yRange)) { goUp = false; } } - else - { + else { tempSpeed = speed * (transform.position.y - (startY - yRange)); if (tempSpeed <= speed * 0.4f) tempSpeed = speed * 0.4f; transform.Translate(-tempSpeed * transform.up); - if (transform.position.y < (startY - yRange)) - { + if (transform.position.y < (startY - yRange)) { goUp = true; } } } } - } diff --git a/OdysseyNow/Assets/Scripts/Graphics/MenuButtonBehavior.cs b/OdysseyNow/Assets/Scripts/Graphics/MenuButtonBehavior.cs index 8994515..0194fb1 100644 --- a/OdysseyNow/Assets/Scripts/Graphics/MenuButtonBehavior.cs +++ b/OdysseyNow/Assets/Scripts/Graphics/MenuButtonBehavior.cs @@ -4,108 +4,119 @@ using UnityEngine.SceneManagement; using UnityEngine.UI; -namespace Graphics -{ +namespace Graphics { /// /// Behavior of all menu buttons in the main menu (and pause menus). /// - public class MenuButtonBehavior : MonoBehaviour - { + public class MenuButtonBehavior : MonoBehaviour { // another UI object that will replace this element on screen, if clicked public GameObject otherMenu; + // another UI object that will replace this element on screen, if clicked public GameObject gameSelect; + // toggle that determines menu control flow public Toggle aiToggle; + // toggle that determines menu control flow public Toggle connectToggle; + private Transform _parent; + /// - /// On start, set button click lisstener. + /// On start, set button click listener. /// - void Start() - { + private void Start() { gameObject.GetComponent