Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Quest : ScriptableObject
- {
- [SerializeField] List<Objective> objectives = new List<Objective>();
- [SerializeField] List<Reward> rewards = new List<Reward>();
- [System.Serializable]
- public class Reward
- {
- [Min(1)]
- public int number;
- public InventoryItem item;
- }
- [System.Serializable]
- public class Objective
- {
- public string reference;
- public string description;
- public bool usesCondition = false;
- public Condition completionCondition;
- }
- public string GetTitle()
- {
- return name;
- }
- public int GetObjectiveCount()
- {
- return objectives.Count;
- }
- public IEnumerable<Objective> GetObjectives()
- {
- return objectives;
- }
- public IEnumerable<Reward> GetRewards()
- {
- return rewards;
- }
- public bool HasObjective(string objectiveRef)
- {
- foreach (var objective in objectives)
- {
- if(objective.reference == objectiveRef)
- {
- return true;
- }
- }
- return false;
- }
- private static Dictionary<string, Quest> masterQuestDictionary;
- public static Quest GetByName(string questName)
- {
- if (masterQuestDictionary == null)
- {
- masterQuestDictionary = new Dictionary<string, Quest>();
- foreach (Quest quest in Resources.LoadAll<Quest>(""))
- {
- if (masterQuestDictionary.ContainsKey(quest.name)) Debug.Log($"There are two {quest.name} quests in the system");
- else masterQuestDictionary.Add(quest.name, quest);
- }
- }
- return masterQuestDictionary.ContainsKey(questName) ? masterQuestDictionary[questName] : null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment