public static void LoadNodes(Quest quest) { bool hasStartTrigger = false; bool hasEndTrigger = false; foreach (QuestTrigger trigger in quest.questTriggers) { new Node(trigger); if (trigger.GetType() == QuestEditor.TranslateType(TRIGGER_TYPES.START)) { hasStartTrigger = true; } if (trigger.GetType() == QuestEditor.TranslateType(TRIGGER_TYPES.END)) { hasEndTrigger = true; } } if (!hasStartTrigger) { Debug.Log("no start trigger"); new Node(quest.gameObject, QuestEditor.TranslateType(TRIGGER_TYPES.START)); } if (!hasEndTrigger) { Debug.Log("no end trigger"); new Node(quest.gameObject, QuestEditor.TranslateType(TRIGGER_TYPES.END)); } }
public void ChangeScript(System.Type type) { if (type != QuestEditor.TranslateType(TRIGGER_TYPES.START) && type != QuestEditor.TranslateType(TRIGGER_TYPES.END) && trigger.GetType() != QuestEditor.TranslateType(TRIGGER_TYPES.START) && trigger.GetType() != QuestEditor.TranslateType(TRIGGER_TYPES.END)) { QuestEditor.selectedQuest.questTriggers.Remove(trigger); QuestTrigger temp = (QuestTrigger)trigger.gameObject.AddComponent(type); Object.DestroyImmediate(trigger); trigger = temp; ChangeTitle(type); QuestEditor.selectedQuest.questTriggers.Add(trigger); } }
public override void OnGUI(Rect rect) { if ((gameObject = Selection.activeGameObject) == null) { gameObject = QuestEditor.selectedQuest.gameObject; } GUILayout.Label("Créer un noeud (trigger) :", EditorStyles.boldLabel); gameObject = (GameObject)EditorGUILayout.ObjectField("GameObject", gameObject, typeof(GameObject), true); triggerType = (TRIGGER_TYPES)EditorGUILayout.EnumPopup("Type du trigger :", triggerType); if (GUILayout.Button("Créer le trigger") && gameObject != null) { new Node(gameObject, QuestEditor.TranslateType(triggerType)); } }
void DisplayData() { // Common objects if (triggerType != (triggerType = (TRIGGER_TYPES)EditorGUILayout.EnumPopup("Type du trigger :", triggerType))) { node.ChangeScript(QuestEditor.TranslateType(triggerType)); } if (GUILayout.Button("Changer GameObject")) { node.ChangeGameObject(Selection.activeGameObject); } node.trigger.isActive = EditorGUILayout.Toggle("is Active", node.trigger.isActive); node.trigger.enabled = node.trigger.isActive; desactiveSelf = EditorGUILayout.Toggle("Desactive Self", desactiveSelf); if (desactiveSelf && !node.trigger.triggersToDesactive.Contains(node.trigger)) { node.trigger.triggersToDesactive.Add(node.trigger); } else if (!desactiveSelf) { node.trigger.triggersToDesactive.Remove(node.trigger); } node.trigger.isInteractable = EditorGUILayout.BeginToggleGroup("is Interactable", node.trigger.isInteractable); node.trigger.offsetIcon = EditorGUILayout.Vector2Field("offsetIcon", node.trigger.offsetIcon); EditorGUILayout.EndToggleGroup(); if (node.trigger.tag == "NPC") { node.trigger.offsetIcon = node.trigger.GetComponent <NPC>().offsetIcon; } // Specific node.trigger if (node.trigger.GetType() == typeof(QuestTrigger_Dialogue) || node.trigger.GetType() == typeof(StartQuest_Dialogue) || node.trigger.GetType() == typeof(EndQuest_Dialogue)) { DisplayDialogue(); } else if (node.trigger.GetType() == typeof(QuestTrigger_ItemPickup)) { ((QuestTrigger_ItemPickup)node.trigger).isQuestItem = EditorGUILayout.Toggle("Is Quest Item ?", ((QuestTrigger_ItemPickup)node.trigger).isQuestItem); node.trigger.GetComponent <ItemOnObject>().item = (Item)EditorGUILayout.ObjectField("Item to pickup", node.trigger.GetComponent <ItemOnObject>().item, typeof(Item), false); node.trigger.offsetIcon = node.trigger.GetComponent <ItemOnObject>().item.offsetIcon; /*node.trigger.GetComponent<SpriteRenderer>().sprite = node.trigger.GetComponent<ItemOnObject>().item.icon; * if (node.trigger.GetComponent<ItemPickup>() != null) * Object.DestroyImmediate(node.trigger.GetComponent<ItemPickup>());*/ } else if (node.trigger.GetType() == typeof(QuestTrigger_Buy)) { DisplayItemsToBuy(); } else if (node.trigger.GetType() == typeof(QuestTrigger_Craft)) { DisplayItemsToCraft(); } else if (node.trigger.GetType() == typeof(RemoveItemAT)) { ((RemoveItemAT)node.trigger).item = (Item)EditorGUILayout.ObjectField("Item to remove", ((RemoveItemAT)node.trigger).item, typeof(Item), false); } else if (node.trigger.GetType() == typeof(RewardTriggerAT)) { DisplayRewards(); } else if (node.trigger.GetType() == typeof(InstantiateAT)) { ((InstantiateAT)node.trigger).prefab = (GameObject)EditorGUILayout.ObjectField("Prefab to instantiate", ((InstantiateAT)node.trigger).prefab, typeof(GameObject), false); } }
private void ChangeTitle(System.Type type) { title = ""; if (QuestEditor.selectedNode == id) { title += "* "; } if (type == QuestEditor.TranslateType(TRIGGER_TYPES.DIALOGUE)) { title += "Dialogue"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.ITEM_PICKUP)) { title += "Item Pickup"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.BUY)) { title += "Buy"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.CRAFT)) { title += "Craft"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.START)) { title += "Start Dialogue"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.END)) { title += "End Dialogue"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.ZONE)) { title += "Zone"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.AT_REMOVE_ITEM)) { title += "Remove Item (AT)"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.AT_REWARD)) { title += "Reward (AT)"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.AT_END_QUEST)) { title += "End Quest (AT)"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.AT_INSTANTIATE)) { title += "Instantiate (AT)"; } else if (type == QuestEditor.TranslateType(TRIGGER_TYPES.AT_ACTIVE_ENNEMI)) { title += "Active Ennemi (AT)"; } else { title = "Trigger"; } if (QuestEditor.selectedNode == id) { title += " *"; } }