public bool ReadTextData(int _chapterNum, int _sceneNum) { string chapterStr = _chapterNum < 10 ? "0" + _chapterNum.ToString() : _chapterNum.ToString(); string sceneStr = _sceneNum < 10 ? "0" + _sceneNum.ToString() : _sceneNum.ToString(); //Debug.Log("Data/Chapter" + chapterStr + "/chapter" + chapterStr + "-scene" + sceneStr); List <Dictionary <string, object> > data = CSVReader.Read("Data/ItemStore" + "/chapter" + chapterStr + "-scene" + sceneStr); //파일이름. if (data.Count <= 0) { return(false); } List <StoreText> texts = new List <StoreText>(); //data[i]["EXP"] <이런식으로 하면 i번째 exp를 헤더로 가진 녀석이 리턴됨 for (int i = 0; i < data.Count; i++) { string postxt = data[i]["Position"].ToString(); int pos = 0; if (postxt != "") { pos = int.Parse(postxt); } StoreText tx = new StoreText(data[i]["Text"].ToString(), data[i]["Character"].ToString(), data[i]["Face"].ToString(), pos, data[i]["Background"].ToString()); texts.Add(tx); } StroeTextPrint.instance.TextStart(texts.ToArray()); return(true); }
public void TextStart(string[] _texts) //string[]을 받고 텍스트 이벤트 자체를 실행시켜주는 함수 { #region 거의 사용안될 예정이라 접어둠 nowTextActive = true; for (int i = 0; i < _texts.Length; i++) { var leftT = new StoreText(_texts[i]); storeTextList.Add(leftT); } if (!now_TextListCoroutine_active && storeTextList.Count > 0) { StartCoroutine(TextListCoroutine()); } #endregion }
IEnumerator TextListCoroutine() //받은 텍스트 리스트를 가지고 텍스트 자체를 출력해주는 함수 { now_TextListCoroutine_active = true; textObj.SetActive(true); textEndObj.SetActive(false); nowStoreTextIndex = 0; while (true) { if (storeTextList.Count <= 0) { break; } nowStoreText = storeTextList[nowStoreTextIndex]; if (now_TextLoop_active) { if (nowStoreTextIndex < storeTextList.Count) { nowStoreTextIndex++; } else { nowStoreTextIndex = 0; } } if (!now_TextLoop_active) { for (int i = 0; i <= nowStoreTextIndex; i++) { storeTextList.RemoveAt(0); } } if (now_TextSelect_idx != -1) // 선택지 검사 { if (nowStoreText.text.Length >= 6) { int selNum = IsThisSelectedText(nowStoreText.text); if (selNum == -1) { now_TextSelect_idx = -1; } else if (selNum == now_TextSelect_idx + 1) { nowStoreText.text = nowStoreText.text.Substring(6, nowStoreText.text.Length - 6); } else if (selNum != now_TextSelect_idx + 1) { continue; } } } if (nowStoreText.text.Length >= 1) { if (nowStoreText.text[0] == '#') //시작 글자가 #일 경우 커맨드 입력으로. { TextCommandActive(nowStoreText.text); continue; } } //컷씬을 표시합니다. var character = CharaOK(nowStoreText.charaName); if (character != null) { FaceImgSet(character, nowStoreText.charaFaceName, nowStoreText.charaPos); } //텍스트를 출력함. if (nowStoreText.charaName != "효과") { if (nowStoreText.text.Length > 0 && nowStoreText.text[0] == '[') // 선택지 출력 { now_TextSelect_OK = false; TextSelectCall(nowStoreText.text); yield return(new WaitUntil(() => now_TextSelect_OK)); } else // 기본 텍스트 출력 { nextText = TextCodeCommand(nowStoreText.text); if (nowStoreText.charaName == "이름없음") { nowName.text = ""; } else { nowName.text = nowStoreText.charaName; } nowText.text = ""; TextWriteInvoke(); yield return(new WaitUntil(() => !now_TextWriteInvoke_active)); yield return(new WaitUntil(() => textEndObj.activeSelf)); yield return(new WaitUntil(() => GetButtonDown)); textEndObj.SetActive(false); } } } now_TextListCoroutine_active = false; textObj.SetActive(false); nowTextActive = false; }