diff --git a/ChaoticCrates/Assets/Scenes/gameScene.unity b/ChaoticCrates/Assets/Scenes/gameScene.unity index 0ca84dee96d57eed80de1d1f564377adf42bd2ec..643c114d70cdab28359a49c3062bb0ccdad4a324 100644 --- a/ChaoticCrates/Assets/Scenes/gameScene.unity +++ b/ChaoticCrates/Assets/Scenes/gameScene.unity @@ -78804,11 +78804,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 50b66d1379fa44e1855e47e5ca0e3eb4, type: 3} m_Name: m_EditorClassIdentifier: + zoomChange: 50 + smoothChange: 0.7 + minSize: 4 + maxSize: 17 cameraDragging: 0 - outerLeftx: -10 - outerRightx: 10 - outerLefty: -10 - outerRighty: 10 --- !u!114 &875563103 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/ChaoticCrates/Assets/Scripts/GameEventSystem/GameEventSystem.cs b/ChaoticCrates/Assets/Scripts/GameEventSystem/GameEventSystem.cs index c853fb57c9f53aff0e28e028732b7a8acb61d99a..14811b8cfd7c495adfee6a6ff046a8bada7ed5b6 100644 --- a/ChaoticCrates/Assets/Scripts/GameEventSystem/GameEventSystem.cs +++ b/ChaoticCrates/Assets/Scripts/GameEventSystem/GameEventSystem.cs @@ -41,4 +41,11 @@ public static class GameEventSystem { SentAction?.Invoke(obj,valid); } -} + + public static event Action CameraPosition; + + public static void OnCameraPosition() + { + CameraPosition?.Invoke(); + } +} \ No newline at end of file diff --git a/ChaoticCrates/Assets/Scripts/Logic/AudioManager.cs b/ChaoticCrates/Assets/Scripts/Logic/AudioManager.cs index 03fae58b45c503f15236214a9e4cf5df92549d82..e44c429c29e20f4a489527dd2250ab1ce220a1bd 100644 --- a/ChaoticCrates/Assets/Scripts/Logic/AudioManager.cs +++ b/ChaoticCrates/Assets/Scripts/Logic/AudioManager.cs @@ -36,7 +36,7 @@ namespace Logic private IEnumerator Start() { - while (false) + while (true) { for (int i = 0; i < playlist.Length; i++) { diff --git a/ChaoticCrates/Assets/Scripts/Logic/MapAndMovement/MapManager.cs b/ChaoticCrates/Assets/Scripts/Logic/MapAndMovement/MapManager.cs index bec40882758134c4ed601361325f50ab87694dc7..d1ba5756c42c1f2667008533b2e346b6d96c5944 100644 --- a/ChaoticCrates/Assets/Scripts/Logic/MapAndMovement/MapManager.cs +++ b/ChaoticCrates/Assets/Scripts/Logic/MapAndMovement/MapManager.cs @@ -72,7 +72,7 @@ namespace Logic.MapAndMovement private void InitGame(Dictionary<ulong, KeyValuePair<string, string>> dict) { if(!IsHost) return; - mapSize = 2 + dict.Count / 2; + mapSize = Math.Min(2 + dict.Count / 2,8); areaLight.transform.localScale = new Vector3(mapSize * 10, mapSize * 10, 1); StartCoroutine(MainCoroutineFlow(dict)); } diff --git a/ChaoticCrates/Assets/Scripts/Logic/MultiPlayer/SceneLoader.cs b/ChaoticCrates/Assets/Scripts/Logic/MultiPlayer/SceneLoader.cs index 7d802a5b06b855d1e7e6669ed9506f1b6d0395ea..5eeffa525cc9bdc7abede3895f9e69a646bd24c3 100644 --- a/ChaoticCrates/Assets/Scripts/Logic/MultiPlayer/SceneLoader.cs +++ b/ChaoticCrates/Assets/Scripts/Logic/MultiPlayer/SceneLoader.cs @@ -76,6 +76,7 @@ namespace Logic.MultiPlayer { yield return StartCoroutine(GetMapProgeress()); GameEventSystem.OnIsLoading(false); + GameEventSystem.OnCameraPosition(); GameEventSystem.OnStartCountDown(); } diff --git a/ChaoticCrates/Assets/Scripts/UI/CameraMovements/CameraDrag.cs b/ChaoticCrates/Assets/Scripts/UI/CameraMovements/CameraDrag.cs index 9d30fafe53206e6658e25b93c0946288500870fd..b61a91dffc3bc57c9e05c35eef1aceae59e8fd07 100644 --- a/ChaoticCrates/Assets/Scripts/UI/CameraMovements/CameraDrag.cs +++ b/ChaoticCrates/Assets/Scripts/UI/CameraMovements/CameraDrag.cs @@ -14,17 +14,32 @@ namespace UI.CameraMovements public class CameraDrag : MonoBehaviour { private Vector3 _dragOrigin; + public float zoomChange; + public float smoothChange; + public float minSize; + public float maxSize; + + private Camera cam; [HideInInspector] public bool cameraDragging = false; - - public float outerLeftx = -10f; - public float outerRightx = 10f; - - - public float outerLefty = -10f; - public float outerRighty = 10f; + private void Start() + { + GameEventSystem.CameraPosition += CenterCamera; + cam = GetComponent<Camera>(); + } + + + + private void CenterCamera() + { + var playerTransform = NetworkManager.Singleton.LocalClient.PlayerObject.transform; + transform.position = + new Vector3(playerTransform.position.x, + playerTransform.position.y, + transform.position.z); + } public void OnDrag(InputAction.CallbackContext callbackContext) { @@ -39,24 +54,25 @@ namespace UI.CameraMovements void Update() { - float wLeft = Screen.width * 0.2f; - float wRight = Screen.width - (Screen.width * 0.2f); - - float hUp = Screen.height * 0.2f; - float hDown = Screen.height - (Screen.height * 0.2f); if (Input.GetKeyDown(KeyCode.Space)) { if (GameNetworkManager.Instance.isSpec) { return;} - var playerTransform = NetworkManager.Singleton.LocalClient.PlayerObject.transform; - transform.position = - new Vector3(playerTransform.position.x, - playerTransform.position.y, - transform.position.z); + CenterCamera(); } - + + if (Input.mouseScrollDelta.y > 0) + { + cam.orthographicSize -= zoomChange * Time.deltaTime * smoothChange; + } + if (Input.mouseScrollDelta.y < 0) + { + cam.orthographicSize += zoomChange * Time.deltaTime * smoothChange; + } + + cam.orthographicSize = Mathf.Clamp(cam.orthographicSize, minSize, maxSize); } private void LateUpdate() @@ -67,42 +83,6 @@ namespace UI.CameraMovements Vector3 move = _dragOrigin - difference; move.z = -10; - /*if (move.x > 0f && move.y > 0f) - { - if (this.transform.position.x < outerRightx && this.transform.position.y < outerRighty) - { - transform.position = move; - } - - } - - if (move.x > 0f && move.y <= 0f) - { - if (this.transform.position.x < outerRightx && this.transform.position.y > outerLefty) - { - transform.position = move; - - } - } - - if (move.x <= 0f && move.y > 0f) - { - if (this.transform.position.x > outerLeftx && this.transform.position.y < outerRighty) - { - transform.position = move; - - } - } - - if (move.x <= 0f && move.y <= 0f) - { - if (this.transform.position.x > outerLeftx && this.transform.position.y > outerLefty) - { - transform.position = move; - - } - }*/ - transform.position = move; } } diff --git a/ChaoticCrates/Assets/Scripts/UI/CameraMovements/UI.CameraDrag.asmdef b/ChaoticCrates/Assets/Scripts/UI/CameraMovements/UI.CameraDrag.asmdef index 0c81c50864e3a19a22a804443e5c2eaddf12c52f..979e2b3649b6dfca29170971d7c681fad70ce243 100644 --- a/ChaoticCrates/Assets/Scripts/UI/CameraMovements/UI.CameraDrag.asmdef +++ b/ChaoticCrates/Assets/Scripts/UI/CameraMovements/UI.CameraDrag.asmdef @@ -6,7 +6,8 @@ "GUID:5a1586fb7f87e0c40b04ae28ae921b2a", "GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b", "GUID:1491147abca9d7d4bb7105af628b223e", - "GUID:75469ad4d38634e559750d17036d5f7c" + "GUID:75469ad4d38634e559750d17036d5f7c", + "GUID:cdc6002414c29684683b7acf4e11ca65" ], "includePlatforms": [], "excludePlatforms": [],