diff --git a/Assets/Prefabs/UI/JobItemUiTemplate.prefab b/Assets/Prefabs/UI/JobItemUiTemplate.prefab index 351a34b5..3f4d649a 100644 --- a/Assets/Prefabs/UI/JobItemUiTemplate.prefab +++ b/Assets/Prefabs/UI/JobItemUiTemplate.prefab @@ -673,4 +673,16 @@ MonoBehaviour: m_TargetGraphic: {fileID: 4798811243242991943} m_OnClick: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 4899774397145829728} + m_TargetAssemblyTypeName: JobItemUITemplate, Assembly-CSharp + m_MethodName: Click + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 diff --git a/Assets/Scenes/House.unity b/Assets/Scenes/House.unity index 015c9285..dc756472 100644 --- a/Assets/Scenes/House.unity +++ b/Assets/Scenes/House.unity @@ -4603,6 +4603,23 @@ PrefabInstance: value: objectReference: {fileID: 11400000, guid: 9dd346cdfec57ee47ad1c06a925769bb, type: 2} + - target: {fileID: 738253190946143797, guid: 88fcb1c95eeeabc479f95a580dea8152, + type: 3} + propertyPath: _jobsInfoList.Array.size + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 738253190946143797, guid: 88fcb1c95eeeabc479f95a580dea8152, + type: 3} + propertyPath: _jobsInfoList.Array.data[0] + value: + objectReference: {fileID: 11400000, guid: c7452dc6dfb2cc040a6d0e543db6b671, + type: 2} + - target: {fileID: 738253190946143797, guid: 88fcb1c95eeeabc479f95a580dea8152, + type: 3} + propertyPath: _jobsInfoList.Array.data[1] + value: + objectReference: {fileID: 11400000, guid: 4381db145ac80514c957374e20392b3b, + type: 2} - target: {fileID: 2369538501029799684, guid: 88fcb1c95eeeabc479f95a580dea8152, type: 3} propertyPath: _selectedObject diff --git a/Assets/Scripts/Helpers/Enums.cs b/Assets/Scripts/Helpers/Enums.cs index 8c7770f3..46bbb066 100644 --- a/Assets/Scripts/Helpers/Enums.cs +++ b/Assets/Scripts/Helpers/Enums.cs @@ -1,6 +1,6 @@ using System.Runtime.Serialization; -public enum JobPositions { Unemployed, Clerk, ManagerAssistaint, Manager }; +public enum JobPositions { Unemployed,Cashier, Clerk, ManagerAssistaint, Manager }; public enum PlayerStates { Awake, Sleeping, Eating,Working } public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, } public enum Tasks { Move, Interact, Rotate }; diff --git a/Assets/Scripts/InteractableObjects/CashierDesk.cs b/Assets/Scripts/InteractableObjects/CashierDesk.cs index a4c185bf..b88be1a7 100644 --- a/Assets/Scripts/InteractableObjects/CashierDesk.cs +++ b/Assets/Scripts/InteractableObjects/CashierDesk.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using UnityEngine; public class CashierDesk : BaseInteractableObject @@ -6,8 +8,8 @@ public class CashierDesk : BaseInteractableObject [SerializeField] private ContainerSO _containerSO; [SerializeField] - private JobInfoSO _jobInfo; - + private List _jobsInfoList; + private JobInfoSO _playerJob; public override void Interact(Player player) { @@ -18,11 +20,12 @@ public class CashierDesk : BaseInteractableObject } else { - // if player work here - if (player.JobPosition == _jobInfo.JobPosition) + _playerJob = _jobsInfoList.First(x => x.JobPosition == player.JobPosition); + print($"playerJob is {_playerJob}"); + if (_playerJob != null) { - UIManager.Instance.ShowTimeSliderDialog($"Work", $"Work as {_jobInfo.Description}", OnCancel, OnConfirm); - + UIManager.Instance.ShowTimeSliderDialog($"Work", $"Work as {_playerJob.Description}", OnCancel, OnConfirm); + } else { @@ -72,7 +75,7 @@ public class CashierDesk : BaseInteractableObject float _totalSalary; private void OnConfirm(TimeSpan time) { - _totalSalary = (float)(time.TotalHours * _jobInfo.Salary); + _totalSalary = (float)(time.TotalHours * _playerJob.Salary); _player.SetPlayerActing(PlayerStates.Working); TimeManager.Instance.FastForward(time); TimeManager.Instance.OnFastForwardEnd += OnFastForwardEnd; diff --git a/Assets/Scripts/InteractableObjects/OfficeTable.cs b/Assets/Scripts/InteractableObjects/OfficeTable.cs index cb7d9068..256deaa3 100644 --- a/Assets/Scripts/InteractableObjects/OfficeTable.cs +++ b/Assets/Scripts/InteractableObjects/OfficeTable.cs @@ -13,8 +13,9 @@ public class OfficeTable : BaseInteractableObject UIManager.Instance.ShowJobSelectionDialog("Job agency", null, OnConfirm); } - private void OnConfirm() + private void OnConfirm(JobInfoSO selectedJob) { - _player.JobPosition = JobPositions.Clerk; + _player.JobPosition = selectedJob.JobPosition; + print($"player selected position is {_player.JobPosition}"); } } diff --git a/Assets/Scripts/ScriptableObjects/JobPositions/Clerk.asset b/Assets/Scripts/ScriptableObjects/JobPositions/Clerk.asset index 9a62363d..b4585e1c 100644 --- a/Assets/Scripts/ScriptableObjects/JobPositions/Clerk.asset +++ b/Assets/Scripts/ScriptableObjects/JobPositions/Clerk.asset @@ -14,4 +14,5 @@ MonoBehaviour: m_EditorClassIdentifier: Description: Clerk Salary: 5 - JobPosition: 1 + Icon: {fileID: 0} + JobPosition: 2 diff --git a/Assets/Scripts/ScriptableObjects/JobPositions/Manager.asset b/Assets/Scripts/ScriptableObjects/JobPositions/Manager.asset index 3f03ac7b..dfa1622d 100644 --- a/Assets/Scripts/ScriptableObjects/JobPositions/Manager.asset +++ b/Assets/Scripts/ScriptableObjects/JobPositions/Manager.asset @@ -14,4 +14,5 @@ MonoBehaviour: m_EditorClassIdentifier: Description: Manager Salary: 9 - JobPosition: 3 + Icon: {fileID: 0} + JobPosition: 4 diff --git a/Assets/Scripts/ScriptableObjects/JobPositions/ManagerAssistant.asset b/Assets/Scripts/ScriptableObjects/JobPositions/ManagerAssistant.asset index b3fc0f52..82862770 100644 --- a/Assets/Scripts/ScriptableObjects/JobPositions/ManagerAssistant.asset +++ b/Assets/Scripts/ScriptableObjects/JobPositions/ManagerAssistant.asset @@ -14,4 +14,5 @@ MonoBehaviour: m_EditorClassIdentifier: Description: Manager assistaint Salary: 6 - JobPosition: 2 + Icon: {fileID: 0} + JobPosition: 3 diff --git a/Assets/Scripts/UIElements/JobItemUITemplate.cs b/Assets/Scripts/UIElements/JobItemUITemplate.cs index 10c311c1..1ff73041 100644 --- a/Assets/Scripts/UIElements/JobItemUITemplate.cs +++ b/Assets/Scripts/UIElements/JobItemUITemplate.cs @@ -1,8 +1,9 @@ using TMPro; using UnityEngine; +using UnityEngine.EventSystems; using UnityEngine.UI; -public class JobItemUITemplate : MonoBehaviour +public class JobItemUITemplate : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler { [SerializeField] private TextMeshProUGUI _descreiption; @@ -11,10 +12,34 @@ public class JobItemUITemplate : MonoBehaviour [SerializeField] private Image _icon; - public void SetItem(JobInfoSO item) + private JobSelectorUI _parent; + private JobInfoSO _item; + public JobInfoSO Item=> _item; + + public void SetItem(JobSelectorUI parent,JobInfoSO item) { + _item= item; + _parent = parent; _descreiption.text = item.Description; _sallary.text = $"{item.Salary}$"; _icon.sprite = item.Icon; } + + void OnMouseDown() + { + _parent.OnItemSelected(this); + } + public void OnPointerClick(PointerEventData eventData) + { + _parent.OnItemSelected(this); + } + + public void Click() + { + _parent.OnItemSelected(this); + } + + public void OnPointerEnter(PointerEventData eventData) + { + } } diff --git a/Assets/Scripts/UIElements/JobSelectorUI.cs b/Assets/Scripts/UIElements/JobSelectorUI.cs index c60b92f9..a76cceab 100644 --- a/Assets/Scripts/UIElements/JobSelectorUI.cs +++ b/Assets/Scripts/UIElements/JobSelectorUI.cs @@ -1,9 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Linq; using TMPro; -using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; @@ -30,7 +27,9 @@ public class JobSelectorUI : MonoBehaviour private List _jobs; private JobTabUITemplate _selectedTab; - public void ShowJobSelectionDialog(string title, Action onCancel, Action onConfirm) + private JobItemUITemplate _selectedItem; + + public void ShowJobSelectionDialog(string title, Action onCancel, Action onConfirm) { UIManager.Instance.Freeze(); @@ -57,7 +56,7 @@ public class JobSelectorUI : MonoBehaviour }); _btnOk.onClick.AddListener(() => { - onConfirm?.Invoke(); + onConfirm?.Invoke(_selectedItem.Item); Hide(); }); } @@ -78,7 +77,7 @@ public class JobSelectorUI : MonoBehaviour { var itemUI = Instantiate(_jobItemUItemplate, _itemsContainer); itemUI.gameObject.SetActive(true); - itemUI.GetComponent().SetItem((job)); + itemUI.GetComponent().SetItem(this,job); } print($"selected {button.JobListItem.name}"); } @@ -88,6 +87,12 @@ public class JobSelectorUI : MonoBehaviour print($"exit {button.JobListItem.name}"); } + public void OnItemSelected(JobItemUITemplate button) + { + print($"selected job {button.Item.name}"); + _selectedItem = button; + } + private void CloseDialog() { UIManager.Instance.Unfreeze(); diff --git a/Assets/Scripts/UIElements/UIManager.cs b/Assets/Scripts/UIElements/UIManager.cs index 7a166a8b..ff877be3 100644 --- a/Assets/Scripts/UIElements/UIManager.cs +++ b/Assets/Scripts/UIElements/UIManager.cs @@ -32,7 +32,7 @@ public class UIManager : MonoBehaviour timeSlider.ShowTimeSliderDialog(title, description, onCancel, onConfirm); } - public void ShowJobSelectionDialog(string title, Action onCancel, Action onConfirm) + public void ShowJobSelectionDialog(string title, Action onCancel, Action onConfirm) { var jobSelector = Instantiate(_jobSelectorPrefab, transform); jobSelector.ShowJobSelectionDialog(title, onCancel, onConfirm); diff --git a/Packages/manifest.json b/Packages/manifest.json index 9aff234a..2e979ffe 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,12 +1,12 @@ { "dependencies": { - "com.unity.ai.navigation": "1.1.1", + "com.unity.ai.navigation": "1.1.3", "com.unity.animation.rigging": "1.2.1", "com.unity.cinemachine": "2.9.5", "com.unity.collab-proxy": "2.0.3", "com.unity.formats.fbx": "4.2.1", - "com.unity.ide.rider": "3.0.18", - "com.unity.ide.visualstudio": "2.0.17", + "com.unity.ide.rider": "3.0.20", + "com.unity.ide.visualstudio": "2.0.18", "com.unity.ide.vscode": "1.2.5", "com.unity.render-pipelines.universal": "14.0.7", "com.unity.test-framework": "1.1.33", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index edcd0423..9bea43a3 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -8,7 +8,7 @@ "url": "https://packages.unity.com" }, "com.unity.ai.navigation": { - "version": "1.1.1", + "version": "1.1.3", "depth": 0, "source": "registry", "dependencies": { @@ -69,7 +69,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "3.0.18", + "version": "3.0.20", "depth": 0, "source": "registry", "dependencies": { @@ -78,7 +78,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.17", + "version": "2.0.18", "depth": 0, "source": "registry", "dependencies": { diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index e4e1acd3..9a1a5024 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.2.15f1 -m_EditorVersionWithRevision: 2022.2.15f1 (30d813e1a2a9) +m_EditorVersion: 2022.2.17f1 +m_EditorVersionWithRevision: 2022.2.17f1 (54cb9bda89c4)