bool isClear = true; //화면을 클리어하고 다음 화면을 출력하는지에 대한 변수 public void Init(bool SelectInit = true) { selectList = new List <TextAndPosition>(); onlyShowList = new List <TextAndPosition>(); integratedList = new List <TextAndPosition>(); streamList = new List <TextAndPosition>(); backgroundList = new List <TextAndPosition>(); indicateList = new Dictionary <int, Object>(); spawnEnemyList = new List <TextAndPosition>(); if (SelectInit) { currentSelectNum = 0; currentArrowingText = null; } delay = 0; //문자출력딜레이 delayBackup = 0; previousStream = new TextAndPosition(); streamCount = 0; countPoint = 0; stopStart = false; stopText = new TextAndPosition(); }
public void PrintPieceOfText(TextAndPosition text) //한글자씩 출력하게 하는 메소드 { int y = 0; if (countPoint == 0) { stopText = (TextAndPosition)text.Clone(); //출력할 텍스트의 위치등의 값 복사 stopText.text = ""; //텍스트만 비우기 delayBackup = delay; } for (countPoint = 0; countPoint < text.text.Length; countPoint++) { if (text.text[countPoint] == '\n') //개행문자가 있을경우 다음줄부터 출력 { stopText.text = ""; y++; } else { stopText.text += text.text[countPoint]; Console.SetCursorPosition(stopText[0] + GlobalPositionX, stopText[1] + GlobalPositionY + y); Console.Write(stopText.text); Thread.Sleep(delay); } } stopText = null; text.textDelay = 0; countPoint = 0; delay = delayBackup; }
public void FrontDelay(TextAndPosition TAndP) { if (TAndP.textFrontDelay > 0) { Thread.Sleep(TAndP.textFrontDelay); TAndP.textFrontDelay = 0; //한번 출력한 문자는 front 딜레이를 없엔다 } }
public void AddChoiceSelectText(String choiceName, TextAndPosition selectText, Object indicate) { Choice choice = choiceDictionary[choiceName]; choice.IndicateChoice = GameManager.DictionaryRearrangement(choice.IndicateChoice); //testLog(choice.IndicateChoice[choice.SelectText.Count]); try{ choice.IndicateChoice.Add(choice.SelectText.Count, indicate); }catch (Exception e) { testLog(e.ToString() + ":" + choice.SelectText.Count + ":" + indicate); return; //choice.IndicateChoice[choice.SelectText.Count]=indicate; } choice.SelectText.Add(selectText); choice.TextArrangement(); }
protected TextAndPosition(TextAndPosition that) //추가된게 많아서 쓰려면 업데이트 하고 쓰기 //2021.8.26 업뎃 완료 { this.text = that.text; this.x = that.x; this.y = that.y; this.isSelect = that.isSelect; this.textDelay = that.textDelay; this.color = that.color; this.textFrontDelay = that.textFrontDelay; this.PriorityLayer = that.PriorityLayer; this.isStream = that.isStream; this.AlignH = that.AlignH; this.Highlight = that.Highlight; this.HighlightColor = that.HighlightColor; this.Layout = that.Layout; }
public void StreamPrint(TextAndPosition TAndP) { //FrontDelay(TAndP); delay = TAndP.textDelay; if (streamCount != 0) { Console.SetCursorPosition(previousStream[0] + GlobalPositionX, previousStream[1] + GlobalPositionY); Console.Write(ReturnSpace(streamCount)); } streamCount = TAndP.text.Length + GetKoreanCount(TAndP.text); PrintPieceOfText(TAndP); if (delay > 0) { Console.ReadKey(); } delay = 0; previousStream = TAndP; }
public int SearchSamePosition(List <TextAndPosition> list, TextAndPosition text) { for (int i = 0; i < list.Count; i++) { if (list[i].y == text.y) { if (list[i].x == text.x) { return(i); } else { return(Define.ERROR); } } return(Define.ERROR); } return(Define.ERROR); }
public void AlignX(TextAndPosition TAndP) // [frontPadding[----text----]backPadding] 중앙정렬 { int length = 0; if (TAndP.text.Contains("\n")) { String[] ts = TAndP.text.Split('\n'); length = ts[0].Length + GetKoreanCount(ts[0]); } else { length = TAndP.text.Length + GetKoreanCount(TAndP.text); } int frontPadding = 0; int backPadding = ScreenSize_Width; while (frontPadding < backPadding) { backPadding = ScreenSize_Width - (++frontPadding + length); } TAndP.x = frontPadding; }
public void DisplayBackground() { ConsoleColor tempC; if (backgroundList != null) { for (int i = 0; i < backgroundList.Count; i++) { TextAndPosition TAndP = backgroundList[i]; if (TAndP.color != null) { tempC = Console.ForegroundColor; Console.ForegroundColor = TAndP.color; } if (TAndP.text.Contains("\n")) { String[] tString = TAndP.text.Split('\n'); for (int y = 0; y < tString.Length; y++) { try{ Console.SetCursorPosition(TAndP[0] + GlobalPositionX, TAndP[1] + GlobalPositionY + y); Console.Write(tString[y]); }catch (System.ArgumentOutOfRangeException e) { Console.Write(TAndP[0] + GlobalPositionX + ","); Console.WriteLine(TAndP[1] + GlobalPositionY + y); } } } else //stopPoint == 0조건 추가하면 순차적으로 출력된다음 다음 내용 출력. 없에면 한꺼번에 출력 { FrontDelay(TAndP); //해당 텍스트를 딜레이시키고 딜레이 0으로 만듦 Console.SetCursorPosition(TAndP[0] + GlobalPositionX, TAndP[1] + GlobalPositionY); Console.Write(TAndP.text); } Console.ForegroundColor = tempC; } } }
public Choice ChangeChoiceText(String choiceName, ChoiceControler choiceControler = null, TextAndPosition onlyShowText = null, TextAndPosition selectText = null, List <TextAndPosition> streamText = null, TextAndPosition returnText = null) { if (choiceControler == null) { choiceControler = this; } //testLog(choiceName); Choice cho = choiceControler.GetChoice(choiceName); if (onlyShowText != null) { cho.OnlyShowText = new List <TextAndPosition>() { onlyShowText }; } if (selectText != null) { cho.SelectText = new List <TextAndPosition>() { selectText }; } if (streamText != null) { cho.StreamText = streamText; } if (returnText != null) { cho.ReturnText = new List <TextAndPosition>() { returnText }; } cho.TextArrangement(); return(cho); }
public void TextArrangement() //Layout종류에 따라 Text들을 정렬 ChoiceControler에 Scenario를 넣을때 호출했다. { int firstX = 0; int lastY = 0; int count = 0; if (selectText != null) { for (int i = 0; i < selectText.Count; i++) //SelectText의 레이아웃 정렬 { TextAndPosition tap = selectText[i]; if (tap.Layout == null) { continue; } if (tap.Layout == TextLayout.SELECT_DEFAULT) { if (selectText.Count == 1) { tap[0] = 22; tap[1] = 13; } else { firstX = GameManager.selectListFirststPositionX(selectText); lastY = GameManager.selectListLastPositionY(selectText); tap[0] = firstX; tap[1] = lastY + ++count; } } } } if (selectText != null) { for (int i = 0; i < selectText.Count; i++) //SelectText중 CROSSROADS의 레이아웃 정렬 { TextAndPosition tap = selectText[i]; List <TextAndPosition> crossroads = new List <TextAndPosition>(); for (int j = 0; j < selectText.Count; j++) { if (selectText[i][1] >= 19) { crossroads.Add(selectText[i]); } } if (crossroads.Count != 0) { if (tap.Layout == TextLayout.CROSSROADS_DEFAULT) { if (crossroads.Count == 1) { tap[0] = 1; tap[1] = 19; } else if (crossroads.Count == 2) { firstX = 60 - (tap.text.Length + Convenience.GetKoreanCount(tap.text)); tap[0] = firstX; tap[1] = 19; } else if (crossroads.Count > 2) { throw new Exception("이미 갈림길이 2개 있음."); } } } } } if (onlyShowText != null) { for (int i = 0; i < onlyShowText.Count; i++) { TextAndPosition tap = onlyShowText[i]; if (tap.Layout == null) { continue; } if (tap.Layout == TextLayout.ONLY_SHOW_DEFAULT) { if (onlyShowText.Count == 1) { tap[0] = 15; tap[1] = 8; } else { firstX = GameManager.selectListFirststPositionX(onlyShowText); lastY = GameManager.selectListLastPositionY(onlyShowText); tap[0] = firstX; tap[1] = lastY; } } } } if (streamText != null) { for (int i = 0; i < streamText.Count; i++) { TextAndPosition tap = streamText[i]; if (tap.Layout == null) { continue; } if (tap.Layout == TextLayout.ONLY_SHOW_DEFAULT) { tap[0] = 15; tap[1] = 8; } } } if (returnText != null) { for (int i = 0; i < returnText.Count; i++) { TextAndPosition tap = returnText[i]; if (tap.Layout == null) { continue; } if (tap.Layout == TextLayout.ONLY_SHOW_DEFAULT) { if (returnText.Count == 1) { tap[0] = 15; tap[1] = 8; } else { firstX = GameManager.selectListFirststPositionX(returnText); lastY = GameManager.selectListLastPositionY(returnText); tap[0] = firstX; tap[1] = lastY; } } } } }
public void PrintAlgorithm() { ConsoleColor tempC; if (currentArrowingText == null && selectList != null && choiceType != ChoiceType.QUICKNEXT) { //choice 첫 호출때 화살표가 보이게 하기 위함 if (!IsEmptyList <TextAndPosition>(selectList)) { if (Cho.Name == "movePhase") //movePhase에서만 선택지 초기값 랜덤으로 { Random random = new Random(); currentSelectNum = random.Next(0, 3); currentArrowingText = selectList[currentSelectNum].text; } else { currentArrowingText = selectList[0].text; } } } DisplayBackground(); if (integratedList != null) { for (int i = 0; i < integratedList.Count; i++) { TextAndPosition TAndP = integratedList[i]; if (TAndP.color != null) { tempC = Console.ForegroundColor; Console.ForegroundColor = TAndP.color; } if (TAndP.isStream) { StreamPrint(TAndP); } else if (TAndP.textDelay > 0) //텍스트의 딜레이 속성이 0보다 크면 한글자씩출력하게 함 { FrontDelay(TAndP); delay = TAndP.textDelay; PrintPieceOfText(TAndP); delay = 0; } else if (TAndP.text.Contains("\n")) //문장 사이에 개행문자가 있을시 { String[] tString = TAndP.text.Split('\n'); for (int y = 0; y < tString.Length; y++) { Console.SetCursorPosition(TAndP[0] + GlobalPositionX, TAndP[1] + GlobalPositionY + y); Console.Write(TextProcessing(tString[y], TAndP.isSelect)); } } else //stopPoint == 0조건 추가하면 순차적으로 출력된다음 다음 내용 출력. 없에면 한꺼번에 출력 { FrontDelay(TAndP); //해당 텍스트를 딜레이시키고 딜레이 0으로 만듦 Console.SetCursorPosition(TAndP[0] + GlobalPositionX, TAndP[1] + GlobalPositionY); if (!IsEmptyList <TextAndPosition>(selectList)) { if (TAndP.isSelect && choiceType != ChoiceType.QUICKNEXT) { int temp = selectList.FindIndex(x => x.text == TAndP.text); voidARROW = temp + 1 + "."; } } Console.Write(TextProcessing(TAndP.text, TAndP.isSelect)); } Console.ForegroundColor = tempC; Thread.Sleep(delay); } delay = 0; } }