private void ParseCodes(string code, ref string fileData, int startIndex, ref int curIndex, ref int openedBracket) { while (openedBracket > 0 && curIndex < fileData.Length && fileData[curIndex] == '>') { curIndex += 1; openedBracket -= 1; } switch (code) { case "Conversation": ParseConversation(ref fileData, curIndex, out curIndex, ref openedBracket); break; case "Background": ParseBackground(fileData, curIndex, out curIndex); break; case "Parameter": ParseParameters(ref fileData, startIndex, curIndex, out curIndex, ref openedBracket); break; case "End": ConversationFileDataBase data = new ConversationFileDataBase(); data.firstCode = "End"; convDatas.Add(data); break; case "Align": ConversationFileDataAlign aData = new ConversationFileDataAlign(); aData.firstCode = "Align"; while (fileData[curIndex] != '<') { curIndex += 1; } while (fileData[curIndex] == '<') { curIndex += 1; openedBracket += 1; } aData.align = ReadUntilTagEnd(fileData, curIndex, out curIndex); while (fileData[curIndex] == '>') { curIndex += 1; openedBracket -= 1; } convDatas.Add(aData); break; case "Prefab": ConversationFileDataPrefab pData = new ConversationFileDataPrefab(); pData.firstCode = "Prefab"; while (fileData[curIndex] != '<') { curIndex += 1; } while (fileData[curIndex] == '<') { curIndex += 1; openedBracket += 1; } pData.prefabName = ReadUntilTagEnd(fileData, curIndex, out curIndex); while (fileData[curIndex] == '>') { curIndex += 1; openedBracket -= 1; } GameObject obj = Resources.Load <GameObject>("Prefabs/Conversations/Events/" + pData.prefabName); preLoadedPrefabs.Add(pData.prefabName, obj); convDatas.Add(pData); break; case "If": ParseCondition(ref fileData, ref curIndex, ref openedBracket); break; case "Comp": ParseComp(ref fileData, ref curIndex, startIndex); //Debug.Log("str " + fileData[curIndex - 1] + fileData[curIndex] + fileData[curIndex + 1]); openedBracket -= 1; break; case "File": while (fileData[curIndex] != '<') { curIndex += 1; } string link = ReadUntilTagEnd(fileData, curIndex + 1, out curIndex); ConversationFileDataFile fData = new ConversationFileDataFile(); fData.firstCode = "File"; fData.fileName = link; convDatas.Add(fData); curIndex += 1; break; case "Standing": ParseStandingCG(fileData, ref curIndex); curIndex += 1; break; case "Bgm": ConversationFileDataBGM bgmData = new ConversationFileDataBGM(); bgmData.firstCode = "Bgm"; while (fileData[curIndex] != '<') { curIndex += 1; } string musicName = ReadUntilTagEnd(fileData, curIndex + 1, out curIndex); bgmData.musicName = musicName; convDatas.Add(bgmData); break; default: Debug.LogWarning("CAN'T PARSE TAG " + code); break; } }
//다음 텍스트를 보이는 것과 관련된 가공을 맡는다. 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(); } }