浏览代码

Changed Events to Event Channels

/main
Chema Damak 4 年前
当前提交
8871d820
共有 27 个文件被更改,包括 121 次插入138 次删除
  1. 8
      UOP1_Project/Assets/Prefabs/UI/Button.prefab
  2. 35
      UOP1_Project/Assets/Scenes/UI Scene.unity
  3. 2
      UOP1_Project/Assets/ScriptableObjects/Events/UI/AddInventoryItemEvent.asset
  4. 2
      UOP1_Project/Assets/ScriptableObjects/Events/UI/CookRecipe.asset
  5. 2
      UOP1_Project/Assets/ScriptableObjects/Events/UI/EquipInventoryItem.asset
  6. 2
      UOP1_Project/Assets/ScriptableObjects/Events/UI/RemoveInventoryItemEvent.asset
  7. 2
      UOP1_Project/Assets/ScriptableObjects/Events/UI/SelectInventoryItemEvent.asset
  8. 2
      UOP1_Project/Assets/ScriptableObjects/Events/UI/UseInventoryItem.asset
  9. 4
      UOP1_Project/Assets/Scripts/Dialogues/DialogueManager.cs
  10. 24
      UOP1_Project/Assets/Scripts/Inventory/InventoryFiller.cs
  11. 4
      UOP1_Project/Assets/Scripts/Inventory/InventoryItemFiller.cs
  12. 30
      UOP1_Project/Assets/Scripts/Inventory/InventoryManager.cs
  13. 4
      UOP1_Project/Assets/Scripts/Inventory/ItemPicker.cs
  14. 4
      UOP1_Project/Assets/Scripts/UI/InventoryTypeTabFiller.cs
  15. 2
      UOP1_Project/Assets/Scripts/UI/InventoryTypeTabsFiller.cs
  16. 4
      UOP1_Project/Assets/Scripts/UI/UIManager.cs
  17. 8
      UOP1_Project/Assets/Inventory/Scripts.meta
  18. 15
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineChannelSO.cs
  19. 15
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/TabEventChannelSo.cs
  20. 11
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/ItemEvent.cs.meta
  21. 11
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/ItemTypeEvent.cs.meta
  22. 17
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineEvent.cs
  23. 17
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/ItemEvent.cs
  24. 17
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/TabTypeEvent.cs
  25. 17
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/ItemTypeEvent.cs
  26. 0
      /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineChannelSO.cs.meta
  27. 0
      /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/TabEventChannelSo.cs.meta

8
UOP1_Project/Assets/Prefabs/UI/Button.prefab


m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Inventory
m_text: X
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6063084967698345726}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 56eb0353ae6e5124bb35b17aff880f16, type: 3}
m_Name:

m_TableCollectionName: GUID:7e97a5d681d6e4480b18b504a66e69b2
m_TableCollectionName:
m_KeyId: 8945393664
m_KeyId: 0
m_Key:
m_FormatArguments: []
m_UpdateString:

35
UOP1_Project/Assets/Scenes/UI Scene.unity


propertyPath: m_Name
value: Button Inventory
objectReference: {fileID: 0}
- target: {fileID: 3451373362961513096, guid: b01383ebcda1049008a325f2ca7e6aca,
type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3451373362961513096, guid: b01383ebcda1049008a325f2ca7e6aca,
type: 3}
propertyPath: m_StringReference.m_TableReference.m_TableCollectionName
value: GUID:7e97a5d681d6e4480b18b504a66e69b2
objectReference: {fileID: 0}
- target: {fileID: 3451373362961513096, guid: b01383ebcda1049008a325f2ca7e6aca,
type: 3}
propertyPath: m_StringReference.m_TableEntryReference.m_KeyId
value: 8945393664
objectReference: {fileID: 0}
- target: {fileID: 5795051186182416585, guid: b01383ebcda1049008a325f2ca7e6aca,
type: 3}
propertyPath: m_text
value: Inventory
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b01383ebcda1049008a325f2ca7e6aca, type: 3}
--- !u!224 &828170414 stripped

type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: RaiseEvent
objectReference: {fileID: 0}
- target: {fileID: 1575787593498220194, guid: 42ed5ae1f90714c4488cfabda2298591,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: RaiseEvent
objectReference: {fileID: 0}
- target: {fileID: 3371382726859284656, guid: 42ed5ae1f90714c4488cfabda2298591,
type: 3}
propertyPath: m_text
value:
objectReference: {fileID: 0}
- target: {fileID: 5854709384753378033, guid: 42ed5ae1f90714c4488cfabda2298591,
type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9125883718042355530, guid: 42ed5ae1f90714c4488cfabda2298591,
type: 3}

2
UOP1_Project/Assets/ScriptableObjects/Events/UI/AddInventoryItemEvent.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d705ad908320412db32d02867406c21, type: 3}
m_Script: {fileID: 11500000, guid: 27ee1f4193e7cac488aad6442034451d, type: 3}
m_Name: AddInventoryItemEvent
m_EditorClassIdentifier:

2
UOP1_Project/Assets/ScriptableObjects/Events/UI/CookRecipe.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d705ad908320412db32d02867406c21, type: 3}
m_Script: {fileID: 11500000, guid: 27ee1f4193e7cac488aad6442034451d, type: 3}
m_Name: CookRecipe
m_EditorClassIdentifier:

2
UOP1_Project/Assets/ScriptableObjects/Events/UI/EquipInventoryItem.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d705ad908320412db32d02867406c21, type: 3}
m_Script: {fileID: 11500000, guid: 27ee1f4193e7cac488aad6442034451d, type: 3}
m_Name: EquipInventoryItem
m_EditorClassIdentifier:

2
UOP1_Project/Assets/ScriptableObjects/Events/UI/RemoveInventoryItemEvent.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d705ad908320412db32d02867406c21, type: 3}
m_Script: {fileID: 11500000, guid: 27ee1f4193e7cac488aad6442034451d, type: 3}
m_Name: RemoveInventoryItemEvent
m_EditorClassIdentifier:

2
UOP1_Project/Assets/ScriptableObjects/Events/UI/SelectInventoryItemEvent.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d705ad908320412db32d02867406c21, type: 3}
m_Script: {fileID: 11500000, guid: 27ee1f4193e7cac488aad6442034451d, type: 3}
m_Name: SelectInventoryItemEvent
m_EditorClassIdentifier:

2
UOP1_Project/Assets/ScriptableObjects/Events/UI/UseInventoryItem.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d705ad908320412db32d02867406c21, type: 3}
m_Script: {fileID: 11500000, guid: 27ee1f4193e7cac488aad6442034451d, type: 3}
m_Name: UseInventoryItem
m_EditorClassIdentifier:

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


public class DialogueManager : MonoBehaviour
{
[SerializeField] private InputReader _inputReader = default;
[SerializeField] DialogueLineEvent dialogueLineEvent;
[SerializeField] DialogueLineChannelSO dialogueLineEvent;
/// <summary>
/// Called to begin a dialogue, i.e. a sequence of lines that require the player's input to move forward.
/// </summary>

{
//TODO: Interface with a UIManager to allow displayal of the line of dialogue in the UI
//Debug.Log("A line of dialogue has been spoken: \"" + dialogueLine.Sentence + "\" by " + dialogueLine.Actor.ActorName);
dialogueLineEvent.Raise(dialogueLine);
dialogueLineEvent.OnEventRaised(dialogueLine);
}
}

24
UOP1_Project/Assets/Scripts/Inventory/InventoryFiller.cs


private List<InventoryItemFiller> instantiatedGameObjects;
public ItemEvent CookRecipeEvent;
public ItemEvent UseItemEvent;
public ItemEvent EquipItemEvent;
public ItemEventChannelSo CookRecipeEvent;
public ItemEventChannelSo UseItemEvent;
public ItemEventChannelSo EquipItemEvent;
public TabTypeEvent ChangeTabEvent;
public TabEventChannelSo ChangeTabEvent;
public ItemEvent SelectItemEvent;
public ItemEventChannelSo SelectItemEvent;
public VoidEventChannelSO ActionButtonClicked;

}
if (ChangeTabEvent != null)
{
ChangeTabEvent.eventRaised += ChangeTabEventRaised;
ChangeTabEvent.OnEventRaised += ChangeTabEventRaised;
SelectItemEvent.eventRaised += InspectItem;
SelectItemEvent.OnEventRaised += InspectItem;
}
}

}
if (ChangeTabEvent != null)
{
ChangeTabEvent.eventRaised -= ChangeTabEventRaised;
ChangeTabEvent.OnEventRaised -= ChangeTabEventRaised;
SelectItemEvent.eventRaised -= InspectItem;
SelectItemEvent.OnEventRaised -= InspectItem;
}
}

{
Debug.Log("USE ITEM " + itemToUse.name);
UseItemEvent.Raise(itemToUse);
UseItemEvent.OnEventRaised(itemToUse);
//update inventory
FillInventory();
}

{
Debug.Log("Equip ITEM " + itemToUse.name);
EquipItemEvent.Raise(itemToUse);
EquipItemEvent.OnEventRaised(itemToUse);
}
void CookRecipe(Item recipeToCook)

CookRecipeEvent.Raise(recipeToCook);
CookRecipeEvent.OnEventRaised(recipeToCook);
//update inspector
InspectItem(recipeToCook);

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


[SerializeField]
private Button itemButton;
public void SetItem(ItemStack itemStack, bool isSelected, ItemEvent selectItemEvent)
public void SetItem(ItemStack itemStack, bool isSelected, ItemEventChannelSo selectItemEvent)
{
UnhoverItem();

{
SelectItem();
UnhoverItem();
selectItemEvent.Raise(currentItem.Item);
selectItemEvent.RaiseEvent(currentItem.Item);
});
}

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


private Inventory currentInventory;
[SerializeField]
private ItemEvent CookRecipeEvent;
private ItemEventChannelSo CookRecipeEvent;
private ItemEvent UseItemEvent;
private ItemEventChannelSo UseItemEvent;
private ItemEvent EquipItemEvent;
private ItemEventChannelSo EquipItemEvent;
ItemEvent AddItemEvent;
ItemEventChannelSo AddItemEvent;
ItemEvent RemoveItemEvent;
ItemEventChannelSo RemoveItemEvent;
private void OnEnable()
{

CookRecipeEvent.eventRaised += CookRecipeEventRaised;
CookRecipeEvent.OnEventRaised += CookRecipeEventRaised;
UseItemEvent.eventRaised += UseItemEventRaised;
UseItemEvent.OnEventRaised += UseItemEventRaised;
EquipItemEvent.eventRaised += EquipItemEventRaised;
EquipItemEvent.OnEventRaised += EquipItemEventRaised;
AddItemEvent.eventRaised += AddItem;
AddItemEvent.OnEventRaised += AddItem;
RemoveItemEvent.eventRaised += RemoveItem;
RemoveItemEvent.OnEventRaised += RemoveItem;
}
}

{
CookRecipeEvent.eventRaised -= CookRecipeEventRaised;
CookRecipeEvent.OnEventRaised -= CookRecipeEventRaised;
UseItemEvent.eventRaised -= UseItemEventRaised;
UseItemEvent.OnEventRaised -= UseItemEventRaised;
EquipItemEvent.eventRaised -= EquipItemEventRaised;
EquipItemEvent.OnEventRaised -= EquipItemEventRaised;
AddItemEvent.eventRaised -= AddItem;
AddItemEvent.OnEventRaised -= AddItem;
RemoveItemEvent.eventRaised -= RemoveItem;
RemoveItemEvent.OnEventRaised -= RemoveItem;
}
}

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


{
[SerializeField]
ItemEvent AddItemEvent;
ItemEventChannelSo AddItemEvent;
AddItemEvent.Raise(item);
AddItemEvent.RaiseEvent(item);
}
}

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


[SerializeField]
private Button actionButton;
public void fillTab(InventoryTabType tabType, bool isSelected, TabTypeEvent changeTabEvent)
public void fillTab(InventoryTabType tabType, bool isSelected, TabEventChannelSo changeTabEvent)
actionButton.onClick.AddListener(() => changeTabEvent.Raise(tabType));
actionButton.onClick.AddListener(() => changeTabEvent.RaiseEvent(tabType));
}

2
UOP1_Project/Assets/Scripts/UI/InventoryTypeTabsFiller.cs


[SerializeField]
private List<InventoryTypeTabFiller> instantiatedGameObjects;
public void FillTabs(List<InventoryTabType> typesList, InventoryTabType selectedType, TabTypeEvent changeTabEvent)
public void FillTabs(List<InventoryTabType> typesList, InventoryTabType selectedType, TabEventChannelSo changeTabEvent)
{
if (instantiatedGameObjects == null)

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


public class UIManager : MonoBehaviour
{
public DialogueLineEvent OpenUIDialogueEvent;
public DialogueLineChannelSO OpenUIDialogueEvent;
public VoidEventChannelSO CloseUIDialogueEvent;
public VoidEventChannelSO OpenInventoryScreenEvent;

//Check if the event exists to avoid errors
if (OpenUIDialogueEvent != null)
{
OpenUIDialogueEvent.eventRaised += OpenUIDialogue;
OpenUIDialogueEvent.OnEventRaised += OpenUIDialogue;
}
if (CloseUIDialogueEvent != null)
{

8
UOP1_Project/Assets/Inventory/Scripts.meta


fileFormatVersion: 2
guid: ae042d26dee93eb4ea906e8b3335ca9d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineChannelSO.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(menuName = "Events/UI/Dialogue line Channel")]
public class DialogueLineChannelSO : ScriptableObject
{
public UnityAction<DialogueLineSO> OnEventRaised;
public void RaiseEvent(DialogueLineSO line)
{
if (OnEventRaised != null)
OnEventRaised.Invoke(line);
}
}

15
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/TabEventChannelSo.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(menuName = "Events/UI/Inventory Tab Event Channel")]
public class TabEventChannelSo : ScriptableObject
{
public UnityAction<InventoryTabType> OnEventRaised;
public void RaiseEvent(InventoryTabType item)
{
if (OnEventRaised != null)
OnEventRaised.Invoke(item);
}
}

11
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/ItemEvent.cs.meta


fileFormatVersion: 2
guid: 2d705ad908320412db32d02867406c21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/ItemTypeEvent.cs.meta


fileFormatVersion: 2
guid: d46288ce342204901b327fdde5a4d5e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

17
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineEvent.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(fileName = "dialogueEvent", menuName = "UI Event/dialogueLineEvent")]
public class DialogueLineEvent : ScriptableObject
{
public UnityAction<DialogueLineSO> eventRaised;
public void Raise(DialogueLineSO dialogueLine)
{
if (eventRaised != null)
eventRaised.Invoke(dialogueLine);
}
}

17
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/ItemEvent.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(fileName = "itemEvent", menuName = "UI Event/itemEvent")]
public class ItemEvent : ScriptableObject
{
public UnityAction<Item> eventRaised;
public void Raise(Item item)
{
if (eventRaised != null)
eventRaised.Invoke(item);
}
}

17
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/TabTypeEvent.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(fileName = "tabTypeEvent", menuName = "UI Event/tabTypeEvent")]
public class TabTypeEvent : ScriptableObject
{
public UnityAction<InventoryTabType> eventRaised;
public void Raise(InventoryTabType tabType)
{
if (eventRaised != null)
eventRaised.Invoke(tabType);
}
}

17
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/ItemTypeEvent.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
//[CreateAssetMenu(fileName = "itemTypeEvent", menuName = "UI Event/itemTypeEvent")]
//public class ItemTypeEvent : ScriptableObject
//{
// public UnityAction<ItemType> eventRaised;
// public void Raise(ItemType itemType)
// {
// if (eventRaised != null)
// eventRaised.Invoke(itemType);
// }
//}

/UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineEvent.cs.meta → /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineChannelSO.cs.meta

/UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/TabTypeEvent.cs.meta → /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/TabEventChannelSo.cs.meta

正在加载...
取消
保存