public void FlyingButtonClickie(NodeDataContainer ndc) { if (!ndc.IsInteractable() || ndc.IsActive()) return; ndc.SetActive(true); flyingFruit--; if (ndc.location == 7) return; int firstNew; if (ndc.location % 2 == 1 && ndc.location != 0) { firstNew = ndc.location + 2; flyingTree.SetSkillState(flyingTree.GetName(ndc.location + 1), false); } else { firstNew = ndc.location + 1; if(ndc.location != 0) flyingTree.SetSkillState(flyingTree.GetName(ndc.location - 1), false); } flyingTree.ShowSkill(flyingTree.GetName(firstNew), false); flyingTree.SetSkillState(flyingTree.GetName(firstNew), flyingFruit > 0); if (ndc.location < 5) { flyingTree.ShowSkill(flyingTree.GetName(firstNew + 1), false); flyingTree.SetSkillState(flyingTree.GetName(firstNew + 1), flyingFruit > 0); } }
//!Wywoływana po naciśnięciu przycisku z odpowiedzią. Zapisuje wybór jeżeli takowy istnieje oraz przygotowuje kolejny węzeł dialogu. public void makeChoice(int i) { if (currentNode.IsChoice) { saveDataController.saveChoice(currentNode, i); } currentNode = currentTree.getNode(currentNode.OutputPorts[i].TargetGuid); displayNextDialog(); }
//!Zapisuje pojedynczy wybór gracza. public void saveChoice(NodeDataContainer currentNode, int i) { string portName = currentNode.OutputPorts[i].PortName; ChoiceData choiceData = currentNode.ChoiceOutcomes.Find(x => x.PortName == portName); choiceData.skillCheck(LoadedSave.PlayerStats); LoadedSave.PastChoices.Add(choiceData); identifyChoicePath(choiceData); }
//!Zapisuje graf do pliku. public void save(string fileName) { if (edges.Count == 0) { return; } DialogContainer dialogContainer = ScriptableObject.CreateInstance <DialogContainer>(); //Tworzy plik zapisu. List <Edge> connectedPorts = new List <Edge>(); foreach (Edge edge in edges) { if (edge.input.node != null) { connectedPorts.Add(edge); } } foreach (DialogNode node in nodes) //Tworzy obiekty reprezentujące węzły do zapisu. { if (node.IsRoot) { continue; } NodeDataContainer data = new NodeDataContainer(node.Guid, node.DialogLine, node.Speaker, node.ExitLine, node.IsChoice, node.IsLeaf, node.IsEnding, node.ChoiceOutcomes, node.GetPosition().position); dialogContainer.NodeData.Add(data); } foreach (Edge edge in connectedPorts) //Tworzy obiekty reprezentujące połączenia i przypisuje je do odpowiednich węzłów. { DialogNode outputNode = (DialogNode)edge.output.node; DialogNode inputNode = (DialogNode)edge.input.node; NodeConnection connection = new NodeConnection(outputNode.Guid, edge.output.portName, inputNode.Guid); dialogContainer.Connections.Add(connection); if (edge.output.portName == "root") { dialogContainer.FirstNodeGuid = inputNode.Guid; } else { dialogContainer.NodeData.Find(x => x.Guid == outputNode.Guid).OutputPorts.Add(connection); } } AssetDatabase.CreateAsset(dialogContainer, "Assets/Resources/Dialogs/Trees/" + fileName + ".asset"); //Zapisuje plik jako asset. AssetDatabase.SaveAssets(); }
//!Przygotowuje kolkejne drzewo dialogowe. private void getNextTree() { if (dialogTrees.Count != 0) { currentTree = dialogTrees[0]; dialogTrees.Remove(currentTree); currentNode = currentTree.getFirstNode(); choiceButtons[0].onClick.RemoveAllListeners(); choiceButtons[0].onClick.AddListener(delegate { makeChoice(0); }); } else { currentTree = null; currentNode = null; } }
public void OpenMenu(bool instant, NodeDataContainer ndc) { StopCoroutine("AnimateClose"); title.text = ndc.title; flavor1.text = ndc.flavorText; flavor2.text = ndc.flavorText2; flavor3.text = ndc.flavorText3; display.sprite = ndc.displayImage; if (!isEnabled) { if (instant) rTransform.localScale = Vector3.zero; else StartCoroutine("AnimateOpen"); } isEnabled = true; }
public DialogNode(NodeDataContainer data) { Guid = data.Guid; title = data.Speaker; DialogLine = data.DialogLine; Speaker = data.Speaker; IsChoice = data.IsChoice; IsLeaf = true; IsEnding = data.IsEnding; ExitLine = data.ExitLine; if (data.ChoiceOutcomes != null) { ChoiceOutcomes = new List <ChoiceData>(data.ChoiceOutcomes); } else { ChoiceOutcomes = new List <ChoiceData>(); } controlsSetup(); }
public void NormalButtonClickie(NodeDataContainer ndc) { if (!ndc.IsInteractable() || ndc.IsActive()) return; ndc.SetActive(true); normalFriut--; if (normalFriut <= 0) { for (int i = 1; i <= 4; i++) { if(!normalTree.IsSkillActive(normalTree.GetName(i))){ normalTree.SetSkillState(normalTree.GetName(i), false); } } } }