Implemet quest completion

This commit is contained in:
2023-07-09 00:10:43 +02:00
parent 30d9d7f1ec
commit a9fbeef0b4
8 changed files with 1008 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices.WindowsRuntime;
using UnityEngine;
public class QuestManager : MonoBehaviour
@@ -8,8 +9,7 @@ public class QuestManager : MonoBehaviour
public int activeQuest = 0;
public Quest[] quests = {
new Quest(_name: "Advert Quest 1", _desc: "Find someone to hand out flyers to advertise our tavern to adventurers. Strength, dexterity, intelligence: doesn<73>t matter, find someone who would do this for as little money as possible.", _failedStr: "Damn, that didn<64>t work at all. That robot just randomly started playing an instrument, much to the dismay of the townspeople.", _strength: 0, _intelligence: 0, _charisma: 5),
new Quest(_name: "Advert Quest 1", _desc: "Find someone to hand out flyers to advertise our tavern to adventurers. Strength, dexterity, intelligence: doesn<73>t matter, find someone who would do this for as little money as possible.", _failedStr: "Damn, that didn<64>t work at all. That robot just randomly started playing an instrument, much to the dismay of the townspeople.", _successStr: "Perfect, this place will be full of adventurers in no time.", _strength: 0, _intelligence: 0, _charisma: 5),
};
private void Awake()
@@ -39,6 +39,43 @@ public class QuestManager : MonoBehaviour
return quests[activeQuest];
}
public bool RunQuestWithAdventurer(CharacterData characterData, Quest quest)
{
if (characterData.m_charisma < quest.charisma)
{
Debug.Log("Character failed charisma check");
return false;
}
if (characterData.m_strength < quest.strength)
{
Debug.Log("Character failed strength check");
return false;
}
if (characterData.m_intelligence < quest.intelligence)
{
Debug.Log("Character failed intlligence check");
return false;
}
return true;
}
public void NextQuest()
{
activeQuest++;
if (activeQuest >= quests.Length)
{
Debug.Log("All quests completed");
}
foreach (var adventurer in Resources.FindObjectsOfTypeAll<AdventurerInteractable>())
{
if (adventurer.m_spawnQuestID == activeQuest)
{
adventurer.gameObject.SetActive(true);
}
}
}
}
[System.Serializable]
@@ -46,14 +83,16 @@ public class Quest
{
public string name;
public string description;
public string successStr;
public string failedStr;
public int strength, intelligence, charisma;
public Quest(string _name, string _desc, string _failedStr, int _strength, int _intelligence, int _charisma)
public Quest(string _name, string _desc, string _failedStr, string _successStr, int _strength, int _intelligence, int _charisma)
{
this.name = _name;
this.description = _desc;
this.failedStr = _failedStr;
this.successStr = _successStr;
this.strength = _strength;
this.intelligence = _intelligence;
this.charisma = _charisma;