private void processSpecialSection(bool skip = false) { string actStr = ""; char nextChar = RawText.ToCharArray() [m_lastCharacterIndex]; int numSpecials = 1; while (numSpecials > 0 && m_lastCharacterIndex < RawText.Length - 1) { actStr += nextChar; m_lastCharacterIndex++; nextChar = RawText.ToCharArray() [m_lastCharacterIndex]; if (nextChar == '>') { numSpecials--; } else if (nextChar == '<') { numSpecials++; } } List <DialogueAction> executedActions = TextboxManager.ValidActions(actStr); string retStr = ""; foreach (DialogueAction da in executedActions) { if (skip) { retStr += da.SkipAction(actStr, this); } else { retStr += da.PerformAction(actStr, this); } } m_lastCharacterIndex++; m_processedText = m_processedText.Substring(0, m_lastCharacterIndex) + retStr + m_processedText.Substring(m_lastCharacterIndex); }
private string ParseSpecialSection(string section) { string actStr = ""; int charNum = 0; char nextChar = section.ToCharArray() [charNum]; actStr += nextChar; int numSpecials = 1; string retString = ""; while (numSpecials > 0 && charNum < section.Length - 1) { charNum++; nextChar = section.ToCharArray() [charNum]; if (nextChar == '>') { numSpecials--; continue; } else if (nextChar == '<') { numSpecials++; continue; } actStr += nextChar; } List <DialogueAction> executedActions = TextboxManager.ValidActions(actStr); foreach (DialogueAction da in executedActions) { retString += da.PerformAction(actStr, this); } charNum++; return(retString + section.Substring(charNum)); }
// Update is called once per frame /* Cutscene scripting guide: * Normal text is shown as dialogue for the starting character. * Using the '|' character or the enter character will create a new textbox. * At the start of a new textbox if the colon character is found within the first 18 characters, the game will attempt to search * For the character and make the dialogue come from that character instead. * * The character ` surrounds a special block. * A number will result in a pause for a certain amount of time. * $ will change the text speed * * --NOT IMPLEMENTED YET-- * > will make a character walk to another character. Needs to be followed by the character name. * < will make them walk away * ] will make them face a character * [ will make them face away. * Any text means the character would try to do an animation * --NOT IMPLEMENTED YET-- * */ void Update() { if (targetedObj != null) { transform.position += targetedObj.transform.position - lastPos; //transform.position = targetedObj.transform.position; lastPos = targetedObj.transform.position; } if (typing) { if (lastCharacter < FullText.Length) { sinceLastChar += Time.deltaTime; sinceLastSound += Time.deltaTime; if (sinceLastChar > timeBetweenChar) { if (pauseTime > 0f) { pauseTime -= Time.deltaTime; } else { lastCharacter++; char nextChar = FullText.ToCharArray() [lastCharacter - 1]; if (nextChar == '`') { //Debug.Log ("Start special section"); string actStr = ""; lastCharacter++; nextChar = FullText.ToCharArray() [lastCharacter - 1]; //Debug.Log (nextChar); string action = "pause"; float res; string test = ""; test += nextChar; if (float.TryParse(test, out res)) { } else { if (nextChar == '!') { action = "control"; } else if (nextChar == '@') { action = "camera"; } else if (nextChar == '#') { action = "scene"; } else if (nextChar == ']') { action = "faceTowards"; } else if (nextChar == '[') { //Debug.Log ("Correct Char"); action = "faceAway"; } else if (nextChar == '>') { action = "walkTowards"; } else if (nextChar == '<') { action = "walkAway"; } else if (nextChar == '$') { action = "textSpeed"; } else if (nextChar == '&') { action = "key"; } else { lastCharacter--; action = "animation"; } lastCharacter++; nextChar = FullText.ToCharArray() [lastCharacter - 1]; } bool numFound = false; string num = ""; //string targetChar = null; while (nextChar != '`') { if ((action == "walkTowards" || action == "walkAway") && nextChar == '-') { numFound = true; } else { if (numFound == true) { num += nextChar; } else { actStr += nextChar; } lastCharacter++; nextChar = FullText.ToCharArray() [lastCharacter - 1]; } } if (action == "control") { toggleControl(actStr); } else if (action == "camera") { cameraTarget(actStr); } else if (action == "walkTowards") { //Debug.Log ("Walking towards: " + actStr); walkToPoint(actStr); /*if (num.Length < 1) { * //masterSequence.walkToChar (targetChar, actStr, 1f); * } else { * //masterSequence.walkToChar (targetChar, actStr, float.Parse(num)); * }*/ } else if (action == "walkAway") { } else if (action == "faceTowards") { facePoint(actStr); //Debug.Log ("Facing towards"); //masterSequence.turnTowards (targetChar, actStr, true); } else if (action == "faceAway") { facePoint(actStr, true); //Debug.Log ("facing away"); //masterSequence.turnTowards (targetChar, actStr, false); } else if (action == "animation") { playAnimation(actStr); } else if (action == "textSpeed") { timeBetweenChar = float.Parse(actStr); } else if (action == "key") { CurrentText += TextboxManager.GetKeyString(actStr); } else if (action == "scene") { Initiate.Fade(actStr, Color.white, 2.0f); } else { pauseTime = float.Parse(actStr); } } else { if (sinceLastSound > 0.15f) { sinceLastSound = 0f; playSound(); } CurrentText += nextChar; mText.text = CurrentText; sinceLastChar = 0f; } } } } else { timeSinceStop += Time.deltaTime; if (timeSinceStop > pauseAfterType) { Destroy(gameObject); } } } }
public override void PerformAction(string actionString, Textbox originTextbox) { originTextbox.CurrentText += TextboxManager.GetKeyString(ExtractArgs(actionString, "&")[0]); }
private void Start() { theTextBox = TextboxManager.instance; }
private void SelectionFunction(DialogueOption dop) { Debug.Log("Starting seqeunce: " + dop.remainderText); TextboxManager.StartSequence(dop.remainderText); GameObject.Destroy(dop.MasterBox.gameObject); }
void DisplayLevelUp() { TextboxManager.StartSequence("~RANK UP! LEVEL " + (Instance.Level + 1) + levelUpStr); levelUpStr = ""; Instance.Level++; }
public override string PerformAction(string actionString, Textbox originTextbox) { return(TextboxManager.GetKeyString(ExtractArgs(actionString, "&")[0])); }
public void IncrementDay() { FadeToBlack(); switch (currentDay) { case DayEnums.Monday: currentDay = DayEnums.Tuesday; break; case DayEnums.Tuesday: currentDay = DayEnums.Wednesday; break; case DayEnums.Wednesday: currentDay = DayEnums.Thursday; break; case DayEnums.Thursday: currentDay = DayEnums.Friday; break; case DayEnums.Friday: currentDay = DayEnums.Saturday; break; case DayEnums.Saturday: currentDay = DayEnums.Sunday; break; case DayEnums.Sunday: currentDay = DayEnums.Monday; break; } currentTime = TimeEnums.Morning; majorActionDone = false; daysSoFar++; if (daysTillPerformance == 0) { daysTillPerformance = 1; } dayCountdown.text = "Days until performance: " + (daysTillPerformance - (daysSoFar % daysTillPerformance)); if (daysSoFar % daysTillPerformance == 0) { gradedPerformance = true; if (playerAvatar.GetComponent <PlayerManager>().trustDonna >= targetTrustLevel) { duoTrapeze = true; } foreach (IDayTimeChangeListener listener in dayTimeChangeListeners) { listener.PerformanceDay(); } } else { foreach (IDayTimeChangeListener listener in dayTimeChangeListeners) { listener.DayTimeChange(currentDay, currentTime); } } TextboxManager.GetInstance().UpdateDateTime(); Invoke("FadeOutBlack", 0.5f); }
// Use this for initialization void Start() { tm = FindObjectOfType <TextboxManager> (); }
// Use this for initialization void Start() { manager = GetComponentInParent <TextboxManager>(); player = FindObjectOfType <PlayerController>(); transform.localPosition = new Vector3(-width - 1, height / 2, 0f); SpriteRenderer[,] boxSpriteHolders = new SpriteRenderer[width, height]; edgeSpriteHolders = new SpriteRenderer[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { for (int k = 0; k < 2; k++) { SpriteRenderer spriteRenderer = Instantiate(manager.spriteRendererPrefab); spriteRenderer.transform.localPosition = transform.position + new Vector3(i, -j, 0); spriteRenderer.transform.SetParent(speechBubble); Sprite[] spriteList; // Box if (k == 0) { spriteRenderer.sortingLayerName = "Textbox"; spriteList = manager.boxSprites; boxSpriteHolders[i, j] = spriteRenderer; } // Edge else { spriteRenderer.sortingLayerName = "Textbox Edge"; spriteList = manager.edgeSprites; edgeSpriteHolders[i, j] = spriteRenderer; } // Set sprite if (i == 0) { if (height == 1) { spriteRenderer.sprite = spriteList[9]; } else if (j == 0) { spriteRenderer.sprite = spriteList[0]; } else if (j == height - 1) { spriteRenderer.sprite = spriteList[6]; } else { spriteRenderer.sprite = spriteList[3]; } } else if (i == width - 1) { if (height == 1) { spriteRenderer.sprite = spriteList[11]; } else if (j == 0) { spriteRenderer.sprite = spriteList[2]; } else if (j == height - 1) { spriteRenderer.sprite = spriteList[8]; } else { spriteRenderer.sprite = spriteList[5]; } } else { if (height == 1) { spriteRenderer.sprite = spriteList[10]; } else if (j == 0) { spriteRenderer.sprite = spriteList[1]; } else if (j == height - 1) { spriteRenderer.sprite = spriteList[7]; } else { spriteRenderer.sprite = spriteList[4]; } } } } } // Add tailport if (tailportSide == 0) { if (height == 1) { edgeSpriteHolders[width - 1, 0].sprite = manager.tailports[0]; } else { int tailportHeight = height / 2; if (tailportHeight == 0) { edgeSpriteHolders[width - 1, tailportHeight].sprite = manager.tailports[1]; } else if (tailportHeight == height - 1) { edgeSpriteHolders[width - 1, tailportHeight].sprite = manager.tailports[3]; } else { edgeSpriteHolders[width - 1, tailportHeight].sprite = manager.tailports[2]; } } manager.tail.transform.parent = transform; manager.tail.transform.localPosition = new Vector3(width, -height / 2, transform.position.z); manager.tail.SetActive(true); } maxLineCount = 3 * height - 2; maxLineLength = 4 * width - 2; StartCoroutine("DisplayText"); playerPrevPosition = player.transform.position; SetMessageBoxSide(); }