private void AddConvData(ConversationFileDataBase data) { if (convDataAddIndex == -1) { convDatas.Add(data); } else { convDatas.Insert(convDataAddIndex, data); } }
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; } }