Esempio n. 1
0
    public List <ChoiceData> Load_ChoiceXML()
    {
        List <ChoiceData> return_data = new List <ChoiceData>();

        TextAsset   txtAsset = (TextAsset)Resources.Load("xml/choice");
        XmlDocument xmlDoc   = new XmlDocument();

        Debug.Log(txtAsset.text);
        xmlDoc.LoadXml(txtAsset.text);

        // 전체 아이템 가져오기 예제.
        XmlNodeList all_nodes = xmlDoc.SelectNodes("Root/text");

        foreach (XmlNode node in all_nodes)
        {
            // 수량이 많으면 반복문 사용.
            ChoiceData choiceData = new ChoiceData
            {
                situation_key = node.SelectSingleNode("situation").InnerText,
                choice        = node.SelectSingleNode("choice").InnerText,
                result        = node.SelectSingleNode("result").InnerText,
                suc           = Int32.Parse(node.SelectSingleNode("suc").InnerText)
            };

            return_data.Add(choiceData);
        }

        return(return_data);
    }
Esempio n. 2
0
    private void OnChangeDirection(SwipeDirection direction)
    {
        ChoiceData choiseData = null;

        if (cardItem.me == true)
        {
            choiseData = direction == SwipeDirection.LEFT ? cardItem.data.left : cardItem.data.right;
        }
        else
        {
            choiseData = direction == SwipeDirection.LEFT ? cardItem.data.eLeft : cardItem.data.eRight;
        }

        List <RewardData> result = new List <RewardData> ();

        Services.data.GetResourceReward(result, choiseData.reward, choiseData.cost, 0, false, false, cardItem.me);

        RewardData rc = result.Find(r => r.count < 0 && r.id == resId && r.enemy == enemy && r.category == GameDataManager.RESOURCE_ID);
        RewardData rr = result.Find(r => r.count > 0 && r.id == resId && r.enemy == enemy && r.category == GameDataManager.RESOURCE_ID);


        for (int i = 0; i < maxValue; i++)
        {
            items[i].GetComponent <ShakeComponent> ().StopShake();
            if (rc != null && i >= (currentValue + rc.count) && i < currentValue)
            {
                items[i].GetComponent <ShakeComponent> ().Shake();
            }
            else if (rr != null && i < currentValue + rr.count && i >= currentValue)
            {
                items[i].GetComponent <ShakeComponent> ().Shake();
            }
        }
    }
Esempio n. 3
0
    //!Umożliwia edycję właściwości portu/odpowiedzi.
    private void editResponse(ChoiceData choiceData)
    {
        foldout.SetEnabled(true);
        foldout.value    = true;
        choiceName.value = choiceData.ChoiceTitle;
        choiceName.RegisterCallback <InputEvent, ChoiceData>(setChoiceName, choiceData);
        makesChoice.value = choiceData.WasMade;
        makesChoice.RegisterCallback <MouseUpEvent, ChoiceData>(setChoiceOutcome, choiceData);

        foreach (Toggle narrativeType in narrativeTypeToggles)
        {
            narrativeType.RegisterCallback <MouseUpEvent, ChoiceData>(setNarrativePath, choiceData);
            if (choiceData.Path.ToString() == narrativeType.text)
            {
                narrativeType.value = true;
            }
            else
            {
                narrativeType.value = false;
            }
        }

        charismaField.value = choiceData.RequiredCharisma.ToString();
        charismaField.RegisterCallback <InputEvent, ChoiceData>(setCharismaRequirement, choiceData);
        deceptionField.value = choiceData.RequiredDeception.ToString();
        deceptionField.RegisterCallback <InputEvent, ChoiceData>(setDeceptionRequirement, choiceData);
        thoughtfulnessField.value = choiceData.RequiredThoughtfulness.ToString();
        thoughtfulnessField.RegisterCallback <InputEvent, ChoiceData>(setThoughtfulnessRequirement, choiceData);
    }
Esempio n. 4
0
    //!Definiuje UI portu.
    private void portControlsSetup(Port port)
    {
        ChoiceData choiceData = ChoiceOutcomes.Find(x => x.PortName == port.portName);

        if (choiceData == null)
        {
            choiceData = new ChoiceData(port.portName);
            ChoiceOutcomes.Add(choiceData);
        }

        Button removeBtn = new Button(delegate { removePort(port); });

        removeBtn.text = "x";
        Button editBtn = new Button(delegate { editResponse(choiceData); });

        editBtn.text = "Edit";

        TextField portNameField = new TextField();

        portNameField.value = port.portName;
        portNameField.RegisterCallback <InputEvent, Port>(setPortName, port);

        port.contentContainer.Add(portNameField);
        port.contentContainer.Add(editBtn);
        port.contentContainer.Add(removeBtn);
    }
        private void ShowEditMenu(ChoiceData choice, int index)
        {
            GUI.FocusControl(null);
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("View"), false, () => {
                Selection.activeObject = choice;
            });

            menu.AddItem(new GUIContent("Move Up"), false, () => {
                _callbacks.Push(() => {
                    MoveChoice(choice, index, -1);
                    DialogueWindow.SaveGraph();
                });
            });

            menu.AddItem(new GUIContent("Move Down"), false, () => {
                _callbacks.Push(() => {
                    MoveChoice(choice, index, 1);
                    DialogueWindow.SaveGraph();
                });
            });

            menu.AddSeparator("");

            menu.AddItem(new GUIContent("Delete"), false, () => {
                _graveyard.Add(_data.choices[index]);
            });

            menu.ShowAsContext();
        }
 private void AddConnectionDisplay(ChoiceData choice)
 {
     _node.Out[0].Hide = true;
     _node.CreateConnection(ConnectionType.Out, choice, false);
     _connections.Add(_node.Out[_node.Out.Count - 1]);
     _serializedObjects.Add(new SerializedObject(choice));
 }
Esempio n. 7
0
    private IEnumerator DoDisplay(BeatData data)
    {
        _output.Clear();

        while (_output.IsBusy)
        {
            yield return(null);
        }

        _output.Display(data.DisplayText);

        while (_output.IsBusy)
        {
            yield return(null);
        }

        for (int count = 0; count < data.Decision.Count; ++count)
        {
            ChoiceData choice = data.Decision[count];
            _output.Display(string.Format("{0}: {1}", (count + 1), choice.DisplayText));

            while (_output.IsBusy)
            {
                yield return(null);
            }
        }

        if (data.Decision.Count > 0)
        {
            _output.ShowWaitingForInput();
        }
    }
Esempio n. 8
0
 public void Init(ChoiceData data, bool nextEvent = false)
 {
     _nextEvent = nextEvent;
     Choice     = data;
     GetComponent <Text>().text           = nextEvent ? "Continuer" : Choice.Intitulate;
     GetComponent <Button>().interactable = CheckPossibility();
 }
        private void MoveChoice(ChoiceData choice, int index, int change)
        {
            var newIndex = Mathf.Min(Mathf.Max(index + change, 0), _data.choices.Count - 1);

            _data.choices.RemoveAt(index);
            _data.choices.Insert(newIndex, choice);
            RebuildChoices();
        }
Esempio n. 10
0
    public void Choose(ChoiceData data)
    {
        CleanChoices();
        ViewPortContent.transform.Find("Lore").GetComponent <Text>().text = data.Feedback;

        GameObject choiceGo = Instantiate(ChoicePrefab, ViewPortContent.transform);

        choiceGo.GetComponent <MovementChoice>().Init(data, true);
    }
Esempio n. 11
0
    //!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);
    }
Esempio n. 12
0
    //!Ustawia nazwę portu.
    private void setPortName(InputEvent e, Port port)
    {
        ChoiceData choiceData = ChoiceOutcomes.Find(x => x.PortName == e.previousData);

        if (choiceData != null)
        {
            choiceData.PortName = e.newData;
        }
        port.portName = e.newData;
    }
Esempio n. 13
0
        public void Execute(CardData cardData, int choice, ChoiceData chMeta, bool me, int time, PlayerManager enemy)
        {
            if (Services.data.CheckConditions(chMeta.conditions, time, false, me))
            {
                List <RewardData> result = new List <RewardData> ();
                Services.data.GetResourceReward(result, chMeta.reward, chMeta.cost, time, true, false, me);
                foreach (RewardData r in result)
                {
                    if (r.count > 0)
                    {
                        if (r.enemy)
                        {
                            enemy.AddResource(r.id, r.count);
                        }
                        else
                        {
                            AddResource(r.id, r.count);
                        }
                    }
                    else
                    {
                        if (r.enemy)
                        {
                            enemy.SubResource(r.id, Math.Abs(r.count));
                        }
                        else
                        {
                            SubResource(r.id, Math.Abs(r.count));
                        }
                    }
                }
            }

            CardExecutedItem cardVO = playerData.cards.Find(c => c.id == cardData.id);

            if (cardVO == null)
            {
                cardVO = new CardExecutedItem();
                playerData.cards.Add(cardVO);
            }

            cardVO.id       = cardData.id;
            cardVO.choice   = choice;
            cardVO.executed = time;
            SaveCardLocal(cardVO);

            enemy.OnProfileUpdated?.Invoke();
            OnProfileUpdated?.Invoke();

            //only for me
            if (this == Services.player)
            {
                Services.network.AddRequestToPool(new RequestVO("choise"));
            }
        }
Esempio n. 14
0
    private IEnumerator INextEvent(ChoiceData data = null, bool noAnim = false)
    {
        if (!noAnim)
        {
            if (data != null && data.Type != EventType.Campement)
            {
                _animator.SetTrigger("Next");
            }
            yield return(new WaitForSeconds(0.5f));
        }

        EventData eventData = null;

        if (data == null)
        {
            eventData = EventsLoader.Instance.GetEvent();
        }
        else
        {
            if (data.Type == EventType.Campement)
            {
                GetComponent <Animator>().SetTrigger("Quit");
                yield break;
            }
            else if (data.Type == EventType.Target)
            {
                eventData = EventsLoader.Instance.GetEvent(data.Target);
                if (eventData == null)
                {
                    Debug.LogError("Can't find target event " + data.Target);
                    eventData = EventsLoader.Instance.GetEvent();
                }
            }
            else
            {
                eventData = EventsLoader.Instance.GetEvent(data.Type, data.Rarity, data.Goodness);
            }
        }

        if (eventData == null)
        {
            if (data != null)
            {
                Debug.LogError("No event found (" + data.Type + ", " + data.Rarity + ", " + data.Goodness + ")");
            }
            else
            {
                Debug.LogError("No event found");
            }

            eventData = EventsLoader.Instance.GetEvent();
        }

        ReadEvent(eventData);
    }
Esempio n. 15
0
        public void GetGraphData()
        {
            if (Edges.Count == 0)
            {
                EditorUtility.DisplayDialog("No Dialogue Connection", "Make Sure You Have at Least 1 Connection Between Dialogues", "OK");
                return;
            }
            foreach (var node in Nodes)
            {
                var json = JsonUtility.ToJson(node.GetPosition().position);
                if (!node.isEntryPoint)
                {
                    var data = new NodeData
                    {
                        Guid     = node.Guid,
                        JsonData = json,
                        Next     = (node.outputContainer.Q <Port>() as DialoguePort).Next
                    };
                    if (node is DialogueNode)
                    {
                        data.Text      = (node as DialogueNode).Text;
                        data.Character = (node as DialogueNode).Character;
                    }
                    else
                    {
                        var listPort = node.outputContainer.Query <Port>().ToList();
                        foreach (var port in listPort)
                        {
                            var        outputPort = port as DialoguePort;
                            ChoiceData tmpChoice  = new ChoiceData
                            {
                                Next     = outputPort.Next,
                                Question = outputPort.Question
                            };
                            data.Choices.Add(tmpChoice);
                        }

                        data.isChoiceNode = true;
                    }

                    dataContainer.Nodes.Add(data);
                }
                else if (node.isEntryPoint)
                {
                    var tmp = new NodeData
                    {
                        Guid         = node.Guid,
                        isEntryPoint = true,
                        Next         = (node.outputContainer.Q <Port>() as DialoguePort).Next
                    };
                    dataContainer.Nodes.Add(tmp);
                }
            }
        }
Esempio n. 16
0
 public void SelectDialgoue()
 {
     AudioManager.instance.PlayRandFromGroup("PhoneButtonSFX");
     if (choice != null)
     {
         DialogueManager.instance.GetResultByName(choice.ChoiceResult).TriggerResult();
     }
     choice = null;
     DialogueManager.instance.DisplayDialogueChoice(targetBeatIndex);
     OnDialogueSelected?.Invoke();
 }
Esempio n. 17
0
    public void UpdateUi()
    {
        ChoiceData choiceData = FindObjectOfType <SaveHandler>().CUR_SELECT_CHOICE_DATA;

        txt_result.text = choiceData.result;
        if (choiceData.suc == 1)
        {
            txt_suc.text = "참교육 성공";
        }
        else
        {
            txt_suc.text = "참교육 실패";
        }
    }
Esempio n. 18
0
 //!Sprawdza do jakiej ścieżki przynależy dany wybór i inkrementuje odpowiadający mu licznik.
 private void identifyChoicePath(ChoiceData choiceData)
 {
     if (choiceData.Path == NarrativePath.Revolution)
     {
         LoadedSave.RevolutionChoices++;
     }
     else if (choiceData.Path == NarrativePath.Reform)
     {
         LoadedSave.ReformChoices++;
     }
     else
     {
         LoadedSave.ConquestChoices++;
     }
 }
Esempio n. 19
0
    public void DisplayChoice(int choiceIndex, string text, int targetBeatID, ChoiceData choice)
    {
        if (choiceIndex < dialogueOptions.Count)
        {
            dialogueOptions[choiceIndex].gameObject.SetActive(true);

            if (choice.ChoiceResult != string.Empty)
            {
                dialogueOptions[choiceIndex].SetUpDialogue(text, targetBeatID, choice);
            }
            else
            {
                dialogueOptions[choiceIndex].SetUpDialogue(text, targetBeatID);
            }
        }
    }
Esempio n. 20
0
    public void SetUpDialogue(string newDisplayText, int targetBeatIndex)
    {
        displayText.text = newDisplayText;
        displayText.ForceMeshUpdate();
        Vector2 renderBounds = displayText.GetRenderedValues(false);

        rt.sizeDelta         = renderBounds + padding;
        this.targetBeatIndex = targetBeatIndex;
        choice = null;
        if (prevBubble != false)
        {
            RectTransform prevRT = prevBubble.GetComponent <RectTransform>();
            Vector2       offsetFromPrevBubble = (Vector2)prevBubble.transform.position - new Vector2(0.0f, prevRT.rect.height);
            transform.position = offsetFromPrevBubble - new Vector2(0.0f, rt.rect.height / 2) + offset;
        }
    }
        private void DeleteChoice(ChoiceData choice)
        {
            var choiceIndex      = _data.choices.IndexOf(choice);
            var connection       = _connections[choiceIndex];
            var serializedObject = _serializedObjects[choiceIndex];

            Undo.SetCurrentGroupName($"Delete {choice.name}");
            Undo.RecordObject(_data, $"Delete {choice.name}");

            connection.Links.ClearAllLinks();
            _data.choices.Remove(choice);
            _node.RemoveConnection(connection);
            _connections.Remove(connection);
            _serializedObjects.Remove(serializedObject);

            Undo.DestroyObjectImmediate(choice);
            Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
        }
Esempio n. 22
0
    public void pickOption(int p)
    {
        ChoiceData choice = _currentBeat.Decision[p];

        DisplayBeat(choice.NextID);

        if (choice.quest != null)
        {
            Player.instance.playerQuests.addNewQuest(choice.quest);
        }

        foreach (GameObject g in choices)
        {
            g.SetActive(false);
        }

        spawnedChoices = false;
    }
Esempio n. 23
0
    private void handleChoice(int i) 
    {
        if(i < 0 || i > _currentChoices.Length) return;

        ChoiceData choice = _currentChoices[i];
        BeatData nextBeat = _data.GetBeatById(choice.NextID);
        NPC npcSpeaking = PlayerController.instance.npcSpeaking;

        // If the choice is unavailable (button inactive) then don't continue with the choice
        if(npcSpeaking.HasUsedDialogueType(choice.Type)) return;
        if(choice.TextType == ChoiceTextType.BribeAmount && !LevelManager.instance.CanAffordBribe(i)) return;

        if(nextBeat.Type != DialogueType.Goodbye) 
        {
            switch(nextBeat.DisplayTextType) 
            {
                case SpeechType.FlatterResponse:
                    npcSpeaking.RespondToFlattery(choice.IsCorrectChoice);
                    break;
                case SpeechType.ThreatenResponse:
                    npcSpeaking.RespondToThreaten(choice.IsCorrectChoice);
                    break;
                case SpeechType.BribeResponse:
                    choice.IsCorrectChoice = npcSpeaking.ReceiveBribe(i);
                    LevelManager.instance.SpendBribe(i);
                    break;
                case SpeechType.RumourStart:
                    choice.IsCorrectChoice = npcSpeaking.CanGiveRumour() && HasRumourAvailable(npcSpeaking);
                    if(choice.IsCorrectChoice && !unlockedRumours.ContainsKey(npcSpeaking))
                    {
                        UnlockRandomRumour(npcSpeaking);
                    }
                    break;
                case SpeechType.RumourEnd:
                    npcSpeaking.CompleteRumour();
                    break;
            }
            DisplayBeat(choice.NextID, false, choice.IsCorrectChoice);
        } 
        else 
        {
            PlayerController.instance.ExitDialogue();
        }
    }
Esempio n. 24
0
    //!Ustawia typ ścieżki fabularnej wyboru.
    private void setNarrativePath(MouseUpEvent e, ChoiceData choiceData)
    {
        Toggle narrativeType = (Toggle)e.target;

        if (narrativeType.value)
        {
            choiceData.Path = (NarrativePath)Enum.Parse(typeof(NarrativePath), narrativeType.text);
            foreach (Toggle toggle in narrativeTypeToggles)
            {
                if (toggle != narrativeType)
                {
                    toggle.value = false;
                }
            }
        }
        else
        {
            narrativeType.value = true;
        }
    }
Esempio n. 25
0
    public void StartTreeDialogue()
    {
        if (_currentNode.GetIsAutoAdvancer())
        {
            Interactor interactor = FindObjectOfType <Interactor>();
            interactor.MustInteract();
        }
        string [] lines = _currentNode.GetDialogue();
        _currentNode = _currentNode.GetNextNode();
        ChoiceData choiceData = _currentNode.GetComponent <ChoiceData>();

        if (choiceData != null)
        {
            Choice choice = choiceData.GetChoice();
            _controller.StartDialogueWithChoice(lines, choice);
        }
        else
        {
            _controller.StartDialogue(lines);
        }
    }
Esempio n. 26
0
    private void UpdateInput()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (_currentBeat != null)
            {
                if (_currentBeat.ID == 1)
                {
                    Application.Quit();
                }
                else
                {
                    DisplayBeat(1);
                }
            }
        }
        else
        {
            KeyCode alpha  = KeyCode.Alpha1;
            KeyCode keypad = KeyCode.Keypad1;

            for (int count = 0; count < _currentBeat.Decision.Count; ++count)
            {
                if (alpha <= KeyCode.Alpha9 && keypad <= KeyCode.Keypad9)
                {
                    if (Input.GetKeyDown(alpha) || Input.GetKeyDown(keypad))
                    {
                        ChoiceData choice = _currentBeat.Decision[count];
                        DisplayBeat(choice.NextID);
                        break;
                    }
                }

                ++alpha;
                ++keypad;
            }
        }
    }
Esempio n. 27
0
    //!Usuwa port.
    public void removePort(Port port)
    {
        noOfPorts--;
        if (noOfPorts <= 0)
        {
            noOfPorts          = 0;
            IsLeaf             = true;
            isLeafToggle.value = true;
            isEndingToggle.SetEnabled(true);
            ExitLineLabel.SetEnabled(true);
        }

        foreach (Edge edge in port.connections)
        {
            edge.input.Disconnect(edge);
            edge.RemoveFromHierarchy();
        }
        outputContainer.Remove(port);
        ChoiceData choiceData = ChoiceOutcomes.Find(x => x.PortName == port.portName); //Nie można do fukcji przekazać po prostu choiceData, gdyż wywoływana jest także poza tą klasą.

        ChoiceOutcomes.Remove(choiceData);
        refreshNode();
    }
Esempio n. 28
0
 public void NextEvent(ChoiceData data = null, bool noAnim = false)
 {
     UpdateValues();
     StartCoroutine(INextEvent(data, noAnim));
 }
Esempio n. 29
0
 //!Ustawia wymagania wyboru co do oszustwa.
 private void setDeceptionRequirement(InputEvent e, ChoiceData choiceData)
 {
     choiceData.RequiredDeception = int.Parse(deceptionField.value);
 }
Esempio n. 30
0
 //!Ustawia wymagania wyboru co do pomyślunku.
 private void setThoughtfulnessRequirement(InputEvent e, ChoiceData choiceData)
 {
     choiceData.RequiredThoughtfulness = int.Parse(thoughtfulnessField.value);
 }