ok, thanks very much for your awesome support, but for me it's a bit complicated the tag thing
I'm calling this from my custom Quest Action that you helped me yesterday to code.
And what I want it, it's to write in the Hud: "Chests: 0 of 7" and that it refresh every time the counter updates.
So now i have:
content1.bodyText = new StringField("Chests: " + quest.GetCounter(CounterName).currentValue + " / " + quest.GetCounter(CounterName).maxValue);
But this only works once as it doesn't refresh (I guess because Execute only executes once by design)
So I may need to change to:
//content.bodyText = new StringField("Chests: " + "{#Flooded2_Chests1} / {>#Flooded2_Chests1}");
But this it doesn't work as it shows the literal tags instead of the value inside the tags.
So how do I need to write this line so it gets on the Hud and refresh automatically?
Thanks! (I leave here the code just in case it's more clear for you)
And I leave you here a screenshot of the HUD and Dialogue:
https://1drv.ms/u/s!AgOs7p5LnVflkMAfksqndaIQpk_1vw
using UnityEngine;
using System;
namespace PixelCrushers.QuestMachine
{
public class ChestQuestAction : QuestAction, PixelCrushers.IMessageHandler
{
public string QuestParameterMessage = "IMPORTANTE: A rellenar, mismo que en el Prefab";
public string CounterName;
private string QuestMessageToActivate = "ActivateChest";
private string QuestMessageOpened = "ChestOpened";
private string QuestMessageToDeativated = "ChestDeativated";
private Quest questActual;
private QuestNode questNodeActual;
private string questString;
public EstadoChest EstadoChestAPoner = EstadoChest.Cerrado;
public bool isVisible => throw new NotImplementedException();
public override void Execute()
{
base.Execute();
// Add your code here. This code will run when the action runs.
switch (EstadoChestAPoner)
{
case EstadoChest.Cerrado:
//Envia mensaje para activar el chest (cerrado)
PixelCrushers.MessageSystem.SendMessage(this, QuestMessageToActivate, QuestParameterMessage);
break;
case EstadoChest.Bloqueado:
//Envia mensaje para desactivar el chest, no se utiliza mucho
PixelCrushers.MessageSystem.SendMessage(this, QuestMessageToDeativated, QuestParameterMessage); //No se utiliza mucho
break;
}
UpdateUI();
// Nos suscribimos a los mensajes de Quest Machine
MessageSystem.AddListener(this, QuestMachineMessages.QuestCounterChangedMessage, questString);
}
private void UpdateUI()
{
//Obtiene la quest donde estamos
questActual = this.quest;
questString = questActual.ToString();
//Obtiene el Nodo donde estamos
questNodeActual = this.questNode;
//Obtiene el estado del Nodo donde estamos
var stateInfo = questNode.GetStateInfo(QuestNodeState.Active);
// get the content list for a specific category
var hudContentList = stateInfo.GetContentList(QuestContentCategory.HUD);
var journalContentList = stateInfo.GetContentList(QuestContentCategory.Journal);
var dialogueContentList = stateInfo.GetContentList(QuestContentCategory.Dialogue);
var alertContentList = stateInfo.GetContentList(QuestContentCategory.Alert);
var content = BodyTextQuestContent.CreateInstance<BodyTextQuestContent>();
var content1 = BodyTextQuestContent.CreateInstance<BodyTextQuestContent>();
content.bodyText = new StringField("Now go find the chest");
if (quest.GetCounter(CounterName) != null)
{
content1.bodyText = new StringField("Chests: " + quest.GetCounter(CounterName).currentValue + " / " + quest.GetCounter(CounterName).maxValue);
//content.bodyText = new StringField("Chests: " + "{#Flooded2_Chests1} / {>#Flooded2_Chests1}");
}
if (hudContentList != null) hudContentList.Add(content);
if (hudContentList != null) hudContentList.Add(content1);
if (journalContentList != null) journalContentList.Add(content);
if (dialogueContentList != null) dialogueContentList.Add(content);
if (alertContentList != null) alertContentList.Add(content);
//Refresca los UIs
QuestMachineMessages.RefreshUIs(this);
//Envia al manager de UI Quest los datos de esta quest para que se pueda suscribir a refrescar el UI cuando cambian los contadores.
//if (QuestUIManager.instance != null) QuestUIManager.instance.RecibeInfoQuestNode(quest, questNode, CounterName);
}
public void OnMessage(MessageArgs messageArgs)
{
if (messageArgs.message == QuestMachineMessages.QuestCounterChangedMessage)
{
Debug.Log("Recibimos mensaje de counter change");
//Refrescamos los UIs (Journal, Hud, Dialogues, etc...)
QuestMachineMessages.RefreshUIs(this);
}
}
}
}