implement simple learning process

This commit is contained in:
Vova
2023-12-19 19:22:26 +02:00
parent 22149e24c8
commit 0f60b41d58
11 changed files with 84 additions and 31 deletions
+7 -5
View File
@@ -3,10 +3,10 @@
public enum JobPositions { Unemployed, Cashier, Clerk, ManagerAssistaint, Manager };
public enum EducationSkill { NotEducated, School, HightSchool, University };
public enum PlayerStates { Awake, Sleeping, Eating, Working }
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job,LocationName }
public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, LocationName }
public enum Tasks { Move, Interact, Rotate };
public enum TaskStatus { Waiting, InProgress, Complete };
public enum InteractionStatus { None,Complete, WaitForChoose, InProgress, FarFromPlayer };
public enum InteractionStatus { None, Complete, WaitForChoose, InProgress, FarFromPlayer };
public enum AnimationStates
{
[EnumMember(Value = "Idle")]
@@ -23,7 +23,8 @@ public enum AnimationStates
Standing
};
public enum RadialMenuActions {
public enum RadialMenuActions
{
Cancel,
Sleep,
Eat,
@@ -31,7 +32,8 @@ public enum RadialMenuActions {
Take,
Work,
Talk,
Buy ,
Buy,
Open,
Enter
Enter,
Learn,
}
@@ -28,6 +28,7 @@ public abstract class BaseInteractableObject : MonoBehaviour
{ RadialMenuActions.Open, new RadialMenuActionDescription() { Description = "Open", IsEnabled = false } },
{ RadialMenuActions.Enter, new RadialMenuActionDescription() { Description = "Enter", IsEnabled = false } },
{ RadialMenuActions.Cancel, new RadialMenuActionDescription() { Description = "Cancel", IsEnabled = true } },
{ RadialMenuActions.Learn, new RadialMenuActionDescription() { Description = "Learn", IsEnabled = false} },
};
}
@@ -12,7 +12,7 @@ public class OfficeTable : BaseInteractableObject
protected override void InteractAction(RadialMenuActions interactAction)
{
GameManager.Instance.UI.ShowTabObtionsDialog(_dialogSO, null, OnConfirm);
GameManager.Instance.UI.ShowTabOptionsDialog(_dialogSO, null, OnConfirm);
}
private void OnConfirm(IDialogOption selectedJob)
@@ -0,0 +1,52 @@
using Assets.Scripts.Interfaces;
using System;
using Unity.VisualScripting;
using UnityEngine;
public class SecretaryDesk : BaseInteractableObject
{
[SerializeField]
private DialogSO _dialogSO;
protected override void PrepareMenuActions()
{
_menuActions[RadialMenuActions.Talk].IsEnabled = true;
_menuActions[RadialMenuActions.Learn].IsEnabled = Player.Instance.ActiveCourse != null;
}
protected override void InteractAction(RadialMenuActions interactAction)
{
switch (interactAction)
{
case RadialMenuActions.Talk:
GameManager.Instance.UI.ShowTabOptionsDialog(_dialogSO, null, OnConfirm);
break;
case RadialMenuActions.Learn:
GameManager.Instance.UI.ShowTimeSliderDialog("Learn", "learn until", OnCancel, OnLearnConfirm);
break;
}
}
private void OnLearnConfirm(TimeSpan time)
{
GameManager.Instance.Time.FastForward(time);
GameManager.Instance.Time.OnFastForwardEnd += OnFastForwardEnd;
_player.Learn(time);
}
private void OnCancel()
{
OnFastForwardEnd();
}
private void OnFastForwardEnd()
{
_player.SetPlayerActing(PlayerStates.Awake);
_player.SetPlayerAnimation(AnimationStates.Standing);
GameManager.Instance.Time.OnFastForwardEnd -= OnFastForwardEnd;
}
private void OnConfirm(IDialogOption selectedOption)
{
_player.ActiveCourse = (selectedOption as EducationInfoSO);
print($"player selected course is {(selectedOption as EducationInfoSO).Description}");
}
}
@@ -1,24 +0,0 @@
using Assets.Scripts.Interfaces;
using UnityEngine;
public class SecretaryDesk : BaseInteractableObject
{
[SerializeField]
private DialogSO _dialogSO;
protected override void PrepareMenuActions()
{
_menuActions[RadialMenuActions.Talk].IsEnabled = true;
}
protected override void InteractAction(RadialMenuActions interactAction)
{
GameManager.Instance.UI.ShowTabObtionsDialog(_dialogSO, null, OnConfirm);
}
private void OnConfirm(IDialogOption selectedOption)
{
//_player.JobPosition = (selectedOption as EducationInfoSO).JobPosition;
print($"player selected position is {(selectedOption as EducationInfoSO).Description}");
}
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 64bc13a0b6923c14ab5d87e8338aca0c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+13
View File
@@ -16,6 +16,8 @@ public class Player : BaseCharacter
public Dictionary<StatsId, object> Stats;
public JobPositions JobPosition { get; set; }
private List<EducationInfoSO> _completedCourses=new();
public EducationInfoSO ActiveCourse { get; set; }
public EducationSkill Education { get; set; }
private ContainerItem _containerItem;
@@ -148,4 +150,15 @@ public class Player : BaseCharacter
{
return _locationName;
}
internal void Learn(TimeSpan time)
{
ActiveCourse.PlayerProgress+= time.Hours;
if(ActiveCourse.PlayerProgress>=ActiveCourse.Duration)
{
Education++;
print($"Congratulation player finish curse {ActiveCourse.Description} and his education now {Education.ToString()}");
ActiveCourse =null;
}
}
}
@@ -8,4 +8,5 @@ public class EducationInfoSO : IDialogOption
public int Duration;
public float EnrollPrice;
public EducationSkill Skill;
public int PlayerProgress;
}
+1 -1
View File
@@ -28,7 +28,7 @@ public class UISystem : MonoBehaviour
timeSlider.ShowTimeSliderDialog(title, description, onCancel, onConfirm);
}
public void ShowTabObtionsDialog(DialogSO dialogSO, Action onCancel, Action<IDialogOption> onConfirm)
public void ShowTabOptionsDialog(DialogSO dialogSO, Action onCancel, Action<IDialogOption> onConfirm)
{
var dialog = Instantiate(_DialogUIPrefab, transform);
dialog.ShowCategoriesDialog(dialogSO, onCancel, onConfirm);