Merge Journal, Quest and Dialog systems

This commit is contained in:
2023-07-08 21:08:01 +02:00
parent 8ed8fcd04f
commit 8210ef30ac
12 changed files with 1849 additions and 84 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AdventurerInteractable : MonoBehaviour
{
public DialogueController dialogueController;
[SerializeField] private string m_name = string.Empty;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnMouseDown()
{
PlayerController.Instance.cameraMovement = false;
CharacterData character = CharacterManager.Instance.GetCharacterDataByName(m_name);
dialogueController.DisplayCharacterText(character);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a7fa9a36f8ebb0f4fa2ea09dac222d2d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AdventurerManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a0025e0659889a54c8e7b136b75e4254
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using UnityEngine;
public class CharacterManager : MonoBehaviour
@@ -35,4 +36,9 @@ public class CharacterManager : MonoBehaviour
{
m_interviewed.Add(name, true);
}
public CharacterData GetCharacterDataByName(string name)
{
return m_characterDatas.Where(i => i.m_name == name).FirstOrDefault();
}
}

View File

@@ -8,10 +8,13 @@ public class DialogueController : MonoBehaviour
private int m_currentIndex = 0;
public bool DialogueInProgress => m_dialoguePanel.gameObject.activeSelf;
// DEBUG - Will need replacing with the character you selected.
private void Start()
{
DisplayCharacterText(CharacterManager.Instance.CharacterDatas[m_currentIndex]);
//DisplayCharacterText(CharacterManager.Instance.CharacterDatas[m_currentIndex]);
m_dialoguePanel.OnQuestionsFinished += OnQuestionsFinished;
}
@@ -27,6 +30,7 @@ public class DialogueController : MonoBehaviour
CharacterManager.Instance.SetInterviewed(characterName);
PlayerController.Instance.cameraMovement = true;
// TODO: stop the dialogue and return to gameplay...
// TODO: we could probably show a "Quit" button highlighted.
}

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a7d6a699566d0234aae77a22105ba6b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -4,14 +4,13 @@ using System.Linq;
using TMPro;
using UnityEngine;
public class QuestLogInteractable : MonoBehaviour
public class Journal : MonoBehaviour
{
public GameObject journal;
public PlayerController playerController;
private List<CharacterData> m_availableAdventurers = new List<CharacterData>();
public Transform adventurerPage;
public Transform questPage;
// Start is called before the first frame update
void Start()
{
@@ -27,27 +26,30 @@ public class QuestLogInteractable : MonoBehaviour
private void OnMouseDown()
{
Debug.Log("MOUSE DOWN ON INVENTORY");
m_availableAdventurers.Clear();
foreach (var character in CharacterManager.Instance.CharacterDatas)
{
if (CharacterManager.Instance.CharacterInterviewed(character.name)) {
m_availableAdventurers.Append(character);
Debug.Log("Available Adventurer:" + character.name);
m_availableAdventurers.Add(character);
}
}
SetJournalQuestPage();
journal.SetActive(true);
if (m_availableAdventurers.Count > 0)
{
SetJournalAdventurerPage(0);
adventurerPage.gameObject.SetActive(true);
}
playerController.cameraMovement = false;
journal.SetActive(true);
PlayerController.Instance.cameraMovement = false;
}
public void CloseJournal()
{
journal.SetActive(false);
adventurerPage.gameObject.SetActive(false);
playerController.cameraMovement = true;
PlayerController.Instance.cameraMovement = true;
}
public void SetJournalAdventurerPage(int id)
@@ -56,4 +58,11 @@ public class QuestLogInteractable : MonoBehaviour
TMP_Text nameLabel = adventurerPage.Find("AdventurerName").gameObject.GetComponent<TMP_Text>();
nameLabel.text = chara.m_name;
}
public void SetJournalQuestPage()
{
Quest quest = QuestManager.Instance.GetActiveQuest();
questPage.Find("QuestName").gameObject.GetComponent<TMP_Text>().text = quest.name;
questPage.Find("QuestDescription").gameObject.GetComponent<TMP_Text>().text = quest.description;
}
}

View File

@@ -4,15 +4,24 @@ using UnityEngine;
public class PlayerController : MonoBehaviour
{
public static PlayerController Instance;
public Vector3 forward;
public Camera playerCam;
public float xLimit = 45;
public float yLimit = 25;
public bool cameraMovement = true;
// Start is called before the first frame update
void Start()
{
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Debug.LogWarning("There can only be one instance of the CharacterManager class");
}
}
// Update is called once per frame

View File

@@ -4,12 +4,26 @@ using UnityEngine;
public class QuestManager : MonoBehaviour
{
public static QuestManager Instance;
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),
};
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Debug.LogWarning("There can only be one instance of the CharacterManager class");
}
}
// Start is called before the first frame update
void Start()
{
@@ -20,11 +34,11 @@ public class QuestManager : MonoBehaviour
}
}
// Update is called once per frame
void Update()
public Quest GetActiveQuest()
{
return quests[activeQuest];
}
}
[System.Serializable]