浏览代码

Basis for QuestSystem WIP

/main
uChema 4 年前
当前提交
f9f6593b
共有 15 个文件被更改,包括 326 次插入11 次删除
  1. 2
      UOP1_Project/Assets/Art/Accessories/EarCurls/earCurls.mat
  2. 2
      UOP1_Project/Assets/Art/Accessories/Moustache/moustache.mat
  3. 13
      UOP1_Project/Assets/Scripts/Inventory/InventoryManager.cs
  4. 8
      UOP1_Project/Assets/AddressableAssetsData/Windows.meta
  5. 8
      UOP1_Project/Assets/Quests.meta
  6. 47
      UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/TaskSO.cs
  7. 11
      UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/TaskSO.cs.meta
  8. 100
      UOP1_Project/Assets/Quests/QuestManager.cs
  9. 11
      UOP1_Project/Assets/Quests/QuestManager.cs.meta
  10. 15
      UOP1_Project/Assets/Quests/QuestSO.cs
  11. 11
      UOP1_Project/Assets/Quests/QuestSO.cs.meta
  12. 90
      UOP1_Project/Assets/Quests/TaskManager.cs
  13. 11
      UOP1_Project/Assets/Quests/TaskManager.cs.meta
  14. 8
      UOP1_Project/Assets/Scenes/Skybox/ClearSky.meta

2
UOP1_Project/Assets/Art/Accessories/EarCurls/earCurls.mat


m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: EarCurls
m_Name: earCurls
m_Shader: {fileID: -6465566751694194690, guid: bf36778a400a0894b86a1f49c422fa62,
type: 3}
m_ShaderKeywords:

2
UOP1_Project/Assets/Art/Accessories/Moustache/moustache.mat


m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Moustache
m_Name: moustache
m_Shader: {fileID: -6465566751694194690, guid: c2f57d091fa8e17459a737c31526637b,
type: 3}
m_ShaderKeywords:

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


[SerializeField]
private ItemEventChannelSo EquipItemEvent;
[SerializeField]
private ItemEventChannelSo RewardItemEvent;
[SerializeField]
private ItemEventChannelSo GiveItemEvent;
[SerializeField]
ItemEventChannelSo AddItemEvent;

if (RemoveItemEvent != null)
{
RemoveItemEvent.OnEventRaised += RemoveItem;
}
if (RewardItemEvent != null)
{
RewardItemEvent.OnEventRaised += AddItem;
}
if (GiveItemEvent != null)
{
GiveItemEvent.OnEventRaised += RemoveItem;
}
}

8
UOP1_Project/Assets/AddressableAssetsData/Windows.meta


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

8
UOP1_Project/Assets/Quests.meta


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

47
UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/TaskSO.cs


using System.Collections.Generic;
using UnityEngine;
public enum taskType
{
dialogue,
giveItem,
checkItem,
rewardItem
}
[CreateAssetMenu(fileName = "Task", menuName = "Missions/Task", order = 51)]
public class TaskSO : ScriptableObject
{
[SerializeField]
private bool _isInstantanious;
[Tooltip("The Character this mission will need interaction with")]
[SerializeField]
private ActorSO _actor;
[SerializeField]
private List <DialogueLineSO> _dialogue;
[SerializeField]
private Item _item;
[SerializeField]
private taskType _type;
[SerializeField]
VoidEventChannelSO _startDialogue;
[SerializeField]
VoidEventChannelSO _endDialogue;
bool _isDone=false;
public List<DialogueLineSO> Dialogue => _dialogue;
public Item Item => _item;
public taskType Type => _type;
public bool IsDone => _isDone;
public ActorSO Actor => _actor;
public bool IsInstantanious => _isInstantanious;
public VoidEventChannelSO StartDialogue => _startDialogue ;
public VoidEventChannelSO EndDialogue=> _endDialogue;
public void FinishTask()
{
_isDone = true;
}
}

11
UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/TaskSO.cs.meta


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

100
UOP1_Project/Assets/Quests/QuestManager.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuestManager : MonoBehaviour
{
public List<QuestSO> Quests = new List<QuestSO>();
public Inventory inventory;
public ItemEventChannelSo GiveItemEvent;
public ItemEventChannelSo RewardItemEvent;
QuestSO currentQuest;
TaskSO currentTask;
int currentQuestIndex=0;
int currentTaskIndex=0;
private void Start()
{
EndTask();
}
public void StartQuest()
{
if( Quests.Count > currentQuestIndex)
{
currentQuest = Quests[currentQuestIndex];
StartTask();
}
}
public void StartTask()
{
if (currentQuest.Tasks.Count > currentTaskIndex)
{
currentTask = currentQuest.Tasks[currentTaskIndex];
switch (currentTask.Type)
{
case taskType.checkItem:
if (inventory.Contains(currentTask.Item))
{
inventory.Contains(currentTask.Item);
EndTask();
}
else
{ PlayDefaultDialogue(currentTask.Dialogue); }
break;
case taskType.giveItem:
if (inventory.Contains(currentTask.Item))
{
GiveItemEvent.RaiseEvent(currentTask.Item);
EndTask();
}
else
{ PlayDefaultDialogue(currentTask.Dialogue); }
break;
case taskType.rewardItem:
RewardItemEvent.RaiseEvent(currentTask.Item);
EndTask();
break;
case taskType.dialogue:
StartDialogue(currentTask.Dialogue);
break;
}
}
}
public void StartDialogue (List<DialogueLineSO> Dialogue) {
//check location
//find the actor
//Add the dialogue on the actor
//subscribe to the dialogue end event
}
public void PlayDefaultDialogue(List<DialogueLineSO> Dialogue)
{
//check location
//find the actor
//Add the dialogue on the actor
//subscribe to the dialogue end event
}
public void EndTask()
{
currentTask.FinishTask();
Debug.Log(Quests[currentQuestIndex].Tasks[currentTaskIndex].IsDone);
}
public void EndQuest()
{
}
}

11
UOP1_Project/Assets/Quests/QuestManager.cs.meta


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

15
UOP1_Project/Assets/Quests/QuestSO.cs


using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Quest", menuName = "Quests/Quest", order = 51)]
public class QuestSO : ScriptableObject
{
[Tooltip("The collection of Tasks composing the Quest")]
[SerializeField]
private List<TaskSO> _tasks = new List<TaskSO>();
public List<TaskSO> Tasks => _tasks;
}

11
UOP1_Project/Assets/Quests/QuestSO.cs.meta


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

90
UOP1_Project/Assets/Quests/TaskManager.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//this script needs to be put on the actor, and takes care of the current task to accomplish.
//the task contains a dialogue and maybe an event.
public class TaskManager : MonoBehaviour
{
public List<DialogueLineSO> DefaultDialogue;
//check if character is actif. An actif character is the character concerned by the task.
public bool hasActifTask;
TaskSO currentTask;
List<DialogueLineSO> currentDialogue;
//play default dialogue if no task
public void PlayDefaultDialogue()
{
}
//register a task
public void RegisterTask(TaskSO task)
{
currentTask = task;
hasActifTask = true;
if (currentTask.Dialogue != null)
{
currentDialogue = currentTask.Dialogue;
if(currentTask.IsInstantanious)
{
StartDialogue();
}
}
}
//start a dialogue when interaction
//some tasks need to be instantanious. And do not need the interact button.
//when interaction again, restart same dialogue.
public void InteractWithCharacter()
{
if(hasActifTask)
{
AchieveTask();
}
else
{
PlayDefaultDialogue();
}
}
public void AchieveTask()
{
}
public void StartDialogue()
{
}
//next line dialogue
//End dialogue
public void EndDialogue()
{
}
//unregister a task when it ends.
public void UnregisterTask()
{
currentTask = null;
hasActifTask = false;
currentDialogue = null;
}
}

11
UOP1_Project/Assets/Quests/TaskManager.cs.meta


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

8
UOP1_Project/Assets/Scenes/Skybox/ClearSky.meta


fileFormatVersion: 2
guid: b54dcdb53f77f3843ab02db68eaa42f6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存