private void OnWizardCreate() { var quest = QuestEditorWindow.selectedQuest; if (quest == null || textTable == null) { return; } if (EditorUtility.DisplayDialog("Move Text To Text Table", "This will remove all loose text from " + quest.name + " and move it to the text table " + textTable.name + ". Proceed?", "OK", "Cancel")) { Undo.RecordObject(quest, "Fill Text Table"); MoveTextToTextTable(quest, textTable); EditorUtility.SetDirty(quest); QuestEditorWindow.RepaintNow(); QuestEditorWindow.RepaintCurrentEditorNow(); } }
private void ClickOnCanvas() { QuestEditorWindow.selectedNodeListIndex = -1; for (int i = 0; i < m_nodeListProperty.arraySize; i++) { var nodeProperty = m_nodeListProperty.GetArrayElementAtIndex(i); var nodeRect = GetCanvasRect(nodeProperty); if (nodeRect.Contains(m_mousePos)) { QuestEditorWindow.selectedNodeListIndex = i; var connectRect = new Rect(nodeRect.x, nodeRect.y + nodeRect.height - QuestEditorStyles.connectorImage.height - 8, nodeRect.width, QuestEditorStyles.connectorImage.height + 8); if (connectRect.Contains(m_mousePos)) { m_connecting = true; } break; } } QuestEditorWindow.SetSelectionToQuest(); QuestEditorWindow.RepaintCurrentEditorNow(); }
protected virtual void AddCounterAndNode() { var quest = QuestEditorWindow.selectedQuest; if (quest == null) { return; } // Add counter: var existingCounter = quest.GetCounter(counterName); // Delete existing first. if (existingCounter != null) { quest.counterList.Remove(existingCounter); } var counter = new QuestCounter(new StringField(counterName), Mathf.Max(0, min), min, max, QuestCounterUpdateMode.Messages); var messageAndParameter = incrementMessage.Split(':'); counter.messageEventList.Add(new QuestCounterMessageEvent(new StringField(quest.id), new StringField(messageAndParameter[0]), new StringField(messageAndParameter[1]), QuestCounterMessageEvent.Operation.ModifyByLiteralValue, 1)); quest.counterList.Add(counter); // Add a new node: var parentNode = GetParentNode(quest); if (parentNode == null) { return; } var node = new QuestNode(new StringField(string.Format(hudInstructionsText, min.ToString(), max.ToString())), new StringField(), QuestNodeType.Condition); quest.nodeList.Add(node); node.childIndexList.AddRange(parentNode.childIndexList); parentNode.childIndexList.Clear(); parentNode.childIndexList.Add(quest.nodeList.Count - 1); node.canvasRect = new Rect(parentNode.canvasRect.x + QuestNode.DefaultNodeWidth + 20, parentNode.canvasRect.y, QuestNode.DefaultNodeWidth, QuestNode.DefaultNodeHeight); // Add success node if specified: if (leadsToSuccess) { AddSuccessNode(quest, node); } // Set node's counter condition: var condition = ScriptableObjectUtility.CreateScriptableObject <CounterQuestCondition>(); condition.name = "counterCondition"; condition.counterIndex = quest.GetCounterIndex(counterName); condition.counterValueMode = CounterValueConditionMode.AtLeast; condition.requiredCounterValue = new QuestNumber(max); node.conditionSet.conditionList.Add(condition); AddAndSaveSubasset(condition); // Set node's UI content: var stateInfo = node.GetStateInfo(QuestNodeState.Active); var hudContentList = stateInfo.GetContentList(QuestContentCategory.HUD); AddBodyContent(hudContentList, hudInstructionsText); AddBodyContent(hudContentList, hudCountText); var journalContentList = stateInfo.GetContentList(QuestContentCategory.Journal); AddBodyContent(journalContentList, journalText); var dialogueContentList = stateInfo.GetContentList(QuestContentCategory.Dialogue); AddBodyContent(dialogueContentList, dialogueText); // Add alert action: if (!string.IsNullOrEmpty(hudInstructionsText)) { var alertAction = ScriptableObjectUtility.CreateScriptableObject <AlertQuestAction>(); AddBodyContent(alertAction.contentList, hudInstructionsText); stateInfo.actionList.Add(alertAction); AddAndSaveSubasset(alertAction); } // Update quest's internal references: quest.SetRuntimeReferences(); // Refresh editor windows: QuestEditorWindow.RepaintNow(); // Quest Editor window. QuestEditorWindow.RepaintCurrentEditorNow(); // Inspector. }
protected virtual void AddMessageNode() { var quest = QuestEditorWindow.selectedQuest; if (quest == null) { return; } // Add a new node: var parentNode = GetParentNode(quest); if (parentNode == null) { return; } var node = new QuestNode(new StringField(hudText), new StringField(), QuestNodeType.Condition); quest.nodeList.Add(node); node.childIndexList.AddRange(parentNode.childIndexList); parentNode.childIndexList.Clear(); parentNode.childIndexList.Add(quest.nodeList.Count - 1); node.canvasRect = new Rect(parentNode.canvasRect.x + QuestNode.DefaultNodeWidth + 20, parentNode.canvasRect.y, QuestNode.DefaultNodeWidth, QuestNode.DefaultNodeHeight); // Add success node if specified: if (leadsToSuccess) { AddSuccessNode(quest, node); } // Set node's counter condition: var condition = ScriptableObjectUtility.CreateScriptableObject <MessageQuestCondition>(); condition.name = "messageCondition"; condition.message = new StringField(message); condition.parameter = new StringField(parameter); condition.value = new MessageValue(); node.conditionSet.conditionList.Add(condition); AddAndSaveSubasset(condition); // Set node's UI content: var stateInfo = node.GetStateInfo(QuestNodeState.Active); var hudContentList = stateInfo.GetContentList(QuestContentCategory.HUD); hudContentList.Add(CreateBodyContent(hudText)); var journalContentList = stateInfo.GetContentList(QuestContentCategory.Journal); journalContentList.Add(CreateBodyContent(journalText)); var dialogueContentList = stateInfo.GetContentList(QuestContentCategory.Dialogue); dialogueContentList.Add(CreateBodyContent(dialogueText)); // Add alert action: var alertAction = ScriptableObjectUtility.CreateScriptableObject <AlertQuestAction>(); alertAction.contentList.Add(CreateBodyContent(hudText)); stateInfo.actionList.Add(alertAction); AddAndSaveSubasset(alertAction); // Update quest's internal references: quest.SetRuntimeReferences(); // Refresh editor windows: QuestEditorWindow.RepaintNow(); // Quest Editor window. QuestEditorWindow.RepaintCurrentEditorNow(); // Inspector. }