From 1aa9048c40df48e1fad894331803f91414dc7c7a Mon Sep 17 00:00:00 2001 From: Valdimir Date: Sun, 29 Sep 2024 23:33:11 +0300 Subject: [PATCH] ui Changes --- Assets/Prefabs/Indoor/House.prefab | 4 +- Assets/Prefabs/Indoor/Mini market.prefab | 6 ++ Assets/Prefabs/UI/RadialMenuItem.prefab | 8 +-- Assets/Prefabs/UI/button.prefab | 2 +- Assets/Scenes/City.unity | 58 ++----------------- Assets/Scenes/MainScene.unity | 19 +++++- Assets/Scriptables/Indoor/Mini market.asset | 2 +- Assets/Scripts/Managers/BuildingManager.cs | 22 ++++--- Assets/Scripts/Managers/CameraSystem.cs | 3 +- Assets/Scripts/Managers/InGameMouseHandler.cs | 3 +- .../Managers/InputSystem/InputActions.cs | 11 ++++ .../InputSystem/InputActions.inputactions | 11 ++++ Assets/Scripts/Managers/SceneManager.cs | 3 +- Assets/Scripts/UIElements/RadialMenuItem.cs | 2 +- Assets/UI/Scripts.meta | 8 +++ Assets/UI/Scripts/TopPanel.cs | 50 ++++++++++++++++ Assets/UI/Scripts/TopPanel.cs.meta | 2 + Assets/UI/{ => Scripts}/progressBar.cs | 0 Assets/UI/{ => Scripts}/progressBar.cs.meta | 0 Assets/UI/buttonElement.uxml | 6 ++ Assets/UI/buttonElement.uxml.meta | 10 ++++ Assets/UI/inGameHud.uxml | 8 +-- 22 files changed, 156 insertions(+), 82 deletions(-) create mode 100644 Assets/UI/Scripts.meta create mode 100644 Assets/UI/Scripts/TopPanel.cs create mode 100644 Assets/UI/Scripts/TopPanel.cs.meta rename Assets/UI/{ => Scripts}/progressBar.cs (100%) rename Assets/UI/{ => Scripts}/progressBar.cs.meta (100%) create mode 100644 Assets/UI/buttonElement.uxml create mode 100644 Assets/UI/buttonElement.uxml.meta diff --git a/Assets/Prefabs/Indoor/House.prefab b/Assets/Prefabs/Indoor/House.prefab index 040f95fc..f2af68f3 100644 --- a/Assets/Prefabs/Indoor/House.prefab +++ b/Assets/Prefabs/Indoor/House.prefab @@ -2644,7 +2644,7 @@ PrefabInstance: - target: {fileID: 1626998783868662017, guid: 5a6b5585f9fba3340a6f0d4893b46d48, type: 3} propertyPath: m_LocalPosition.z - value: -1.245 + value: -1.331 objectReference: {fileID: 0} - target: {fileID: 1626998783868662017, guid: 5a6b5585f9fba3340a6f0d4893b46d48, type: 3} @@ -3696,7 +3696,7 @@ PrefabInstance: - target: {fileID: 168138393772344589, guid: 910e671451e1bf94e9bba00c3809c94a, type: 3} propertyPath: m_LocalPosition.x - value: 1.376 + value: 0.919 objectReference: {fileID: 0} - target: {fileID: 168138393772344589, guid: 910e671451e1bf94e9bba00c3809c94a, type: 3} diff --git a/Assets/Prefabs/Indoor/Mini market.prefab b/Assets/Prefabs/Indoor/Mini market.prefab index b536a351..714b8da3 100644 --- a/Assets/Prefabs/Indoor/Mini market.prefab +++ b/Assets/Prefabs/Indoor/Mini market.prefab @@ -16104,6 +16104,12 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 5411692448278503736} m_Modifications: + - target: {fileID: 551020291880888998, guid: 1a6eb89c878bfd64babad29d36df197b, + type: 3} + propertyPath: BuildingInfo + value: + objectReference: {fileID: 11400000, guid: 9decf03291be4634888cf5440dd0b485, + type: 2} - target: {fileID: 551020291880888998, guid: 1a6eb89c878bfd64babad29d36df197b, type: 3} propertyPath: _spawnPointInSceneName diff --git a/Assets/Prefabs/UI/RadialMenuItem.prefab b/Assets/Prefabs/UI/RadialMenuItem.prefab index d9f1989a..989303a6 100644 --- a/Assets/Prefabs/UI/RadialMenuItem.prefab +++ b/Assets/Prefabs/UI/RadialMenuItem.prefab @@ -37,7 +37,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 250, y: 50} + m_SizeDelta: {x: 150, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &7523537103864575754 CanvasRenderer: @@ -76,7 +76,7 @@ MonoBehaviour: m_FillClockwise: 1 m_FillOrigin: 0 m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 + m_PixelsPerUnitMultiplier: 0.4 --- !u!114 &8504314472782682815 MonoBehaviour: m_ObjectHideFlags: 0 @@ -225,8 +225,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 40 - m_fontSizeBase: 40 + m_fontSize: 20 + m_fontSizeBase: 20 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 diff --git a/Assets/Prefabs/UI/button.prefab b/Assets/Prefabs/UI/button.prefab index 23d9ab8c..71a750a6 100644 --- a/Assets/Prefabs/UI/button.prefab +++ b/Assets/Prefabs/UI/button.prefab @@ -36,7 +36,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} m_AnchoredPosition: {x: 25.22, y: -18.965} - m_SizeDelta: {x: 0, y: 0} + m_SizeDelta: {x: 40.44, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &3806516703089782043 CanvasRenderer: diff --git a/Assets/Scenes/City.unity b/Assets/Scenes/City.unity index 185a7e65..d4a177b8 100644 --- a/Assets/Scenes/City.unity +++ b/Assets/Scenes/City.unity @@ -1451,7 +1451,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 364890571} serializedVersion: 2 - m_LocalRotation: {x: 0.3826835, y: 0.000000022481233, z: -0.000000009312033, w: 0.92387956} + m_LocalRotation: {x: 0.3826835, y: 0.000000022481231, z: -0.000000009312033, w: 0.9238795} m_LocalPosition: {x: 29.11, y: 5, z: -5} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -2223,7 +2223,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 663697246} serializedVersion: 2 - m_LocalRotation: {x: 0.3826835, y: 0.000000022481233, z: -0.000000009312033, w: 0.92387956} + m_LocalRotation: {x: 0.3826835, y: 0.000000022481231, z: -0.000000009312033, w: 0.9238795} m_LocalPosition: {x: 29.11, y: 5, z: -5} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -2706,55 +2706,6 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 0.089999996, y: 0.089999996, z: 0.0016000008} m_Center: {x: 0.00000023841858, y: 0, z: 0.0008000004} ---- !u!1 &856744744 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 856744746} - - component: {fileID: 856744745} - m_Layer: 5 - m_Name: UIDocument - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &856744745 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 856744744} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0} - m_Name: - m_EditorClassIdentifier: - m_PanelSettings: {fileID: 11400000, guid: 91d76c20b085bbf4d8cd8ec60bb56af3, type: 2} - m_ParentUI: {fileID: 0} - sourceAsset: {fileID: 9197481963319205126, guid: f56df0e5e8c60e241a519804b41d2e2d, - type: 3} - m_SortingOrder: 0 ---- !u!4 &856744746 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 856744744} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &861905856 stripped GameObject: m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 06629d5387e888e408bfe1c0a360997a, @@ -5594,7 +5545,7 @@ RectTransform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4333559282153253760} m_LocalRotation: {x: 0, y: -0.7071068, z: 0, w: 0.7071068} - m_LocalPosition: {x: 0, y: 0, z: 0.19} + m_LocalPosition: {x: 0, y: 0, z: -0.15} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -5616,7 +5567,7 @@ GameObject: - component: {fileID: 1595984949156300432} - component: {fileID: 4333559282153253761} m_Layer: 0 - m_Name: InteractPoint + m_Name: Interactable m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -5684,4 +5635,3 @@ SceneRoots: - {fileID: 276784286} - {fileID: 100471662} - {fileID: 913350237} - - {fileID: 856744746} diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index 08467b8e..84731085 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -490,7 +490,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 580921796} serializedVersion: 2 - m_LocalRotation: {x: 0.3826835, y: 0.000000022481233, z: -0.000000009312033, w: 0.92387956} + m_LocalRotation: {x: 0.3826835, y: 0.000000022481231, z: -0.000000009312033, w: 0.9238795} m_LocalPosition: {x: 29.11, y: 5, z: -5} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -808,8 +808,9 @@ GameObject: m_Component: - component: {fileID: 715788843} - component: {fileID: 715788844} + - component: {fileID: 715788845} m_Layer: 5 - m_Name: UIDocument + m_Name: InGameHud m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -847,6 +848,18 @@ MonoBehaviour: sourceAsset: {fileID: 9197481963319205126, guid: f56df0e5e8c60e241a519804b41d2e2d, type: 3} m_SortingOrder: 0 +--- !u!114 &715788845 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 715788842} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b12a25de2b34933489e52900d32221dd, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &856666918 GameObject: m_ObjectHideFlags: 0 @@ -1852,7 +1865,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1758781746} serializedVersion: 2 - m_LocalRotation: {x: 0.3826835, y: 0.000000022481233, z: -0.000000009312033, w: 0.92387956} + m_LocalRotation: {x: 0.3826835, y: 0.000000022481231, z: -0.000000009312033, w: 0.9238795} m_LocalPosition: {x: 29.11, y: 5, z: -5} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 diff --git a/Assets/Scriptables/Indoor/Mini market.asset b/Assets/Scriptables/Indoor/Mini market.asset index 91cfc7d5..c3c80053 100644 --- a/Assets/Scriptables/Indoor/Mini market.asset +++ b/Assets/Scriptables/Indoor/Mini market.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5fd44e1aaa501ac4c8f210861aa1b08c, type: 3} m_Name: Mini market m_EditorClassIdentifier: - BuidingName: Mini market + BuidingName: MiniMarket Address: Mini market SpawnPointInSceneName: Door Prefab: {fileID: 785642118100129014, guid: 20b968bb62f7c9d49a2a731d06ca7224, type: 3} diff --git a/Assets/Scripts/Managers/BuildingManager.cs b/Assets/Scripts/Managers/BuildingManager.cs index c4500b76..fb7b4bf9 100644 --- a/Assets/Scripts/Managers/BuildingManager.cs +++ b/Assets/Scripts/Managers/BuildingManager.cs @@ -10,20 +10,21 @@ public class BuildingManager : MonoBehaviour public void BuildingInteract(IndoorSO indoor) { - IsOpen = CheckIsOpen(indoor.OpenHoursFrom, indoor.OpenHoursTo); + if (!IsInside) { EnterBuilding(indoor); } else { - ExitBuilding(); + ExitBuilding(indoor); } } private void EnterBuilding(IndoorSO indoor) { - if(IsOpen) + IsOpen = CheckIsOpen(indoor?.OpenHoursFrom, indoor?.OpenHoursTo); + if (IsOpen) { Indoor = indoor; IsInside = true; @@ -31,14 +32,19 @@ public class BuildingManager : MonoBehaviour } } - public void ExitBuilding() + public void ExitBuilding(IndoorSO indoor) { - GameManager.Instance.Scene.Change("city"); + IsInside = false; + GameManager.Instance.Scene.Change("city",indoor.BuidingName); } - private bool CheckIsOpen(int from, int to) + private bool CheckIsOpen(int? from, int? to) { - return GameManager.Instance.Time.CurrentTime.Hours >= from - && GameManager.Instance.Time.CurrentTime.Hours <= to; + if (from.HasValue && to.HasValue) + { + return GameManager.Instance.Time.CurrentTime.Hours >= from + && GameManager.Instance.Time.CurrentTime.Hours <= to; + } + return true; } } diff --git a/Assets/Scripts/Managers/CameraSystem.cs b/Assets/Scripts/Managers/CameraSystem.cs index 524c28c0..a19d8788 100644 --- a/Assets/Scripts/Managers/CameraSystem.cs +++ b/Assets/Scripts/Managers/CameraSystem.cs @@ -145,8 +145,7 @@ public class CameraSystem : MonoBehaviour private void HandleCameraMovement(Vector2 inputDir) { - - Vector3 moveDir = transform.forward * -inputDir.y + transform.right * -inputDir.x; + Vector3 moveDir = transform.forward * inputDir.y + transform.right * inputDir.x; transform.position += moveDir * _moveSpeed * Time.deltaTime; } diff --git a/Assets/Scripts/Managers/InGameMouseHandler.cs b/Assets/Scripts/Managers/InGameMouseHandler.cs index 76df35ee..03bb9fd6 100644 --- a/Assets/Scripts/Managers/InGameMouseHandler.cs +++ b/Assets/Scripts/Managers/InGameMouseHandler.cs @@ -51,7 +51,8 @@ public class InGameMouseHandler : UnityEngine.Object public void Update() { - if (Mouse.current.leftButton.wasPressedThisFrame) + + if (GameManager.Instance.Input.PlayerAction.PointClick.WasPressedThisFrame()) { ClickToMove(!EventSystem.current.IsPointerOverGameObject()); } diff --git a/Assets/Scripts/Managers/InputSystem/InputActions.cs b/Assets/Scripts/Managers/InputSystem/InputActions.cs index b3bbf158..1d3f6b9d 100644 --- a/Assets/Scripts/Managers/InputSystem/InputActions.cs +++ b/Assets/Scripts/Managers/InputSystem/InputActions.cs @@ -49,6 +49,17 @@ public partial class @InputActions: IInputActionCollection2, IDisposable ""action"": ""PointClick"", ""isComposite"": false, ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""25a11c76-9acb-4544-bf8f-121962b3bf0b"", + ""path"": ""/buttonSouth"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""PointClick"", + ""isComposite"": false, + ""isPartOfComposite"": false } ] }, diff --git a/Assets/Scripts/Managers/InputSystem/InputActions.inputactions b/Assets/Scripts/Managers/InputSystem/InputActions.inputactions index 0ede718a..fc8c8499 100644 --- a/Assets/Scripts/Managers/InputSystem/InputActions.inputactions +++ b/Assets/Scripts/Managers/InputSystem/InputActions.inputactions @@ -26,6 +26,17 @@ "action": "PointClick", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "25a11c76-9acb-4544-bf8f-121962b3bf0b", + "path": "/buttonSouth", + "interactions": "", + "processors": "", + "groups": "", + "action": "PointClick", + "isComposite": false, + "isPartOfComposite": false } ] }, diff --git a/Assets/Scripts/Managers/SceneManager.cs b/Assets/Scripts/Managers/SceneManager.cs index dd7b282d..994fe34d 100644 --- a/Assets/Scripts/Managers/SceneManager.cs +++ b/Assets/Scripts/Managers/SceneManager.cs @@ -9,8 +9,9 @@ public class SceneManager UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneManager_sceneLoaded; } - public void Change(string sceneName) + public void Change(string sceneName,string spawnName= "DefaultStartPoint") { + _spawnLocationName = spawnName; UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName); } diff --git a/Assets/Scripts/UIElements/RadialMenuItem.cs b/Assets/Scripts/UIElements/RadialMenuItem.cs index daeaa4c6..58b1c21d 100644 --- a/Assets/Scripts/UIElements/RadialMenuItem.cs +++ b/Assets/Scripts/UIElements/RadialMenuItem.cs @@ -30,7 +30,7 @@ public class RadialMenuItem : MonoBehaviour float posX = Mathf.Sin(theta); float posY = Mathf.Cos(theta); - button.transform.localPosition = new Vector3(posX, posY, 0) * 150f; + button.transform.localPosition = new Vector3(posX, posY, 0) * 50f; var textMeshPro = button.GetComponentInChildren(); if (textMeshPro != null) diff --git a/Assets/UI/Scripts.meta b/Assets/UI/Scripts.meta new file mode 100644 index 00000000..e5e29989 --- /dev/null +++ b/Assets/UI/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c347a40ca3c44cf4da082942f26de978 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI/Scripts/TopPanel.cs b/Assets/UI/Scripts/TopPanel.cs new file mode 100644 index 00000000..189ffc2d --- /dev/null +++ b/Assets/UI/Scripts/TopPanel.cs @@ -0,0 +1,50 @@ +using Assets.Scripts.Interfaces; +using UnityEngine; +using UnityEngine.UIElements; + +public class TopPanel : MonoBehaviour +{ + private Label _timeLabel; + private Label _moneyLabel; + private Label _locationLabel; + private VisualElement _energy; + private VisualElement _food; + + void Start() + { + GameManager.Instance.Time.OnMinuteChanged -= UpdateTime; + GameManager.Instance.Time.OnMinuteChanged += UpdateTime; + + var root = GetComponent().rootVisualElement; + _timeLabel = root.Q