Player can select job position now
This commit is contained in:
@@ -673,4 +673,16 @@ MonoBehaviour:
|
|||||||
m_TargetGraphic: {fileID: 4798811243242991943}
|
m_TargetGraphic: {fileID: 4798811243242991943}
|
||||||
m_OnClick:
|
m_OnClick:
|
||||||
m_PersistentCalls:
|
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
|
||||||
|
|||||||
@@ -4603,6 +4603,23 @@ PrefabInstance:
|
|||||||
value:
|
value:
|
||||||
objectReference: {fileID: 11400000, guid: 9dd346cdfec57ee47ad1c06a925769bb,
|
objectReference: {fileID: 11400000, guid: 9dd346cdfec57ee47ad1c06a925769bb,
|
||||||
type: 2}
|
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,
|
- target: {fileID: 2369538501029799684, guid: 88fcb1c95eeeabc479f95a580dea8152,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: _selectedObject
|
propertyPath: _selectedObject
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Runtime.Serialization;
|
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 PlayerStates { Awake, Sleeping, Eating,Working }
|
||||||
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, }
|
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, }
|
||||||
public enum Tasks { Move, Interact, Rotate };
|
public enum Tasks { Move, Interact, Rotate };
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CashierDesk : BaseInteractableObject
|
public class CashierDesk : BaseInteractableObject
|
||||||
@@ -6,8 +8,8 @@ public class CashierDesk : BaseInteractableObject
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private ContainerSO _containerSO;
|
private ContainerSO _containerSO;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private JobInfoSO _jobInfo;
|
private List<JobInfoSO> _jobsInfoList;
|
||||||
|
private JobInfoSO _playerJob;
|
||||||
|
|
||||||
public override void Interact(Player player)
|
public override void Interact(Player player)
|
||||||
{
|
{
|
||||||
@@ -18,11 +20,12 @@ public class CashierDesk : BaseInteractableObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if player work here
|
_playerJob = _jobsInfoList.First(x => x.JobPosition == player.JobPosition);
|
||||||
if (player.JobPosition == _jobInfo.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
|
else
|
||||||
{
|
{
|
||||||
@@ -72,7 +75,7 @@ public class CashierDesk : BaseInteractableObject
|
|||||||
float _totalSalary;
|
float _totalSalary;
|
||||||
private void OnConfirm(TimeSpan time)
|
private void OnConfirm(TimeSpan time)
|
||||||
{
|
{
|
||||||
_totalSalary = (float)(time.TotalHours * _jobInfo.Salary);
|
_totalSalary = (float)(time.TotalHours * _playerJob.Salary);
|
||||||
_player.SetPlayerActing(PlayerStates.Working);
|
_player.SetPlayerActing(PlayerStates.Working);
|
||||||
TimeManager.Instance.FastForward(time);
|
TimeManager.Instance.FastForward(time);
|
||||||
TimeManager.Instance.OnFastForwardEnd += OnFastForwardEnd;
|
TimeManager.Instance.OnFastForwardEnd += OnFastForwardEnd;
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ public class OfficeTable : BaseInteractableObject
|
|||||||
UIManager.Instance.ShowJobSelectionDialog("Job agency", null, OnConfirm);
|
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
Description: Clerk
|
Description: Clerk
|
||||||
Salary: 5
|
Salary: 5
|
||||||
JobPosition: 1
|
Icon: {fileID: 0}
|
||||||
|
JobPosition: 2
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
Description: Manager
|
Description: Manager
|
||||||
Salary: 9
|
Salary: 9
|
||||||
JobPosition: 3
|
Icon: {fileID: 0}
|
||||||
|
JobPosition: 4
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
Description: Manager assistaint
|
Description: Manager assistaint
|
||||||
Salary: 6
|
Salary: 6
|
||||||
JobPosition: 2
|
Icon: {fileID: 0}
|
||||||
|
JobPosition: 3
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class JobItemUITemplate : MonoBehaviour
|
public class JobItemUITemplate : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private TextMeshProUGUI _descreiption;
|
private TextMeshProUGUI _descreiption;
|
||||||
@@ -11,10 +12,34 @@ public class JobItemUITemplate : MonoBehaviour
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Image _icon;
|
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;
|
_descreiption.text = item.Description;
|
||||||
_sallary.text = $"{item.Salary}$";
|
_sallary.text = $"{item.Salary}$";
|
||||||
_icon.sprite = item.Icon;
|
_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)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -30,7 +27,9 @@ public class JobSelectorUI : MonoBehaviour
|
|||||||
private List<JobsListSO> _jobs;
|
private List<JobsListSO> _jobs;
|
||||||
|
|
||||||
private JobTabUITemplate _selectedTab;
|
private JobTabUITemplate _selectedTab;
|
||||||
public void ShowJobSelectionDialog(string title, Action onCancel, Action onConfirm)
|
private JobItemUITemplate _selectedItem;
|
||||||
|
|
||||||
|
public void ShowJobSelectionDialog(string title, Action onCancel, Action<JobInfoSO> onConfirm)
|
||||||
{
|
{
|
||||||
UIManager.Instance.Freeze();
|
UIManager.Instance.Freeze();
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ public class JobSelectorUI : MonoBehaviour
|
|||||||
});
|
});
|
||||||
_btnOk.onClick.AddListener(() =>
|
_btnOk.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
onConfirm?.Invoke();
|
onConfirm?.Invoke(_selectedItem.Item);
|
||||||
Hide();
|
Hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -78,7 +77,7 @@ public class JobSelectorUI : MonoBehaviour
|
|||||||
{
|
{
|
||||||
var itemUI = Instantiate(_jobItemUItemplate, _itemsContainer);
|
var itemUI = Instantiate(_jobItemUItemplate, _itemsContainer);
|
||||||
itemUI.gameObject.SetActive(true);
|
itemUI.gameObject.SetActive(true);
|
||||||
itemUI.GetComponent<JobItemUITemplate>().SetItem((job));
|
itemUI.GetComponent<JobItemUITemplate>().SetItem(this,job);
|
||||||
}
|
}
|
||||||
print($"selected {button.JobListItem.name}");
|
print($"selected {button.JobListItem.name}");
|
||||||
}
|
}
|
||||||
@@ -88,6 +87,12 @@ public class JobSelectorUI : MonoBehaviour
|
|||||||
print($"exit {button.JobListItem.name}");
|
print($"exit {button.JobListItem.name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnItemSelected(JobItemUITemplate button)
|
||||||
|
{
|
||||||
|
print($"selected job {button.Item.name}");
|
||||||
|
_selectedItem = button;
|
||||||
|
}
|
||||||
|
|
||||||
private void CloseDialog()
|
private void CloseDialog()
|
||||||
{
|
{
|
||||||
UIManager.Instance.Unfreeze();
|
UIManager.Instance.Unfreeze();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class UIManager : MonoBehaviour
|
|||||||
timeSlider.ShowTimeSliderDialog(title, description, onCancel, onConfirm);
|
timeSlider.ShowTimeSliderDialog(title, description, onCancel, onConfirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowJobSelectionDialog(string title, Action onCancel, Action onConfirm)
|
public void ShowJobSelectionDialog(string title, Action onCancel, Action<JobInfoSO> onConfirm)
|
||||||
{
|
{
|
||||||
var jobSelector = Instantiate(_jobSelectorPrefab, transform);
|
var jobSelector = Instantiate(_jobSelectorPrefab, transform);
|
||||||
jobSelector.ShowJobSelectionDialog(title, onCancel, onConfirm);
|
jobSelector.ShowJobSelectionDialog(title, onCancel, onConfirm);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.ai.navigation": "1.1.1",
|
"com.unity.ai.navigation": "1.1.3",
|
||||||
"com.unity.animation.rigging": "1.2.1",
|
"com.unity.animation.rigging": "1.2.1",
|
||||||
"com.unity.cinemachine": "2.9.5",
|
"com.unity.cinemachine": "2.9.5",
|
||||||
"com.unity.collab-proxy": "2.0.3",
|
"com.unity.collab-proxy": "2.0.3",
|
||||||
"com.unity.formats.fbx": "4.2.1",
|
"com.unity.formats.fbx": "4.2.1",
|
||||||
"com.unity.ide.rider": "3.0.18",
|
"com.unity.ide.rider": "3.0.20",
|
||||||
"com.unity.ide.visualstudio": "2.0.17",
|
"com.unity.ide.visualstudio": "2.0.18",
|
||||||
"com.unity.ide.vscode": "1.2.5",
|
"com.unity.ide.vscode": "1.2.5",
|
||||||
"com.unity.render-pipelines.universal": "14.0.7",
|
"com.unity.render-pipelines.universal": "14.0.7",
|
||||||
"com.unity.test-framework": "1.1.33",
|
"com.unity.test-framework": "1.1.33",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.ai.navigation": {
|
"com.unity.ai.navigation": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.3",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.ide.rider": {
|
"com.unity.ide.rider": {
|
||||||
"version": "3.0.18",
|
"version": "3.0.20",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.ide.visualstudio": {
|
"com.unity.ide.visualstudio": {
|
||||||
"version": "2.0.17",
|
"version": "2.0.18",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
m_EditorVersion: 2022.2.15f1
|
m_EditorVersion: 2022.2.17f1
|
||||||
m_EditorVersionWithRevision: 2022.2.15f1 (30d813e1a2a9)
|
m_EditorVersionWithRevision: 2022.2.17f1 (54cb9bda89c4)
|
||||||
|
|||||||
Reference in New Issue
Block a user