Beispiel #1
0
    private void ParseConversation(ref string fileData, int curIndex, out int outIndex, ref int openedBracket)
    {
        int startBracket = openedBracket;

        while (fileData[curIndex] != '<')
        {
            curIndex += 1;
        }
        while (fileData[curIndex] == '<')
        {
            openedBracket += 1;
            curIndex      += 1;
        }

        ConversationFileDataConv convData = new ConversationFileDataConv();

        convData.firstCode = "Conversation";

        string code = ReadUntilTagEnd(fileData, curIndex, out curIndex);

        try
        {
            convData.talkerCode = int.Parse(code);
        }
        catch
        {
            Debug.LogError("talker Code is Wrong");
        }

        while (fileData[curIndex] == '>')
        {
            openedBracket -= 1;
            curIndex      += 1;
        }


        while (fileData[curIndex] != '<')
        {
            curIndex += 1;
        }
        while (fileData[curIndex] == '<')
        {
            openedBracket += 1;
            curIndex      += 1;
        }

        string summary = ReadUntilTagEnd(fileData, curIndex, out curIndex);

        convData.convSummary = summary;
        while (fileData[curIndex] == '>')
        {
            openedBracket -= 1;
            curIndex      += 1;
        }

        while (fileData[curIndex] != '<')
        {
            curIndex += 1;
        }
        while (fileData[curIndex] == '<')
        {
            openedBracket += 1;
            curIndex      += 1;
        }

        // 선택지 여부
        string distracter = ReadUntilTagEnd(fileData, curIndex, out curIndex);

        convData.hasDistracter = bool.Parse(distracter);

        while (fileData[curIndex] == '>')
        {
            openedBracket -= 1;
            curIndex      += 1;
        }

        // 선택지 파싱
        if (convData.hasDistracter)
        {
            DistracterData data = ParseDistracters(ref fileData, curIndex, out curIndex, ref openedBracket);
            convData.distracter = data;
        }
        convDatas.Add(convData);


        outIndex = curIndex;
    }
Beispiel #2
0
    //다음 텍스트를 보이는 것과 관련된 가공을 맡는다.
    public void ShowText()
    {
        if (curConvIndex < convDatas.Count)
        {
            string code = convDatas[curConvIndex].firstCode;

            if (convText.CanBeUsed)
            {
                while (code != "Conversation" && curConvIndex < convDatas.Count)
                {
                    switch (code)
                    {
                    case "Background":
                        ConversationFileDataBackground data = (ConversationFileDataBackground)convDatas[curConvIndex];
                        Sprite sprite;
                        preLoadedSprites.TryGetValue(data.fileName, out sprite);

                        background.sprite = sprite;
                        break;

                    case "Align":
                        convText.ClearText();
                        ParseAlignData();

                        break;

                    case "Prefab":
                        ParsePrefab((ConversationFileDataPrefab)convDatas[curConvIndex]);

                        break;

                    case "File":
                        string link = ((ConversationFileDataFile)convDatas[curConvIndex]).fileName;

                        InitConversationDatas();
                        ParseConvFile(link);
                        ShowText();
                        return;

                    case "Standing":
                        ParseStandingCgExecute((ConversationFileDataStanding)convDatas[curConvIndex]);

                        break;

                    case "End":
                        EventManager.Instance.EventEnded();
                        return;

                    case "Bgm":
                        ConversationFileDataBGM bgmData = (ConversationFileDataBGM)convDatas[curConvIndex];

                        SoundManager.Instance.PlayBackground(bgmData.musicName);

                        break;

                    default:
                        Debug.LogError("CAN'T Parse Tag " + code);

                        break;
                    }

                    curConvIndex += 1;
                    code          = convDatas[curConvIndex].firstCode;
                }

                ConversationFileDataConv convData = (ConversationFileDataConv)convDatas[curConvIndex];
                if (convText.setNewString(convData.convSummary))
                {
                    string talker;
                    talkerName.TryGetValue(convData.talkerCode, out talker);
                    if (convData.talkerCode == -1)
                    {
                        Color clr = talkerBack.color;
                        clr.a            = 0;
                        talkerBack.color = clr;
                    }
                    else
                    {
                        Color clr = talkerBack.color;
                        clr.a            = 1;
                        talkerBack.color = clr;
                    }
                    talkerText.text = talker;

                    if (convData.hasDistracter)
                    {
                        StartCoroutine(CorCheckDistracter(curConvIndex));
                    }

                    curConvIndex += 1;
                }
            }
            else
            {
                convText.ShowWholeText();
            }
        }
        else if (curConvIndex == convDatas.Count)
        {
            convText.ShowWholeText();
        }
    }