change multiple scene system to dynamic indoor scene
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using UnityEngine;
|
||||
|
||||
public class AreaName : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string _areaName;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if(other.gameObject.GetComponentInChildren<Player>() is Player)
|
||||
{
|
||||
(Player.Instance.Stats[StatsId.LocationName] as IStringStat).SetValue(_areaName);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18f0e472918ce7a41898514f037c380d
|
||||
@@ -0,0 +1,62 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class BaseInteractableObject : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public Transform _interactionPoint;
|
||||
|
||||
protected Dictionary<RadialMenuActions, RadialMenuActionDescription> _menuActions = new();
|
||||
private RadialMenuActions _selectedAction;
|
||||
protected Player _player;
|
||||
private InteractionStatus _currentStatus = InteractionStatus.None;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
_menuActions = new Dictionary<RadialMenuActions, RadialMenuActionDescription>
|
||||
{
|
||||
{ RadialMenuActions.Buy, new RadialMenuActionDescription() { Description = "Buy", IsEnabled = false } },
|
||||
{ RadialMenuActions.Sleep, new RadialMenuActionDescription() { Description = "Sleep", IsEnabled = false } },
|
||||
{ RadialMenuActions.Talk, new RadialMenuActionDescription() { Description = "Talk", IsEnabled = false } },
|
||||
{ RadialMenuActions.Put, new RadialMenuActionDescription() { Description = "Put", IsEnabled = false } },
|
||||
{ RadialMenuActions.Take, new RadialMenuActionDescription() { Description = "Take", IsEnabled = false } },
|
||||
{ RadialMenuActions.Work, new RadialMenuActionDescription() { Description = "Work", IsEnabled = false } },
|
||||
{ RadialMenuActions.Eat, new RadialMenuActionDescription() { Description = "Eat", IsEnabled = false } },
|
||||
{ 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} },
|
||||
};
|
||||
}
|
||||
|
||||
public async UniTask<InteractionStatus> ShowPopupMenu(Player player)
|
||||
{
|
||||
_player = player;
|
||||
PrepareMenuActions();
|
||||
var filteredActions = _menuActions.Where(x => x.Value.IsEnabled).ToDictionary(i => i.Key, i => i.Value);
|
||||
var result=await GameManager.Instance.UI.ShowItemPopupMenu(filteredActions);
|
||||
if (result == RadialMenuActions.Cancel)
|
||||
{
|
||||
_currentStatus = InteractionStatus.Complete;
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedAction = result;
|
||||
_currentStatus = InteractionStatus.InProgress;
|
||||
}
|
||||
return _currentStatus;
|
||||
}
|
||||
|
||||
public TaskStatus Interact()
|
||||
{
|
||||
InteractAction(_selectedAction);
|
||||
return TaskStatus.Complete;
|
||||
}
|
||||
|
||||
protected abstract void InteractAction(RadialMenuActions interactAction);
|
||||
|
||||
protected abstract void PrepareMenuActions();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2af31bf77e63ee64da69d7c708550949
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
public class Bed : BaseInteractableObject
|
||||
{
|
||||
|
||||
protected override void PrepareMenuActions()
|
||||
{
|
||||
_menuActions[RadialMenuActions.Sleep].IsEnabled = true;
|
||||
}
|
||||
|
||||
protected override void InteractAction(RadialMenuActions interactAction)
|
||||
{
|
||||
_player.SetPlayerAnimation(AnimationStates.Sitting, OnAnimationFinished);
|
||||
}
|
||||
|
||||
private void OnAnimationFinished()
|
||||
{
|
||||
GameManager.Instance.UI.ShowTimeSliderDialog("Sleep", "Wake up in", OnCancel, OnConfirm);
|
||||
}
|
||||
private void OnCancel()
|
||||
{
|
||||
OnFastForwardEnd();
|
||||
}
|
||||
|
||||
private void OnConfirm(TimeSpan time)
|
||||
{
|
||||
_player.SetPlayerActing(PlayerStates.Sleeping);
|
||||
GameManager.Instance.Time.FastForward(time);
|
||||
GameManager.Instance.Time.OnFastForwardEnd += OnFastForwardEnd;
|
||||
}
|
||||
|
||||
private void OnFastForwardEnd()
|
||||
{
|
||||
_player.SetPlayerActing(PlayerStates.Awake);
|
||||
_player.SetPlayerAnimation(AnimationStates.Standing);
|
||||
GameManager.Instance.Time.OnFastForwardEnd -= OnFastForwardEnd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec924e9d7d23a4e46b256dedc9caa75c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class CashierDesk : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
[SerializeField]
|
||||
private List<JobInfoSO> _jobsInfoList;
|
||||
private JobInfoSO _playerJob;
|
||||
|
||||
private bool CheckIfPlayerHaveItems()
|
||||
{
|
||||
if (_player.IsHoldContainerItem())
|
||||
{
|
||||
var playerContainer = _player.GetContainerItem();
|
||||
if (playerContainer.IsSalebleItems())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void PrepareMenuActions()
|
||||
{
|
||||
_playerJob = _jobsInfoList.FirstOrDefault(x => x.JobPosition == _player.JobPosition);
|
||||
if (_playerJob != null)
|
||||
_menuActions[RadialMenuActions.Work].IsEnabled = true;
|
||||
|
||||
_menuActions[RadialMenuActions.Buy].IsEnabled = CheckIfPlayerHaveItems();
|
||||
|
||||
}
|
||||
|
||||
protected override void InteractAction(RadialMenuActions interactAction)
|
||||
{
|
||||
switch (interactAction)
|
||||
{
|
||||
case RadialMenuActions.Buy:
|
||||
BuyItems();
|
||||
break;
|
||||
case RadialMenuActions.Work:
|
||||
GameManager.Instance.UI.ShowTimeSliderDialog($"Work", $"Work as {_playerJob.Description}", OnCancel, OnConfirm);
|
||||
break;
|
||||
default:
|
||||
print("unknown action");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void BuyItems()
|
||||
{
|
||||
var playerContainer = _player.GetContainerItem();
|
||||
if (playerContainer.IsSalebleItems())
|
||||
{
|
||||
var playerItemsList = playerContainer.GetItems();
|
||||
_player.ClearContainerItem();
|
||||
float finalPrice = 0;
|
||||
foreach (SellableItemSO item in playerItemsList)
|
||||
{
|
||||
finalPrice += item.Price;
|
||||
}
|
||||
|
||||
var transform = Instantiate(_containerSO.prefab, _interactionPoint);
|
||||
var containerItem = transform.GetComponent<ContainerItem>();
|
||||
if (containerItem == null)
|
||||
{
|
||||
Debug.LogError("Container Item is null");
|
||||
return;
|
||||
}
|
||||
_player.Pay(finalPrice);
|
||||
foreach (var item in playerContainer.GetItems())
|
||||
{
|
||||
|
||||
var foodItemSO = ScriptableObject.CreateInstance<FoodItemSO>();
|
||||
foodItemSO.ItemName = item.ItemName;
|
||||
foodItemSO.Energy = 0;
|
||||
containerItem.AddItem(foodItemSO);
|
||||
}
|
||||
_player.SetContainerItem(containerItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancel()
|
||||
{
|
||||
OnFastForwardEnd();
|
||||
}
|
||||
|
||||
float _totalSalary;
|
||||
private void OnConfirm(TimeSpan time)
|
||||
{
|
||||
_totalSalary = (float)(time.TotalHours * _playerJob.Salary);
|
||||
_player.SetPlayerActing(PlayerStates.Working);
|
||||
GameManager.Instance.Time.FastForward(time);
|
||||
GameManager.Instance.Time.OnFastForwardEnd += OnFastForwardEnd;
|
||||
}
|
||||
|
||||
private void OnFastForwardEnd()
|
||||
{
|
||||
_player.AddMoney(_totalSalary);
|
||||
_player.SetPlayerActing(PlayerStates.Awake);
|
||||
GameManager.Instance.Time.OnFastForwardEnd -= OnFastForwardEnd;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b3df7729a1cd4e479add673fa0f9b76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DoorController : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
public IndoorSO BuildingInfo;
|
||||
[SerializeField]
|
||||
private string _scene;
|
||||
[SerializeField]
|
||||
private string _spawnPointInSceneName;
|
||||
[SerializeField]
|
||||
private string _exitName;
|
||||
|
||||
protected override void PrepareMenuActions()
|
||||
{
|
||||
_menuActions[RadialMenuActions.Enter].IsEnabled = true;
|
||||
}
|
||||
|
||||
protected override void InteractAction(RadialMenuActions interactAction)
|
||||
{
|
||||
GameManager.Instance.BuildingSystem.BuildingInteract(BuildingInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 024987a58bcb1394a97473f1d70d0c47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
|
||||
using Assets.Scripts.Interfaces;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Fridge : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
|
||||
private List<FoodItemSO> _foodObjects = new List<FoodItemSO>();
|
||||
|
||||
private bool CheckIfPlayerHaveItems()
|
||||
{
|
||||
if (_player.IsHoldContainerItem())
|
||||
{
|
||||
var playerContainer = _player.GetContainerItem();
|
||||
if (!playerContainer.IsSalebleItems())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void PrepareMenuActions()
|
||||
{
|
||||
_menuActions[RadialMenuActions.Put].IsEnabled = CheckIfPlayerHaveItems();
|
||||
_menuActions[RadialMenuActions.Eat].IsEnabled = _foodObjects.Count > 0;
|
||||
}
|
||||
|
||||
protected override void InteractAction(RadialMenuActions interactAction)
|
||||
{
|
||||
switch (interactAction)
|
||||
{
|
||||
case RadialMenuActions.Put:
|
||||
var playerContainer = _player.GetContainerItem();
|
||||
if (_foodObjects.Count + playerContainer.GetItems().Count <= _containerSO.MaxCapacity)
|
||||
{
|
||||
foreach (FoodItemSO item in playerContainer.GetItems())
|
||||
{
|
||||
_foodObjects.Add(item);
|
||||
}
|
||||
|
||||
_player.ClearContainerItem();
|
||||
Debug.Log($"Fridge have {_foodObjects.Count} pices of food");
|
||||
}
|
||||
else
|
||||
Debug.Log($"Fridge is full");
|
||||
break;
|
||||
case RadialMenuActions.Eat:
|
||||
var hunger = (_player.Stats[StatsId.Food] as INumericStat).MaxValue - (_player.Stats[StatsId.Food] as INumericStat).Value;
|
||||
var eatingItems = _foodObjects.Count < (hunger / 10) ? _foodObjects.Count : (hunger / 10);
|
||||
StartCoroutine(EatRoutine(eatingItems));
|
||||
_foodObjects.RemoveRange(0, (int)eatingItems);
|
||||
break;
|
||||
default:
|
||||
print("unknown action");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator EatRoutine(float timeToEat)
|
||||
{
|
||||
_player.SetPlayerActing(PlayerStates.Eating);
|
||||
yield return new WaitForSeconds(timeToEat);
|
||||
_player.SetPlayerActing(PlayerStates.Awake);
|
||||
yield break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6768a45c9ae20c246bf1052cfa08ddec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using Unity.AI.Navigation;
|
||||
using UnityEngine;
|
||||
|
||||
public class IndoorController : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
var indoor = GameManager.Instance.BuildingSystem.Indoor;
|
||||
Instantiate(indoor.Prefab, Vector3.zero, Quaternion.identity);
|
||||
|
||||
Player.Instance.NavAgent.Warp(SpawnPlayer(indoor));
|
||||
// If the NavMeshSurface is not assigned in the Inspector, try to find it
|
||||
var navMeshSurface = indoor.Prefab.GetComponentInChildren<NavMeshSurface>();
|
||||
Player.Instance.NavAgent.enabled = true;
|
||||
// Build the NavMesh
|
||||
if (navMeshSurface != null)
|
||||
{
|
||||
navMeshSurface.BuildNavMesh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("NavMeshSurface is not assigned and not found on the GameObject.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Vector3 SpawnPlayer(IndoorSO indoor)
|
||||
{
|
||||
var spawnPoints = GameObject.FindGameObjectsWithTag("Respawn");
|
||||
BaseInteractableObject interactable = null;
|
||||
if (spawnPoints != null)
|
||||
{
|
||||
foreach (var spawn in spawnPoints)
|
||||
{
|
||||
if (spawn.name.ToLower() == indoor.SpawnPointInSceneName.ToLower())
|
||||
{
|
||||
interactable = spawn.GetComponent<BaseInteractableObject>();
|
||||
Player.Instance.SetPosition(interactable._interactionPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
GameManager.Instance.Camera.ResetToPlayerPosition();
|
||||
return (interactable == null) ? Vector3.zero : interactable._interactionPoint.position;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1add187954d66d4594d1b192ce4a248
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc223213aaee4f748bbcd9342e1d3aae
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ContainerItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
public event EventHandler OnItemsChange;
|
||||
|
||||
private List<BaseItemSO> _items = new List<BaseItemSO>();
|
||||
|
||||
public ContainerSO GetContainerObjectSO()
|
||||
{
|
||||
return _containerSO;
|
||||
}
|
||||
|
||||
public void AddItem(BaseItemSO item)
|
||||
{
|
||||
if (_items.Count < _containerSO.MaxCapacity)
|
||||
{
|
||||
Debug.Log($"Player put to container a {item.ItemName}");
|
||||
_items.Add(item);
|
||||
OnItemsChange?.Invoke(this,EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Container is full");
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(BaseItemSO item)
|
||||
{
|
||||
if (_items.Count>0)
|
||||
{
|
||||
Debug.Log($"Player remove {item.ItemName} from container");
|
||||
_items.Remove(item);
|
||||
OnItemsChange?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Container is emplty");
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseItemSO> GetItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
public bool IsSalebleItems()
|
||||
{
|
||||
return _items.Any(x => x is SellableItemSO);
|
||||
}
|
||||
|
||||
public void AddItems(List<BaseItemSO> playerItemsList)
|
||||
{
|
||||
foreach (var item in playerItemsList)
|
||||
{
|
||||
AddItem(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e6fa409eb749c54cab3871962e90678
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,4 @@
|
||||
public class FoodItemSO : BaseItemSO
|
||||
{
|
||||
public int Energy { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef8197297f5651a4082c2562c95e5cd5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SellableItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private SellableItemSO _sellableItemSO;
|
||||
|
||||
public SellableItemSO GetSellableItemSO()
|
||||
{
|
||||
return _sellableItemSO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 329673eaf27345041afad67ebb166565
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using UnityEngine;
|
||||
|
||||
public class OfficeTable : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private DialogSO _dialogSO;
|
||||
protected override void PrepareMenuActions()
|
||||
{
|
||||
_menuActions[RadialMenuActions.Talk].IsEnabled = true;
|
||||
}
|
||||
|
||||
protected override void InteractAction(RadialMenuActions interactAction)
|
||||
{
|
||||
GameManager.Instance.UI.ShowTabOptionsDialog(_dialogSO, null, OnConfirm);
|
||||
}
|
||||
|
||||
private void OnConfirm(IDialogOption selectedJob)
|
||||
{
|
||||
_player.JobPosition = (selectedJob as JobInfoSO).JobPosition;
|
||||
print($"player selected position is {_player.JobPosition}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca9df444fb3d3ad469a952aa9bd2160d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,5 @@
|
||||
public class RadialMenuActionDescription
|
||||
{
|
||||
public bool IsEnabled { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6bfbb59bd3f3234e947cc44069cfe7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using System;
|
||||
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 {_player.ActiveCourse.name} in next", 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}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05e7f5c95d24c174ba832e4264e9d224
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ShopingContainer : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
|
||||
protected override void PrepareMenuActions()
|
||||
{
|
||||
if (!_player.IsHoldContainerItem())
|
||||
_menuActions[RadialMenuActions.Take].IsEnabled = true;
|
||||
}
|
||||
|
||||
protected override void InteractAction(RadialMenuActions interactAction)
|
||||
{
|
||||
var transform = Instantiate(_containerSO.prefab, _interactionPoint);
|
||||
var containerItem = transform.GetComponent<ContainerItem>();
|
||||
if (containerItem == null)
|
||||
{
|
||||
Debug.LogError("Container Item is null");
|
||||
return;
|
||||
}
|
||||
_player.SetContainerItem(containerItem);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47d747d0dea3a1144ac061eabd85e7b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class StoreContainer : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private SellableItemSO _sellableItemSO;
|
||||
|
||||
protected override void PrepareMenuActions()
|
||||
{
|
||||
_menuActions[RadialMenuActions.Take].IsEnabled = _player.IsHoldContainerItem();
|
||||
}
|
||||
|
||||
protected override void InteractAction(RadialMenuActions interactAction)
|
||||
{
|
||||
var clone = Instantiate(_sellableItemSO);
|
||||
|
||||
var container = _player.GetContainerItem();
|
||||
container.AddItem(clone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 476179b02ece27040b9373a7668b7a28
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user