浏览代码

Refractoring

/main
uChema 4 年前
当前提交
b2cf2c5b
共有 47 个文件被更改,包括 356 次插入323 次删除
  1. 5
      UOP1_Project/Assets/Prefabs/Characters/BardHare.prefab
  2. 3
      UOP1_Project/Assets/Prefabs/Managers/DialogueManager.prefab
  3. 3
      UOP1_Project/Assets/Prefabs/Managers/QuestManager.prefab
  4. 10
      UOP1_Project/Assets/Scenes/Examples/InteractionExample.unity
  5. 3
      UOP1_Project/Assets/ScriptableObjects/Events/Dialogue/EndDialogueEvent.asset
  6. 2
      UOP1_Project/Assets/ScriptableObjects/Events/Dialogue/EndDialogueEvent.asset.meta
  7. 3
      UOP1_Project/Assets/ScriptableObjects/Events/Quests/EndStepEvent.asset
  8. 2
      UOP1_Project/Assets/ScriptableObjects/Events/Quests/EndStepEvent.asset.meta
  9. 2
      UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Quest1.asset
  10. 5
      UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step1/Step1.asset
  11. 4
      UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step2/Dialogue/Step2_StartDialogue.asset
  12. 3
      UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step2/Step2.asset
  13. 1
      UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step3/Dialogue/Step3_StartDialogue.asset
  14. 3
      UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step3/Step3.asset
  15. 20
      UOP1_Project/Assets/Scripts/Cutscenes/CutsceneManager.cs
  16. 10
      UOP1_Project/Assets/Scripts/Cutscenes/CutsceneTrigger.cs
  17. 27
      UOP1_Project/Assets/Scripts/Dialogues/DialogueDataSO.cs
  18. 40
      UOP1_Project/Assets/Scripts/Dialogues/DialogueManager.cs
  19. 4
      UOP1_Project/Assets/Scripts/Dialogues/DialogueTrigger.cs
  20. 2
      UOP1_Project/Assets/Scripts/Effects/DissolveHelper.cs
  21. 19
      UOP1_Project/Assets/Scripts/Inventory/CollectibleItem.cs
  22. 56
      UOP1_Project/Assets/Scripts/Inventory/InventoryItemFiller.cs
  23. 100
      UOP1_Project/Assets/Scripts/Inventory/InventoryManager.cs
  24. 2
      UOP1_Project/Assets/Scripts/Inventory/ItemInstance.cs
  25. 8
      UOP1_Project/Assets/Scripts/Inventory/ItemPicker.cs
  26. 4
      UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/InventoryTabType.cs
  27. 13
      UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/Item.cs
  28. 12
      UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/ItemType.cs
  29. 52
      UOP1_Project/Assets/Scripts/Inventory/UIInventoryManager.cs
  30. 45
      UOP1_Project/Assets/Scripts/Quests/QuestManager.cs
  31. 40
      UOP1_Project/Assets/Scripts/Quests/StepController.cs
  32. 16
      UOP1_Project/Assets/Scripts/UI/CookingInventoryInspectorFiller.cs
  33. 15
      UOP1_Project/Assets/Scripts/UI/IngredientFiller.cs
  34. 15
      UOP1_Project/Assets/Scripts/UI/InspectorDescriptionFiller.cs
  35. 18
      UOP1_Project/Assets/Scripts/UI/InspectorFiller.cs
  36. 6
      UOP1_Project/Assets/Scripts/UI/InspectorPreviewFiller.cs
  37. 8
      UOP1_Project/Assets/Scripts/UI/InventoryButtonFiller.cs
  38. 14
      UOP1_Project/Assets/Scripts/UI/InventoryTypeTabFiller.cs
  39. 4
      UOP1_Project/Assets/Scripts/UI/ScriptableObject/InteractionSO.cs
  40. 10
      UOP1_Project/Assets/Scripts/UI/SimpleInventoryInspectorFiller.cs
  41. 8
      UOP1_Project/Assets/Scripts/UI/UIDialogueChoiceFiller.cs
  42. 7
      UOP1_Project/Assets/Scripts/UI/UIDialogueManager.cs
  43. 11
      UOP1_Project/Assets/Scripts/UI/UIInteractionItemFiller.cs
  44. 11
      UOP1_Project/Assets/Scripts/UI/UIInteractionManager.cs
  45. 10
      UOP1_Project/Assets/Scripts/UI/UIManager.cs
  46. 15
      UOP1_Project/Assets/ScriptableObjects/Events/Quests/ContinueStepEvent.asset
  47. 8
      UOP1_Project/Assets/ScriptableObjects/Events/Quests/ContinueStepEvent.asset.meta

5
UOP1_Project/Assets/Prefabs/Characters/BardHare.prefab


_actor: {fileID: 11400000, guid: 027d026cf519df04eb8b7bf251472e13, type: 2}
_defaultDialogue: {fileID: 11400000, guid: f7ead55387bac6d4a9ba9bf10c5c3ee5, type: 2}
_startStepEvent: {fileID: 11400000, guid: ab5fce85191f90d449e132c92e099476, type: 2}
_endDialogueEvent: {fileID: 11400000, guid: b2a95390cb0fdfd4ebbd4fac6e1ca2bc, type: 2}
_endDialogueEvent: {fileID: 11400000, guid: b8f14d59bc3b10e4f9bdf1e65c3c6280, type: 2}
_endStepEvent: {fileID: 11400000, guid: fa6fff5267e6a0340aa7b0222f9c77c7, type: 2}
_continueWithStep: {fileID: 11400000, guid: 6711182c372e2e94a8bd3fd1868223ec, type: 2}
_endStepEvent: {fileID: 11400000, guid: de57bfb8f4b9de7489e0af77da306a8d, type: 2}
_checkStepValidityEvent: {fileID: 11400000, guid: 71375bc63dd705044a6b0fc6ee5f2acd,
type: 2}
_startDialogueEvent: {fileID: 11400000, guid: 5cfe626f5482b914a9e46ebbe35ea1a8,

3
UOP1_Project/Assets/Prefabs/Managers/DialogueManager.prefab


type: 2}
_showChoicesUIEvent: {fileID: 11400000, guid: a4e5e48a0f3430c4197b317e650727c6,
type: 2}
_endDialogue: {fileID: 11400000, guid: b2a95390cb0fdfd4ebbd4fac6e1ca2bc, type: 2}
_endDialogue: {fileID: 11400000, guid: b8f14d59bc3b10e4f9bdf1e65c3c6280, type: 2}
_continueWithStep: {fileID: 11400000, guid: 6711182c372e2e94a8bd3fd1868223ec, type: 2}
_closeDialogueUIEvent: {fileID: 11400000, guid: 53a7f1f01ef364704b1d45d01f2421ae,
type: 2}

3
UOP1_Project/Assets/Prefabs/Managers/QuestManager.prefab


_inventory: {fileID: 11400000, guid: 59c84467f7726dc4587a8373b0936f03, type: 2}
_checkStepValidityEvent: {fileID: 11400000, guid: 71375bc63dd705044a6b0fc6ee5f2acd,
type: 2}
_endStepEvent: {fileID: 11400000, guid: fa6fff5267e6a0340aa7b0222f9c77c7, type: 2}
_endStepEvent: {fileID: 11400000, guid: de57bfb8f4b9de7489e0af77da306a8d, type: 2}
_endDialogueEvent: {fileID: 11400000, guid: b8f14d59bc3b10e4f9bdf1e65c3c6280, type: 2}
_startStepEvent: {fileID: 11400000, guid: ab5fce85191f90d449e132c92e099476, type: 2}
_winDialogueEvent: {fileID: 11400000, guid: dc2da1754c28ab9499cb6c7d72465e69, type: 2}
_loseDialogueEvent: {fileID: 11400000, guid: fcc99784052e5cc469b8c22c0674b051, type: 2}

10
UOP1_Project/Assets/Scenes/Examples/InteractionExample.unity


_openUIDialogueEvent: {fileID: 0}
_showChoicesUIEvent: {fileID: 0}
_endDialogue: {fileID: 0}
_continueWithStep: {fileID: 0}
_closeDialogueUIEvent: {fileID: 0}
--- !u!4 &419940103
Transform:

m_EditorClassIdentifier:
_openUIDialogueEvent: {fileID: 0}
_closeUIDialogueEvent: {fileID: 0}
_showChoicesUIEvent: {fileID: 0}
_openInventoryScreenEvent: {fileID: 0}
_openInventoryScreenForCookingEvent: {fileID: 0}
_closeInventoryScreenEvent: {fileID: 0}

m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
_dialogueManager: {fileID: 419940102}
PlayCutsceneEvent: {fileID: 0}
PlayDialogueEvent: {fileID: 0}
PauseTimelineEvent: {fileID: 0}
_playCutsceneEvent: {fileID: 0}
_playDialogueEvent: {fileID: 0}
_pauseTimelineEvent: {fileID: 0}
--- !u!4 &1647029640
Transform:
m_ObjectHideFlags: 0

_lineText: {fileID: 0}
_actorNameText: {fileID: 0}
_choicesManager: {fileID: 0}
ShowChoicesEvent: {fileID: 0}
_showChoicesEvent: {fileID: 0}
--- !u!222 &1981939916
CanvasRenderer:
m_ObjectHideFlags: 0

3
UOP1_Project/Assets/ScriptableObjects/Events/Dialogue/EndDialogueEvent.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7fafac715ff920c4383fed91a38a351e, type: 3}
m_Script: {fileID: 11500000, guid: 458685ec13446b04e887efdeca5ec20f, type: 3}
description:

2
UOP1_Project/Assets/ScriptableObjects/Events/Dialogue/EndDialogueEvent.asset.meta


fileFormatVersion: 2
guid: b2a95390cb0fdfd4ebbd4fac6e1ca2bc
guid: b8f14d59bc3b10e4f9bdf1e65c3c6280
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0

3
UOP1_Project/Assets/ScriptableObjects/Events/Quests/EndStepEvent.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4d2ce8a9511333c42a9e907bbdb3b32f, type: 3}
m_Script: {fileID: 11500000, guid: 7fafac715ff920c4383fed91a38a351e, type: 3}
description:

2
UOP1_Project/Assets/ScriptableObjects/Events/Quests/EndStepEvent.asset.meta


fileFormatVersion: 2
guid: fa6fff5267e6a0340aa7b0222f9c77c7
guid: de57bfb8f4b9de7489e0af77da306a8d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0

2
UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Quest1.asset


m_Script: {fileID: 11500000, guid: 05c700bba7d21604586cb89ec5afdee0, type: 3}
m_Name: Quest1
m_EditorClassIdentifier:
_tasks:
_steps:
- {fileID: 11400000, guid: 6d97071327172b049a2d7e8d0260cbea, type: 2}
- {fileID: 11400000, guid: f053cd027694c2341b24e7a6637cd30b, type: 2}
- {fileID: 11400000, guid: 9141d636b142e18459e416f602aa7827, type: 2}

5
UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step1/Step1.asset


m_Name: Step1
m_EditorClassIdentifier:
_actor: {fileID: 11400000, guid: 027d026cf519df04eb8b7bf251472e13, type: 2}
_dialogueBeforeStep: {fileID: 0}
_dialogueBeforeStep: {fileID: 11400000, guid: e59770a38e7b1454594ff0ade5cc9347,
type: 2}
_isDone: 1
_isDone: 0

4
UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step2/Dialogue/Step2_StartDialogue.asset


_choices:
- _response: {fileID: 11400000, guid: 41b89c0c93e7af1439d29abc8362b4ec, type: 2}
_nextDialogue: {fileID: 0}
_actionType: 1
_nextDialogue: {fileID: 0}
_nextDialogue: {fileID: 11400000, guid: bd01348075afad54497623d69415d173, type: 2}
_actionType: 0
_dialogueType: 0

3
UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step2/Step2.asset


m_Name: Step2
m_EditorClassIdentifier:
_actor: {fileID: 11400000, guid: 027d026cf519df04eb8b7bf251472e13, type: 2}
_dialogueBeforeStep: {fileID: 0}
_dialogueBeforeStep: {fileID: 11400000, guid: 51d45f4919bbf75429951b9afeeb0ca6,
type: 2}
_winDialogue: {fileID: 11400000, guid: 77292c1386386844d808b7e5ad5485f3, type: 2}
_loseDialogue: {fileID: 11400000, guid: bd01348075afad54497623d69415d173, type: 2}
_item: {fileID: 11400000, guid: 8aff2c01ad67b48d0a0627754d613415, type: 2}

1
UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step3/Dialogue/Step3_StartDialogue.asset


_choices:
- _response: {fileID: 11400000, guid: ef6aede833517e541b24b831e031f5e4, type: 2}
_nextDialogue: {fileID: 11400000, guid: a96a88b56ae09e8408fa02eeea91fa07, type: 2}
_actionType: 1
_dialogueType: 0

3
UOP1_Project/Assets/ScriptableObjects/Quests/Quest1/Step3/Step3.asset


m_Name: Step3
m_EditorClassIdentifier:
_actor: {fileID: 11400000, guid: 027d026cf519df04eb8b7bf251472e13, type: 2}
_dialogueBeforeStep: {fileID: 0}
_dialogueBeforeStep: {fileID: 11400000, guid: f70689490c87e1c479cda63bc7047f9e,
type: 2}
_winDialogue: {fileID: 0}
_loseDialogue: {fileID: 0}
_item: {fileID: 11400000, guid: 981618c3eb6d24746a53ce7dbe6559a6, type: 2}

20
UOP1_Project/Assets/Scripts/Cutscenes/CutsceneManager.cs


[SerializeField] private InputReader _inputReader = default;
[SerializeField] private DialogueManager _dialogueManager = default;
[SerializeField] private PlayableDirectorChannelSO PlayCutsceneEvent;
[SerializeField] public DialogueLineChannelSO PlayDialogueEvent;
[SerializeField] public VoidEventChannelSO PauseTimelineEvent;
[SerializeField] private PlayableDirectorChannelSO _playCutsceneEvent =default;
[SerializeField] public DialogueLineChannelSO _playDialogueEvent=default;
[SerializeField] public VoidEventChannelSO _pauseTimelineEvent=default;
private PlayableDirector _activePlayableDirector;
private bool _isPaused;

}
private void Start()
{
if( PlayCutsceneEvent!=null)
if( _playCutsceneEvent!=null)
PlayCutsceneEvent.OnEventRaised += PlayCutscene;
_playCutsceneEvent.OnEventRaised += PlayCutscene;
if (PlayDialogueEvent != null)
if (_playDialogueEvent != null)
PlayDialogueEvent.OnEventRaised += PlayDialogueFromClip;
_playDialogueEvent.OnEventRaised += PlayDialogueFromClip;
if (PauseTimelineEvent != null)
if (_pauseTimelineEvent != null)
PauseTimelineEvent.OnEventRaised += PauseTimeline;
_pauseTimelineEvent.OnEventRaised += PauseTimeline;
}
}

10
UOP1_Project/Assets/Scripts/Cutscenes/CutsceneTrigger.cs


[SerializeField] private bool _playOnStart = default;
[SerializeField] private bool _playOnce = default;
[SerializeField] private PlayableDirectorChannelSO PlayCutsceneEvent;
[SerializeField] private PlayableDirectorChannelSO _playCutsceneEvent = default;
if(PlayCutsceneEvent!=null)
PlayCutsceneEvent.RaiseEvent(_playableDirector);
if(_playCutsceneEvent!=null)
_playCutsceneEvent.RaiseEvent(_playableDirector);
if (PlayCutsceneEvent != null)
PlayCutsceneEvent.RaiseEvent(_playableDirector);
if (_playCutsceneEvent != null)
_playCutsceneEvent.RaiseEvent(_playableDirector);
if (_playOnce)
Destroy(this);

27
UOP1_Project/Assets/Scripts/Dialogues/DialogueDataSO.cs


using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Timeline;
public enum dialogueType
public enum DialogueType
{
startDialogue,
winDialogue,

}
public enum DialogueActionType
{
nothing,
continueWithStep
}
/// <summary>
/// A Dialogue is a list of consecutive DialogueLines. They play in sequence using the input of the player to skip forward.
/// In future versions it might contain support for branching conversations.

{
[SerializeField] private ActorSO _actor = default;
[SerializeField] private List<DialogueLineSO> _dialogueLines;
[SerializeField] private List<Choice> _choices;
[SerializeField] private dialogueType _dialogueType;
[SerializeField] private List<DialogueLineSO> _dialogueLines = default;
[SerializeField] private List<Choice> _choices = default;
[SerializeField] private DialogueType _dialogueType = default;
public dialogueType DialogueType => _dialogueType;
public DialogueType DialogueType => _dialogueType;
//TODO: Add support for branching conversations
// Maybe add 2 (or more) special line slots which represent a choice in a conversation

[Serializable]
public class Choice
{
[SerializeField] private DialogueLineSO _response;
[SerializeField] private DialogueDataSO _nextDialogue;
public DialogueLineSO Response { get => _response; }
public DialogueDataSO NextDialogue { get => _nextDialogue; }
[SerializeField] private DialogueLineSO _response = default;
[SerializeField] private DialogueDataSO _nextDialogue = default;
[SerializeField] private DialogueActionType _actionType = default;
public DialogueLineSO Response => _response;
public DialogueDataSO NextDialogue => _nextDialogue;
public DialogueActionType ActionType => _actionType;
}

40
UOP1_Project/Assets/Scripts/Dialogues/DialogueManager.cs


[SerializeField] private InputReader _inputReader = default;
private int _counter;
private bool _reachedEndOfDialogue { get => _counter >= _currentDialogueDataSO.DialogueLines.Count; }
private bool _reachedEndOfDialogue { get => _counter >= _currentDialogue.DialogueLines.Count; }
[Header("Listening on channels")]
[SerializeField] private DialogueDataChannelSO _startDialogue = default;

[SerializeField] private DialogueLineChannelSO _openUIDialogueEvent = default;
[SerializeField] private DialogueChoicesChannelSO _showChoicesUIEvent = default;
[SerializeField] private VoidEventChannelSO _endDialogue = default;
[SerializeField] private DialogueDataChannelSO _endDialogue = default;
[SerializeField] private VoidEventChannelSO _continueWithStep = default;
private DialogueDataSO _currentDialogueDataSO = default;
private DialogueDataSO _currentDialogue = default;
private void Start()
{

public void DisplayDialogueData(DialogueDataSO dialogueDataSO)
{
BeginDialogueData(dialogueDataSO);
DisplayDialogueLine(_currentDialogueDataSO.DialogueLines[_counter], dialogueDataSO.Actor);
DisplayDialogueLine(_currentDialogue.DialogueLines[_counter], dialogueDataSO.Actor);
}
/// <summary>

_counter = 0;
_inputReader.EnableDialogueInput();
_inputReader.advanceDialogueEvent += OnAdvance;
_currentDialogueDataSO = dialogueDataSO;
_currentDialogue = dialogueDataSO;
}
/// <summary>

/// <param name="dialogueLine"></param>
public void DisplayDialogueLine(DialogueLineSO dialogueLine, ActorSO actor)
{
Debug.Log("DisplayDialogueLine");
if(_openUIDialogueEvent!=null)
{
_openUIDialogueEvent.RaiseEvent(dialogueLine, actor);

if (!_reachedEndOfDialogue)
{
DisplayDialogueLine(_currentDialogueDataSO.DialogueLines[_counter], _currentDialogueDataSO.Actor);
DisplayDialogueLine(_currentDialogue.DialogueLines[_counter], _currentDialogue.Actor);
if(_currentDialogueDataSO.Choices.Count > 0)
if(_currentDialogue.Choices.Count > 0)
DisplayChoices(_currentDialogueDataSO.Choices);
DisplayChoices(_currentDialogue.Choices);
}
else
{

{
_makeDialogueChoiceEvent.OnEventRaised -= MakeDialogueChoice;
}
if (choice.NextDialogue != null)
DisplayDialogueData(choice.NextDialogue);
if (choice.ActionType == DialogueActionType.continueWithStep)
{
if(_continueWithStep!=null)
_continueWithStep.RaiseEvent();
if (choice.NextDialogue != null)
DisplayDialogueData(choice.NextDialogue);
}
DialogueEnded();
{
if (choice.NextDialogue != null)
DisplayDialogueData(choice.NextDialogue);
else
DialogueEndedAndCloseDialogueUI();
}
Debug.Log("DialogueEnded");
_endDialogue.RaiseEvent();
_endDialogue.RaiseEvent(_currentDialogue);
Debug.Log("DialogueEnded");
_endDialogue.RaiseEvent();
_endDialogue.RaiseEvent(_currentDialogue);
if (_closeDialogueUIEvent != null)
_closeDialogueUIEvent.RaiseEvent();
_inputReader.advanceDialogueEvent -= OnAdvance;

4
UOP1_Project/Assets/Scripts/Dialogues/DialogueTrigger.cs


public class DialogueTrigger : MonoBehaviour
{
[SerializeField] private DialogueManager _dialogueManager;
[SerializeField] private DialogueDataSO _dialogueData;
[SerializeField] private DialogueManager _dialogueManager =default;
[SerializeField] private DialogueDataSO _dialogueData=default;
private void OnTriggerEnter(Collider other)
{

2
UOP1_Project/Assets/Scripts/Effects/DissolveHelper.cs


public class DissolveHelper : MonoBehaviour
{
[SerializeField] ParticleSystem _dissolveParticlesPrefab;
[SerializeField] ParticleSystem _dissolveParticlesPrefab = default;
[SerializeField] float _dissolveDuration = 1f;
private MeshRenderer _renderer;

19
UOP1_Project/Assets/Scripts/Inventory/CollectibleItem.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
[SerializeField]
private Item currentItem;
[SerializeField] private Item _currentItem=default;
[SerializeField]
private SpriteRenderer[] itemImages;
[SerializeField] private SpriteRenderer[] _itemImages=default;
private void Start()
{
SetItem();

public Item GetItem()
{
Debug.Log("current item " + currentItem);
return currentItem;
Debug.Log("current item " + _currentItem);
return _currentItem;
}

for (int i = 0; i < itemImages.Length; i++)
for (int i = 0; i < _itemImages.Length; i++)
itemImages[i].sprite = currentItem.PreviewImage;
_itemImages[i].sprite = _currentItem.PreviewImage;
}
}

if (other.gameObject.GetComponent<ItemPicker>())
{
other.gameObject.GetComponent<ItemPicker>().PickItem(currentItem);
other.gameObject.GetComponent<ItemPicker>().PickItem(_currentItem);
}

56
UOP1_Project/Assets/Scripts/Inventory/InventoryItemFiller.cs


using UnityEngine.UI;
using TMPro;
using UnityEngine.Localization.Components;
[SerializeField]
private Image itemPreviewImage;
[SerializeField]
private LocalizeStringEvent itemTitle;
[SerializeField]
private TextMeshProUGUI itemCount;
[SerializeField]
private Image bgImage;
[SerializeField]
private Image imgHover;
[SerializeField]
private Image imgSelected;
public ItemStack currentItem;
[SerializeField]
private Button itemButton;
[SerializeField] private Image _itemPreviewImage = default;
[SerializeField] private LocalizeStringEvent _itemTitle = default;
[SerializeField] private TextMeshProUGUI _itemCount = default;
[SerializeField] private Image _bgImage = default;
[SerializeField] private Image _imgHover = default;
[SerializeField] private Image _imgSelected = default;
[HideInInspector] public ItemStack _currentItem = default;
[SerializeField] private Button _itemButton = default;
public void SetItem(ItemStack itemStack, bool isSelected, ItemEventChannelSO selectItemEvent)
{

currentItem = itemStack;
_currentItem = itemStack;
imgSelected.gameObject.SetActive(isSelected);
_imgSelected.gameObject.SetActive(isSelected);
itemPreviewImage.sprite = itemStack.Item.PreviewImage;
itemTitle.StringReference = itemStack.Item.Name;
itemCount.text = itemStack.Amount.ToString();
bgImage.color = itemStack.Item.ItemType.TypeColor;
_itemPreviewImage.sprite = itemStack.Item.PreviewImage;
_itemTitle.StringReference = itemStack.Item.Name;
_itemCount.text = itemStack.Amount.ToString();
_bgImage.color = itemStack.Item.ItemType.TypeColor;
itemButton.onClick.RemoveAllListeners();
_itemButton.onClick.RemoveAllListeners();
itemButton.onClick.AddListener(() =>
_itemButton.onClick.AddListener(() =>
selectItemEvent.RaiseEvent(currentItem.Item);
selectItemEvent.RaiseEvent(_currentItem.Item);
});
}

{
imgHover.gameObject.SetActive(true);
_imgHover.gameObject.SetActive(true);
}

imgHover.gameObject.SetActive(false);
_imgHover.gameObject.SetActive(false);
}

imgSelected.gameObject.SetActive(true);
_imgSelected.gameObject.SetActive(true);
}

imgSelected.gameObject.SetActive(false);
_imgSelected.gameObject.SetActive(false);
}

100
UOP1_Project/Assets/Scripts/Inventory/InventoryManager.cs


public class InventoryManager : MonoBehaviour
{
[SerializeField]
private Inventory currentInventory;
[SerializeField]
private ItemEventChannelSO CookRecipeEvent;
[SerializeField]
private ItemEventChannelSO UseItemEvent;
[SerializeField]
private ItemEventChannelSO EquipItemEvent;
[SerializeField]
private ItemEventChannelSO RewardItemEvent;
[SerializeField]
private ItemEventChannelSO GiveItemEvent;
[SerializeField]
ItemEventChannelSO AddItemEvent;
[SerializeField]
ItemEventChannelSO RemoveItemEvent;
[SerializeField] private Inventory _currentInventory = default;
[SerializeField] private ItemEventChannelSO _cookRecipeEvent = default;
[SerializeField] private ItemEventChannelSO _useItemEvent = default;
[SerializeField] private ItemEventChannelSO _equipItemEvent = default;
[SerializeField] private ItemEventChannelSO _rewardItemEvent = default;
[SerializeField] private ItemEventChannelSO _giveItemEvent = default;
[SerializeField] ItemEventChannelSO _addItemEvent = default;
[SerializeField] ItemEventChannelSO _removeItemEvent = default;
if (CookRecipeEvent != null)
if (_cookRecipeEvent != null)
CookRecipeEvent.OnEventRaised += CookRecipeEventRaised;
_cookRecipeEvent.OnEventRaised += CookRecipeEventRaised;
if (UseItemEvent != null)
if (_useItemEvent != null)
UseItemEvent.OnEventRaised += UseItemEventRaised;
_useItemEvent.OnEventRaised += UseItemEventRaised;
if (EquipItemEvent != null)
if (_equipItemEvent != null)
EquipItemEvent.OnEventRaised += EquipItemEventRaised;
_equipItemEvent.OnEventRaised += EquipItemEventRaised;
if (AddItemEvent != null)
if (_addItemEvent != null)
AddItemEvent.OnEventRaised += AddItem;
_addItemEvent.OnEventRaised += AddItem;
if (RemoveItemEvent != null)
if (_removeItemEvent != null)
RemoveItemEvent.OnEventRaised += RemoveItem;
_removeItemEvent.OnEventRaised += RemoveItem;
if (RewardItemEvent != null)
if (_rewardItemEvent != null)
RewardItemEvent.OnEventRaised += AddItem;
_rewardItemEvent.OnEventRaised += AddItem;
if (GiveItemEvent != null)
if (_giveItemEvent != null)
GiveItemEvent.OnEventRaised += RemoveItem;
_giveItemEvent.OnEventRaised += RemoveItem;
if (CookRecipeEvent != null)
if (_cookRecipeEvent != null)
CookRecipeEvent.OnEventRaised -= CookRecipeEventRaised;
_cookRecipeEvent.OnEventRaised -= CookRecipeEventRaised;
if (UseItemEvent != null)
if (_useItemEvent != null)
UseItemEvent.OnEventRaised -= UseItemEventRaised;
_useItemEvent.OnEventRaised -= UseItemEventRaised;
if (EquipItemEvent != null)
if (_equipItemEvent != null)
EquipItemEvent.OnEventRaised -= EquipItemEventRaised;
_equipItemEvent.OnEventRaised -= EquipItemEventRaised;
if (AddItemEvent != null)
if (_addItemEvent != null)
AddItemEvent.OnEventRaised -= AddItem;
_addItemEvent.OnEventRaised -= AddItem;
if (RemoveItemEvent != null)
if (_removeItemEvent != null)
RemoveItemEvent.OnEventRaised -= RemoveItem;
_removeItemEvent.OnEventRaised -= RemoveItem;
}
}

void AddItemWithUIUpdate(Item item)
{
currentInventory.Add(item);
if (currentInventory.Contains(item))
_currentInventory.Add(item);
if (_currentInventory.Contains(item))
ItemStack itemToUpdate = currentInventory.Items.Find(o => o.Item == item);
ItemStack itemToUpdate = _currentInventory.Items.Find(o => o.Item == item);
// UIManager.Instance.UpdateInventoryScreen(itemToUpdate, false);
}
}

ItemStack itemToUpdate = new ItemStack();
if (currentInventory.Contains(item))
if (_currentInventory.Contains(item))
itemToUpdate = currentInventory.Items.Find(o => o.Item == item);
itemToUpdate = _currentInventory.Items.Find(o => o.Item == item);
currentInventory.Remove(item);
_currentInventory.Remove(item);
bool removeItem = currentInventory.Contains(item);
bool removeItem = _currentInventory.Contains(item);
currentInventory.Add(item);
_currentInventory.Add(item);
currentInventory.Remove(item);
_currentInventory.Remove(item);
}

//find recipe
if (currentInventory.Contains(recipe))
if (_currentInventory.Contains(recipe))
if (currentInventory.hasIngredients(ingredients))
if (_currentInventory.hasIngredients(ingredients))
currentInventory.Remove(ingredients[i].Item, ingredients[i].Amount);
_currentInventory.Remove(ingredients[i].Item, ingredients[i].Amount);
currentInventory.Add(recipe.ResultingDish);
_currentInventory.Add(recipe.ResultingDish);
}
}

2
UOP1_Project/Assets/Scripts/Inventory/ItemInstance.cs


public class ItemInstance : MonoBehaviour
{
[SerializeField]
private Item _item;
private Item _item =default;
public Item Item => _item;
}

8
UOP1_Project/Assets/Scripts/Inventory/ItemPicker.cs


public class ItemPicker : MonoBehaviour
{
[SerializeField]
ItemEventChannelSO AddItemEvent;
[SerializeField] ItemEventChannelSO _addItemEvent = default;
if (AddItemEvent != null)
AddItemEvent.RaiseEvent(item);
if (_addItemEvent != null)
_addItemEvent.RaiseEvent(item);
}
}

4
UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/InventoryTabType.cs


{
[Tooltip("The tab Name that will be displayed in the inventory")]
[SerializeField]
private LocalizedString _tabName;
private LocalizedString _tabName =default;
[SerializeField] private TabType _tabType;
[SerializeField] private TabType _tabType=default;
public LocalizedString TabName => _tabName;
public TabType TabType => _tabType;

13
UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/Item.cs


public class Item : ScriptableObject
{
[Tooltip("The name of the item")]
[SerializeField]
private LocalizedString _name;
[SerializeField] private LocalizedString _name = default;
private Sprite _previewImage;
private Sprite _previewImage = default;
private LocalizedString _description;
private LocalizedString _description = default;
private ItemType _itemType;
private ItemType _itemType = default;
private GameObject _prefab;
private GameObject _prefab = default;
[Tooltip("The list of the ingredients necessary to the recipe")]
[SerializeField]

[SerializeField]
private Item _resultingDish;
private Item _resultingDish = default;

12
UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/ItemType.cs


{
[Tooltip("The action associated with the item type")]
[SerializeField]
private LocalizedString _actionName;
private LocalizedString _actionName=default;
private LocalizedString _typeName;
private LocalizedString _typeName=default;
[SerializeField] private Color _typeColor;
[SerializeField] private Color _typeColor=default;
[SerializeField] private itemInventoryType _type;
[SerializeField] private itemInventoryType _type=default;
[SerializeField] private ItemInventoryActionType _actionType;
[SerializeField] private ItemInventoryActionType _actionType=default;
[SerializeField] private InventoryTabType _tabType;
[SerializeField] private InventoryTabType _tabType=default;
public LocalizedString ActionName => _actionName;
public LocalizedString TypeName => _typeName;

52
UOP1_Project/Assets/Scripts/Inventory/UIInventoryManager.cs


public class UIInventoryManager : MonoBehaviour
{
private Inventory currentInventory;
private Inventory currentInventory = default;
private InventoryItemFiller itemPrefab;
private InventoryItemFiller itemPrefab = default;
private GameObject contentParent;
private GameObject contentParent = default;
private InspectorFiller inspectorFiller;
private InspectorFiller inspectorFiller = default;
private InventoryTypeTabsFiller tabFiller;
private InventoryTypeTabsFiller tabFiller = default;
private InventoryButtonFiller buttonFiller;
private InventoryButtonFiller buttonFiller = default;
InventoryTabType selectedTab;
InventoryTabType selectedTab = default;
private List<InventoryItemFiller> instantiatedGameObjects;
private List<InventoryItemFiller> instantiatedGameObjects = default;
public ItemEventChannelSO CookRecipeEvent;
public ItemEventChannelSO UseItemEvent;
public ItemEventChannelSO EquipItemEvent;
[SerializeField]
private ItemEventChannelSO CookRecipeEvent = default;
[SerializeField]
private ItemEventChannelSO UseItemEvent = default;
[SerializeField]
private ItemEventChannelSO EquipItemEvent = default;
public TabEventChannelSO ChangeTabEvent;
[SerializeField]
private TabEventChannelSO ChangeTabEvent = default;
public ItemEventChannelSO SelectItemEvent;
[SerializeField]
private ItemEventChannelSO SelectItemEvent = default;
public VoidEventChannelSO ActionButtonClicked;
[SerializeField]
private VoidEventChannelSO ActionButtonClicked = default;
public VoidEventChannelSO OnInteractionEndedEvent;
[SerializeField]
private VoidEventChannelSO OnInteractionEndedEvent = default;
private void OnEnable()
{

if (removeItem)
{
if (instantiatedGameObjects.Exists(o => o.currentItem == itemToUpdate))
if (instantiatedGameObjects.Exists(o => o._currentItem == itemToUpdate))
int index = instantiatedGameObjects.FindIndex(o => o.currentItem == itemToUpdate);
int index = instantiatedGameObjects.FindIndex(o => o._currentItem == itemToUpdate);
instantiatedGameObjects[index].gameObject.SetActive(false);
}

{
int index = 0;
//if the item has already been created
if (instantiatedGameObjects.Exists(o => o.currentItem == itemToUpdate))
if (instantiatedGameObjects.Exists(o => o._currentItem == itemToUpdate))
index = instantiatedGameObjects.FindIndex(o => o.currentItem == itemToUpdate);
index = instantiatedGameObjects.FindIndex(o => o._currentItem == itemToUpdate);
}

public void InspectItem(Item itemToInspect)
{
if (instantiatedGameObjects.Exists(o => o.currentItem.Item == itemToInspect))
if (instantiatedGameObjects.Exists(o => o._currentItem.Item == itemToInspect))
int itemIndex = instantiatedGameObjects.FindIndex(o => o.currentItem.Item == itemToInspect);
int itemIndex = instantiatedGameObjects.FindIndex(o => o._currentItem.Item == itemToInspect);
//unselect selected Item

{
//find the item
Item itemToActOn = new Item();
itemToActOn = instantiatedGameObjects[selectedItemId].currentItem.Item;
itemToActOn = instantiatedGameObjects[selectedItemId]._currentItem.Item;
//check the selected Item type
//call action function depending on the itemType

45
UOP1_Project/Assets/Scripts/Quests/QuestManager.cs


[Header("Linstening to channels")]
[SerializeField] private VoidEventChannelSO _checkStepValidityEvent = default;
[SerializeField] private StepChannelSO _endStepEvent = default;
[SerializeField] private VoidEventChannelSO _endStepEvent = default;
[SerializeField] private DialogueDataChannelSO _endDialogueEvent = default;
[Header("Broadcasting on channels")]
[SerializeField] private StepChannelSO _startStepEvent = default;

private int _currentStepIndex =0;
private void Start()
{
Debug.Log("Start");
if ( _endDialogueEvent != null)
{
_endDialogueEvent.OnEventRaised += EndDialogue;
}
Debug.Log("Start Game");
_currentQuestIndex = 0;
if (_quests != null)
{

}
void StartQuest()
{
Debug.Log("Start Quest");
if (_quests != null)
if ( _quests.Count > _currentQuestIndex)
{

void StartStep()
{
Debug.Log("Start step");
if (_currentQuest.Steps!=null)
if (_currentQuest.Steps.Count > _currentStepIndex)
{

{
_winDialogueEvent.OnEventRaised();
}
}
}
else
{
//trigger lose dialogue

break;
case stepType.rewardItem:
_rewardItemEvent.RaiseEvent(_currentStep.Item);
//no dialogue is needed after Reward Item
EndStep();
break;
//no dialogue is needed after Reward Item
EndStep();
break;
//dialogue has already been played
EndStep();
//dialogue has already been played
EndStep();
break;

}
void EndDialogue (DialogueDataSO dialogue)
{
void EndStep()
//depending on the dialogue that ended, do something
switch (dialogue.DialogueType)
{
case DialogueType.winDialogue:
EndStep();
break;
default:
break;
}
}
void EndStep()
{
_currentStep = null;

if (_quests[_currentQuestIndex].Steps.Count > _currentStepIndex)
{
if (_endStepEvent != null)
_endStepEvent.RaiseEvent(_quests[_currentQuestIndex].Steps[_currentStepIndex]);
_endStepEvent.RaiseEvent();
_quests[_currentQuestIndex].Steps[_currentStepIndex].FinishStep();
if(_quests[_currentQuestIndex].Steps.Count > _currentStepIndex +1)
{

40
UOP1_Project/Assets/Scripts/Quests/StepController.cs


[Header("Listening to channels")]
[SerializeField] private StepChannelSO _startStepEvent = default;
[SerializeField] private VoidEventChannelSO _endDialogueEvent = default;
[SerializeField] private DialogueDataChannelSO _endDialogueEvent = default;
[SerializeField] private StepChannelSO _endStepEvent = default;
[SerializeField] private VoidEventChannelSO _continueWithStep = default;
[SerializeField] private VoidEventChannelSO _endStepEvent = default;
[Header("Broadcasting on channels")]
[SerializeField] private VoidEventChannelSO _checkStepValidityEvent = default;

{ _loseDialogueEvent.OnEventRaised += PlayLoseDialogue; }
if (_endStepEvent != null)
{ _endStepEvent.OnEventRaised += EndStep; }
if (_continueWithStep != null)
{ _continueWithStep.OnEventRaised += ContinueWithStep; }
}
//play default dialogue if no step

}
void CheckStepInvolvment(StepSO step)
{
Debug.Log("check involvment");
if(_actor == step.Actor)
{
RegisterStep(step);

//register a step
void RegisterStep(StepSO step)
void RegisterStep(StepSO step)
{
_currentStep = step;
_hasActifStep = true;

//some Steps need to be instantanious. And do not need the interact button.
//when interaction again, restart same dialogue.
void InteractWithCharacter(ActorSO actorToInteractWith)
void InteractWithCharacter(ActorSO actorToInteractWith)
{
if (actorToInteractWith == _actor)
{

{
if (_startDialogueEvent != null)
{
Debug.Log("Start Dialogue ");
_startDialogueEvent.RaiseEvent(_currentDialogue);
}

if (_currentStep != null)
if (_currentStep.LoseDialogue != null)
{
Debug.Log("Play lose Dialogue ");
_currentDialogue = _currentStep.LoseDialogue;
StartDialogue();
}

{
Debug.Log("Play Win Dialogue" + _currentStep.WinDialogue);
if (_currentStep != null)
if (_currentStep.WinDialogue != null)
{

}
//End dialogue
void EndDialogue()
void EndDialogue(DialogueDataSO dialogue)
//depending on the dialogue that ended, do something
switch (_currentDialogue.DialogueType)
//depending on the dialogue that ended, do something. The dialogue type can be different from the current dialogue type
switch (dialogue.DialogueType)
case dialogueType.startDialogue:
case DialogueType.startDialogue:
case dialogueType.winDialogue:
case DialogueType.winDialogue:
case dialogueType.loseDialogue:
case DialogueType.loseDialogue:
//closeDialogue
//replay start Dialogue if the lose Dialogue ended
if (_currentStep.DialogueBeforeStep != null)

}
break;
case dialogueType.defaultDialogue:
case DialogueType.defaultDialogue:
//close Dialogue
//nothing happens if it's the default dialogue
break;

}
void ContinueWithStep()
{
CheckStepValidity();
}
void CheckStepValidity()
{
if(_checkStepValidityEvent!=null)

}
void EndStep(StepSO stepToFinish)
{
Debug.Log("End step " + stepToFinish.name);
if(stepToFinish==_currentStep)
UnregisterStep();
else

16
UOP1_Project/Assets/Scripts/UI/CookingInventoryInspectorFiller.cs


public class CookingInventoryInspectorFiller : MonoBehaviour
{
[SerializeField]
private InspectorPreviewFiller inspectorPreviewFiller;
[SerializeField]
private InspectorDescriptionFiller inspectorDescriptionFiller;
[SerializeField] private InspectorPreviewFiller _inspectorPreviewFiller=default;
[SerializeField]
private RecipeIngredientsFiller recipeIngredientsFiller;
[SerializeField] private InspectorDescriptionFiller _inspectorDescriptionFiller=default;
[SerializeField] private RecipeIngredientsFiller _recipeIngredientsFiller=default;

inspectorPreviewFiller.FillPreview(itemToInspect);
inspectorDescriptionFiller.FillDescription(itemToInspect);
recipeIngredientsFiller.FillIngredients(itemToInspect.IngredientsList, availabilityArray);
_inspectorPreviewFiller.FillPreview(itemToInspect);
_inspectorDescriptionFiller.FillDescription(itemToInspect);
_recipeIngredientsFiller.FillIngredients(itemToInspect.IngredientsList, availabilityArray);
}
}

15
UOP1_Project/Assets/Scripts/UI/IngredientFiller.cs


using UnityEngine;
using UnityEngine.Localization.Components;
using TMPro;
private TextMeshProUGUI ingredientAmount;
private TextMeshProUGUI _ingredientAmount=default;
private LocalizeStringEvent ingredientName;
private LocalizeStringEvent _ingredientName=default;
private GameObject checkMark;
private GameObject _checkMark=default;
ingredientAmount.text = ingredient.Amount.ToString();
ingredientName.StringReference = ingredient.Item.Name;
checkMark.SetActive(isAvailable);
_ingredientAmount.text = ingredient.Amount.ToString();
_ingredientName.StringReference = ingredient.Item.Name;
_checkMark.SetActive(isAvailable);
}
}

15
UOP1_Project/Assets/Scripts/UI/InspectorDescriptionFiller.cs


using UnityEngine.Localization.Components;
[SerializeField]
private LocalizeStringEvent textDescription;
[SerializeField] private LocalizeStringEvent _textDescription = default;
[SerializeField]
private LocalizeStringEvent textName;
[SerializeField] private LocalizeStringEvent _textName=default;
textName.gameObject.SetActive(true);
textDescription.gameObject.SetActive(true);
_textName.gameObject.SetActive(true);
_textDescription.gameObject.SetActive(true);
textName.StringReference = itemToInspect.Name;
textDescription.StringReference = itemToInspect.Description;
_textName.StringReference = itemToInspect.Name;
_textDescription.StringReference = itemToInspect.Description;
}

18
UOP1_Project/Assets/Scripts/UI/InspectorFiller.cs


public class InspectorFiller : MonoBehaviour
{
[SerializeField]
private SimpleInventoryInspectorFiller simpleInventoryInspector;
[SerializeField] private SimpleInventoryInspectorFiller _simpleInventoryInspector = default;
[SerializeField]
private CookingInventoryInspectorFiller cookingInventoryInspector;
[SerializeField] private CookingInventoryInspectorFiller _cookingInventoryInspector=default;
simpleInventoryInspector.gameObject.SetActive(!isForCooking);
cookingInventoryInspector.gameObject.SetActive(isForCooking);
_simpleInventoryInspector.gameObject.SetActive(!isForCooking);
_cookingInventoryInspector.gameObject.SetActive(isForCooking);
simpleInventoryInspector.FillItemInspector(itemToInspect);
_simpleInventoryInspector.FillItemInspector(itemToInspect);
cookingInventoryInspector.FillItemInspector(itemToInspect, availabilityArray);
_cookingInventoryInspector.FillItemInspector(itemToInspect, availabilityArray);
}

{
simpleInventoryInspector.gameObject.SetActive(false);
cookingInventoryInspector.gameObject.SetActive(false);
_simpleInventoryInspector.gameObject.SetActive(false);
_cookingInventoryInspector.gameObject.SetActive(false);
}

6
UOP1_Project/Assets/Scripts/UI/InspectorPreviewFiller.cs


public class InspectorPreviewFiller : MonoBehaviour
{
[SerializeField]
private Image previewImage;
private Image _previewImage =default;
previewImage.gameObject.SetActive(true);
previewImage.sprite = ItemToInspect.PreviewImage;
_previewImage.gameObject.SetActive(true);
_previewImage.sprite = ItemToInspect.PreviewImage;
}

8
UOP1_Project/Assets/Scripts/UI/InventoryButtonFiller.cs


{
[SerializeField]
private LocalizeStringEvent buttonActionText;
private LocalizeStringEvent _buttonActionText = default;
private Button buttonAction;
private Button _buttonAction = default;
public void FillInventoryButtons(ItemType itemType, bool isInteractable = true)

buttonAction.interactable = isInteractable;
_buttonAction.interactable = isInteractable;
buttonActionText.StringReference = itemType.ActionName;
_buttonActionText.StringReference = itemType.ActionName;

14
UOP1_Project/Assets/Scripts/UI/InventoryTypeTabFiller.cs


public class InventoryTypeTabFiller : MonoBehaviour
{
[SerializeField]
private LocalizeStringEvent tabName;
[SerializeField] private LocalizeStringEvent _tabName = default;
[SerializeField]
private Button actionButton;
[SerializeField] private Button _actionButton=default;
tabName.StringReference = tabType.TabName;
actionButton.interactable = !isSelected;
actionButton.onClick.RemoveAllListeners();
actionButton.onClick.AddListener(() => changeTabEvent.RaiseEvent(tabType));
_tabName.StringReference = tabType.TabName;
_actionButton.interactable = !isSelected;
_actionButton.onClick.RemoveAllListeners();
_actionButton.onClick.AddListener(() => changeTabEvent.RaiseEvent(tabType));
}

4
UOP1_Project/Assets/Scripts/UI/ScriptableObject/InteractionSO.cs


{
[Tooltip("The interaction name")]
[SerializeField]
private LocalizedString _interactionName;
private LocalizedString _interactionName =default;
private InteractionType _interactionType;
private InteractionType _interactionType=default;

10
UOP1_Project/Assets/Scripts/UI/SimpleInventoryInspectorFiller.cs


public class SimpleInventoryInspectorFiller : MonoBehaviour
{
[SerializeField]
private InspectorPreviewFiller inspectorPreviewFiller;
[SerializeField] private InspectorPreviewFiller _inspectorPreviewFiller =default;
[SerializeField]
private InspectorDescriptionFiller inspectorDescriptionFiller;
[SerializeField] private InspectorDescriptionFiller _inspectorDescriptionFiller=default;
inspectorPreviewFiller.FillPreview(itemToInspect);
inspectorDescriptionFiller.FillDescription(itemToInspect);
_inspectorPreviewFiller.FillPreview(itemToInspect);
_inspectorDescriptionFiller.FillDescription(itemToInspect);

8
UOP1_Project/Assets/Scripts/UI/UIDialogueChoiceFiller.cs


using UnityEngine;
using TMPro;
using UnityEngine.Localization.Components;
using UnityEngine.Serialization;
[FormerlySerializedAs("choiceText")]
[SerializeField] private LocalizeStringEvent _choiceText;
[FormerlySerializedAs("MakeAChoiceEvent")]
[SerializeField] private DialogueChoiceChannelSO _makeAChoiceEvent;
[SerializeField] private LocalizeStringEvent _choiceText =default;
[SerializeField] private DialogueChoiceChannelSO _makeAChoiceEvent=default;
Choice currentChoice;

7
UOP1_Project/Assets/Scripts/UI/UIDialogueManager.cs


using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.Serialization;
using UnityEngine.Localization.Components;
public class UIDialogueManager : MonoBehaviour
{

[SerializeField] private UIDialogueChoicesManager _choicesManager = default;
[SerializeField] private DialogueChoicesChannelSO ShowChoicesEvent;
[SerializeField] private DialogueChoicesChannelSO _showChoicesEvent = default;
if (ShowChoicesEvent != null)
if (_showChoicesEvent != null)
ShowChoicesEvent.OnEventRaised += ShowChoices;
_showChoicesEvent.OnEventRaised += ShowChoices;
}
}
public void SetDialogue(DialogueLineSO dialogueLine, ActorSO actor)

11
UOP1_Project/Assets/Scripts/UI/UIInteractionItemFiller.cs


public class UIInteractionItemFiller : MonoBehaviour
{
[SerializeField] LocalizeStringEvent _interactionName=default;
[SerializeField]
LocalizeStringEvent interactionName;
[SerializeField]
TextMeshProUGUI interactionKeyButton;
[SerializeField] TextMeshProUGUI _interactionKeyButton=default;
interactionName.StringReference = interactionItem.InteractionName;
interactionKeyButton.text = KeyCode.E.ToString(); // this keycode will be modified later on
_interactionName.StringReference = interactionItem.InteractionName;
_interactionKeyButton.text = KeyCode.E.ToString(); // this keycode will be modified later on
}
}

11
UOP1_Project/Assets/Scripts/UI/UIInteractionManager.cs


public class UIInteractionManager : MonoBehaviour
{
[SerializeField]
private List<InteractionSO> listInteractions;
private List<InteractionSO> _listInteractions =default;
private UIInteractionItemFiller interactionItem;
private UIInteractionItemFiller _interactionItem=default;
if ((listInteractions != null) && (interactionItem != null))
if (listInteractions.Exists(o => o.InteractionType == interactionType))
if ((_listInteractions != null) && (_interactionItem != null))
if (_listInteractions.Exists(o => o.InteractionType == interactionType))
interactionItem.FillInteractionPanel(listInteractions.Find(o => o.InteractionType == interactionType));
_interactionItem.FillInteractionPanel(_listInteractions.Find(o => o.InteractionType == interactionType));
}
}

10
UOP1_Project/Assets/Scripts/UI/UIManager.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
[FormerlySerializedAs("OpenUIDialogueEvent")]
[FormerlySerializedAs("CloseUIDialogueEvent")]
[FormerlySerializedAs("ShowChoicesUIEvent")]
[SerializeField] private DialogueChoicesChannelSO _showChoicesUIEvent = default;
[FormerlySerializedAs("OpenInventoryScreenEvent")]
[FormerlySerializedAs("OpenInventoryScreenForCookingEvent")]
[FormerlySerializedAs("CloseInventoryScreenEvent")]
[FormerlySerializedAs("OnInteractionEndedEvent")]
[FormerlySerializedAs("SetInteractionEvent")]
[SerializeField] private InteractionUIEventChannelSO _setInteractionEvent = default;
private void OnEnable()

15
UOP1_Project/Assets/ScriptableObjects/Events/Quests/ContinueStepEvent.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7fafac715ff920c4383fed91a38a351e, type: 3}
m_Name: ContinueStepEvent
m_EditorClassIdentifier:
description:

8
UOP1_Project/Assets/ScriptableObjects/Events/Quests/ContinueStepEvent.asset.meta


fileFormatVersion: 2
guid: 6711182c372e2e94a8bd3fd1868223ec
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存