Code: Select all
MessageSystem.AddListener(this, QuestMachineMessages.QuestTrackToggleChangedMessage, string.Empty);
Code: Select all
MessageSystem.AddListener(this, QuestMachineMessages.QuestTrackToggleChangedMessage, string.Empty);
Code: Select all
var trackedQuest = QuestMachine.GetQuestJournal().questList.Find(quest => quest.showInTrackHUD);
Code: Select all
QuestMachine.GetQuestJournal().questAdded += QuestAdded;
Code: Select all
MessageSystem.AddListener(this, QuestMachineMessages.QuestStateChangedMessage, string.Empty);
Code: Select all
SetQuestState("fetchQuest", "Success")
Code: Select all
SetQuestNodeState("fetchQuest", "Return", "True")
Code: Select all
SetQuesterQuestNodeState("fetchQuest", "Return", "True", "Player")
Code: Select all
GiveQuestToQuester("Shop Keeper", "fetchQuest", "Player");
Code: Select all
[SerializeField] private QuestVariablesSchematicsDictionary dictionary;
private MakinomSchematicAsset schematicAsset;
private List<PixelCrushers.QuestMachine.Quest> trackedQuests;
//private List<string> trackedQuestIDs;
private void Awake()
{
//Message with paremeter = questID, Argument 0 = nodeID, argument 1 = new state
QuestMachine.GetQuestJournal().questAdded += QuestAdded;
MessageSystem.AddListener(this, QuestMachineMessages.QuestStateChangedMessage, string.Empty);
}
private void QuestAdded(PixelCrushers.QuestMachine.Quest quest)
{
Maki.Game.Variables.Set(quest.id + "Tracked", true);
Debug.Log("Tracked Quest true");
}
private void OnDestroy()
{
// Stop listening:
MessageSystem.RemoveListener(this);
QuestMachine.GetQuestJournal().questAdded -= QuestAdded;
//QuestMachine.GetQuestJournal().
}
public void OnMessage(MessageArgs messageArgs)
{
string questID = messageArgs.parameter;
StringField nodeIDField = (StringField)messageArgs.values[0];
//This will remove messages pertaining to queststates and not quest not states
//if (nodeIDField == null) { return;}
string nodeID = StringField.GetStringValue(nodeIDField);
//seems to work regardless of questnodestate or queststate message arguement
QuestNodeState state = (QuestNodeState)messageArgs.values[1];
string status = state.ToString();
string globalVariable = questID + nodeID + status;
Debug.Log(globalVariable);
//set node state variables to true
if (dictionary.QuestSchematicsDictionary.ContainsKey(globalVariable))
{
Maki.Game.Variables.Set(globalVariable, true);
//if quest is successful then change tracking
if (globalVariable == questID + "Successful")
{
Maki.Game.Variables.Set(questID + "Tracking", false);
}
}
Code: Select all
public void OnMessage(MessageArgs messageArgs)
{
switch (messageArgs.message)
{
string questID = messageArgs.parameter;
case QuestMachineMessages.QuestTrackToggleChangedMessage:
Maki.Game.Variables.Set(questID + "Tracking", (bool)messageArgs.values[0]);
break;
case QuestMachineMessages.QuestStateChangedMessage:
bool isMainQuestState = messageArgs.values[0] == null;
if (isMainQuestState)
{
QuestState questState = (QuestState)messageArgs[1];
string questStateVariableName = questID + questState;
Maki.Game.Variables.Set(questStateVariableName, true); // I'm not quite sure why this would be a bool.
}
else
{
string questNodeID = (StringField)messageArgs[0];
QuestNodeState questNodeState = (QuestNodeState)messageArgs[1];
string questNodeStateVariableName = questID + questNodeID + questNodeState;
Maki.Game.Variables.Set(questNodeStateVariableName, true);
}
break;
}
}
Code: Select all
public void OnMessage(MessageArgs messageArgs)
{
string questID = messageArgs.parameter;
switch (messageArgs.message)
{
case QuestMachineMessages.QuestTrackToggleChangedMessage:
Maki.Game.Variables.Set(questID + "Tracking", (bool)messageArgs.values[0]);
break;
case QuestMachineMessages.QuestStateChangedMessage:
bool isMainQuestState = messageArgs.values[0] == null;
if (isMainQuestState)
{
QuestState questStateAsset = (QuestState)messageArgs.values[1];
string questState = questStateAsset.ToString();
//string questStateVariableName = questID + questState;
Maki.Game.Variables.Set(questID, questState); // I'm not quite sure why this would be a bool.
}
else
{
string questNodeID = StringField.GetStringValue((StringField)messageArgs.values[0]);
QuestNodeState questNodeState = (QuestNodeState)messageArgs.values[1];
string questNodeStateVariableName = questID + questNodeID + questNodeState;
Maki.Game.Variables.Set(questNodeStateVariableName, true);
//PlaySchematic(questNodeStateVariableName);
}
break;
}
}