Re: Procedural generation based on data and not presence?
Posted: Thu Apr 25, 2019 9:58 am
Great news and thank you once again for all the support. Good luck in your ludum dare .
Support and discussion forum for Pixel Crushers products
https://www.pixelcrushers.com:443/phpbb/
https://www.pixelcrushers.com:443/phpbb/viewtopic.php?t=2182
Code: Select all
private void OnQuestGenerated(Quest quest)
{
QuestBuilder questbuilder = new QuestBuilder(quest);
if (quest.title.value.StartsWith("Polymorph"))
{
QuestNode nodeWhereToAddFrom = quest.nodeList[quest.nodeList.Count/2];
var counter = questbuilder.AddCounter("stuffs", 0, 0, 5, false, QuestCounterUpdateMode.Messages);
var conditionNode = questbuilder.AddConditionNode(nodeWhereToAddFrom, "ID11", "NAME11", ConditionCountMode.All);
questbuilder.AddCounterCondition(conditionNode, "Find it", CounterValueConditionMode.AtLeast, 5);
var counterMessageEvent = new QuestCounterMessageEvent(null, new StringField("Find it"), new StringField("stuff"), QuestCounterMessageEvent.Operation.ModifyByLiteralValue, 1);
counter.messageEventList.Add(counterMessageEvent);
questbuilder.AddContents(conditionNode.GetStateInfo(QuestNodeState.Active).GetContentList(QuestContentCategory.Dialogue), questbuilder.CreateBodyContent("DIALOGUE"));
questbuilder.AddContents(conditionNode.GetStateInfo(QuestNodeState.Active).GetContentList(QuestContentCategory.Journal), questbuilder.CreateBodyContent("DIALOGUE"));
questbuilder.AddContents(conditionNode.GetStateInfo(QuestNodeState.Active).GetContentList(QuestContentCategory.HUD), questbuilder.CreateBodyContent("DIALOGUE"));
}
Debug.Log(quest.nodeList.Count);
quest = questbuilder.ToQuest();
//questGenerators[1].gameObject.GetComponent<QuestGiver>().AddQuest(quest);
// And add it to the QuestGiver:
//GetComponent<QuestGiver>().AddQuest(myQuest);
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers;
using PixelCrushers.QuestMachine;
public class ExtraNodeTest : MonoBehaviour
{
private void Start()
{
GetComponent<QuestGeneratorEntity>().generatedQuest += OnQuestGenerated;
}
private void OnQuestGenerated(Quest quest)
{
QuestBuilder questbuilder = new QuestBuilder(quest);
if (quest.title.value.StartsWith("Polymorph"))
{
QuestNode nodeWhereToAddFrom = quest.nodeList[2]; // [TL] quest.nodeList[quest.nodeList.Count / 2];
var counter = questbuilder.AddCounter("stuffs", 0, 0, 5, false, QuestCounterUpdateMode.Messages);
var conditionNode = questbuilder.AddConditionNode(nodeWhereToAddFrom, "ID11", "NAME11", ConditionCountMode.All);
//[TL] Move node to the right so it doesn't overlap an existing node:
conditionNode.canvasRect = new Rect(conditionNode.canvasRect.x + QuestNode.DefaultNodeWidth + 20, conditionNode.canvasRect.y, QuestNode.DefaultNodeWidth, QuestNode.DefaultNodeHeight);
//[TL] You don't have to manually create a message event object. This is how to add a counter condition:
//questbuilder.AddCounterCondition(conditionNode, "Find it", CounterValueConditionMode.AtLeast, 5);
questbuilder.AddCounterCondition(conditionNode, "stuffs", CounterValueConditionMode.AtLeast, 5);
questbuilder.AddCounterMessageEvent("stuffs", string.Empty, "Got", "Stuffs", QuestCounterMessageEvent.Operation.ModifyByLiteralValue, 1);
//var counterMessageEvent = new QuestCounterMessageEvent(null, new StringField("Find it"), new StringField("stuff"), QuestCounterMessageEvent.Operation.ModifyByLiteralValue, 1);
//counter.messageEventList.Add(counterMessageEvent);
questbuilder.AddContents(conditionNode.GetStateInfo(QuestNodeState.Active).GetContentList(QuestContentCategory.Dialogue), questbuilder.CreateBodyContent("DIALOGUE Stuffs")); //[TL]
questbuilder.AddContents(conditionNode.GetStateInfo(QuestNodeState.Active).GetContentList(QuestContentCategory.Journal), questbuilder.CreateBodyContent("JOURNAL Stuffs"));
questbuilder.AddContents(conditionNode.GetStateInfo(QuestNodeState.Active).GetContentList(QuestContentCategory.HUD), questbuilder.CreateBodyContent("HUD Get Stuffs"));
//[TL] Link conditionNode to success:
var successNodeIndex = quest.nodeList.FindIndex(node => StringField.Equals(node.id, "success"));
Debug.Log("successNodeIndex=" + successNodeIndex);
conditionNode.childIndexList.Add(successNodeIndex);
}
Debug.Log(quest.nodeList.Count);
quest = questbuilder.ToQuest();
//questGenerators[1].gameObject.GetComponent<QuestGiver>().AddQuest(quest);
// And add it to the QuestGiver:
//GetComponent<QuestGiver>().AddQuest(myQuest);
}
}