public void ShowSMS(SentenceObject sO, bool showAfterSentence) { SMSBoxParent.gameObject.SetActive(true); GameObject gO = Instantiate(SMSPrefab) as GameObject;; if (sO.images.Count > 0 && (!sO.images [0].appearAfterSentence || showAfterSentence)) { gO.GetComponent <SMS> ().image.sprite = sO.images [0].image; } else { gO.GetComponent <SMS> ().imageParent.SetActive(false); gO.GetComponent <SMS>().spaceAdder.gameObject.SetActive(false); } gO.GetComponent <SMS> ().message.text = sO.text; if (showAfterSentence) { gO.GetComponent <SMS> ().message.gameObject.SetActive(false); sO.images [0].alreadyShown = true; } if (lastSMS == null || sO.characterName != lastSMS.characterName) { right = !right; } if (right) { gO.GetComponent <SMS> ().layout.padding.left = SMSpadding; nbRight++; } else { gO.GetComponent <SMS> ().layout.padding.right = SMSpadding; nbLeft++; } gO.GetComponent <SMS> ().background.color = TextManager.getCharacter(sO.characterName).color; gO.GetComponent <SMS> ().characterName.text = sO.characterName; gO.transform.SetParent(SMSBoxParent.transform); slider.GetComponent <ScrollRect> ().verticalScrollbar.value = 0; Transform t = slider.parent; slider.SetParent(null); slider.SetParent(t); if (nbLeft + nbRight > 1) { StartCoroutine(ResizeContent(gO.GetComponent <RectTransform>())); } lastSMS = sO; }
public void DisplayChoices(SentenceObject sO) { nbChoice = 0; choicesShown = true; characName.text = ""; sentence.text = ""; foreach (ChoiceObject cO in sO.choices) { choices [nbChoice] = cO; nbChoice++; } choicesObject.SetActive(true); for (int i = 0; i < sO.choices.Count; i++) { choicesButtons [i].gameObject.SetActive(true); choicesTexts [i].text = choices [i].answer; } for (int i = sO.choices.Count; i < choicesButtons.Length; i++) { choicesButtons [i].gameObject.SetActive(false); } }
public void HandleSounds(SentenceObject sO) { if (sO.stopTheme) { StopAllSound(); } else { if (sO.themes.Count > 0) { PlaySound(sO.themes[0], true, false); } if (sO.themes.Count > 1) { PlaySound(sO.themes[1], false, true); } foreach (SoundObject sdO in sO.sounds) { if (sdO.sound != null) { PlaySound(sdO, false, false); } } } }
void SentenceGUI(SentenceObject sO) { GUIStyle myStyle = new GUIStyle(EditorStyles.helpBox); GUILayout.BeginHorizontal(); GUILayout.Label(sO.index / 1000 + "." + sO.index % 1000 + ".", GUILayout.Width((sO.index / 1000 + "." + sO.index % 1000 + "").Length * 10 + 5), GUILayout.Height(20)); sO.checkbox = EditorGUILayout.Toggle(sO.checkbox, GUILayout.Width(10)); if (sO.isSMS) { GUI.backgroundColor = TextManager.getCharacter(sO.characterName).color; myStyle.normal.textColor = Color.white; } else { GUI.backgroundColor = Color.black; myStyle.normal.textColor = TextManager.getCharacter(sO.characterName).color; } GUILayout.Label(sO.text, myStyle); GUI.backgroundColor = defaultColor; if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.Height(20))) { TextManager.SaveText(fileName); DetailEditor.ShowWindow(fileName, sO); } GUILayout.Space(20); GUILayout.EndHorizontal(); }
void copy(SentenceObject sentenceToCopy) { index = sentenceToCopy.index; text = sentenceToCopy.text; images = sentenceToCopy.images; fade = sentenceToCopy.fade; crossfade = sentenceToCopy.crossfade; keepPreviousImages = sentenceToCopy.keepPreviousImages; characterName = sentenceToCopy.characterName; fadeDuration = sentenceToCopy.fadeDuration; fadeInDuration = sentenceToCopy.fadeInDuration; fadeColorR = sentenceToCopy.fadeColorR; fadeColorG = sentenceToCopy.fadeColorG; fadeColorB = sentenceToCopy.fadeColorB; delayBeforeAppear = sentenceToCopy.delayBeforeAppear; sounds = sentenceToCopy.sounds; themes = sentenceToCopy.themes; inaccessible = sentenceToCopy.inaccessible; choices = sentenceToCopy.choices; isSMS = sentenceToCopy.isSMS; checkbox = sentenceToCopy.checkbox; stopTheme = sentenceToCopy.stopTheme; }
void GUIChoice() { GUILayout.Label("Choices", EditorStyles.boldLabel); //scrollPosChoice = EditorGUILayout.BeginScrollView(scrollPosChoice,false,false); for (int i = 0; i < nbChoice; i++) { GUILayout.BeginHorizontal(); choiceList [i].answer = EditorGUILayout.TextField(choiceList [i].answer); stringIndex [i] = EditorGUILayout.TextField("go to sequence from", stringIndex [i]); stringIndexEnd [i] = EditorGUILayout.TextField("to", stringIndexEnd [i]); GUILayout.EndHorizontal(); if (stringIndex [i] != null && stringIndexEnd [i] != null && stringIndex [i].Contains(".") && stringIndexEnd [i].Contains(".")) { string[] res = stringIndex [i].Split('.'); string[] res2 = stringIndexEnd [i].Split('.'); int a, b, a2, b2; if (int.TryParse(res [0], out a) && int.TryParse(res [1], out b)) { choiceList [i].nextSentenceIndex = a * 1000 + b; } if (int.TryParse(res2 [0], out a2) && int.TryParse(res2 [1], out b2)) { choiceList [i].endSequenceIndex = a2 * 1000 + b2; } SentenceObject sO = TextManager.GetSentence(choiceList [i].nextSentenceIndex); SentenceObject sOEnd = TextManager.GetSentence(choiceList [i].endSequenceIndex); GUILayout.BeginHorizontal(); GUILayout.Label(sO.text, EditorStyles.helpBox); GUILayout.Label("->"); GUILayout.Label(sOEnd.text, EditorStyles.helpBox); GUILayout.EndHorizontal(); } } //EditorGUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("New Choice")) { if (nbChoice < 4) { nbChoice++; choiceList [nbChoice - 1] = new ChoiceObject(); } } GUILayout.EndHorizontal(); }
public static void ShowWindow(string fN, SentenceObject sO) { fileName = fN; sentence = sO; animDuration = new float[100]; beginPos = new Vector2[100]; beginRot = new float[100]; beginScale = new Vector2[100]; for (int i = 0; i < beginScale.Length; i++) { beginScale [i] = Vector2.one; } endPos = new Vector2[100]; endRot = new float[100]; endScale = new Vector2[100]; for (int i = 0; i < endScale.Length; i++) { endScale [i] = Vector2.one; } soundFadeInDuration = new float[100]; soundFadeOutDuration = new float[100]; soundDelay = new float[100]; soundLoop = new bool[100]; soundList = new SoundObject[100]; imgList = new ImageObject[100]; m_ShowExtraFields = new AnimBool[100]; m_ShowExtraFieldsSound = new AnimBool[100]; choiceList = new ChoiceObject[10]; stringIndex = new string[10]; stringIndexEnd = new string[10]; options = new string[100]; appearAfterSentence = new bool[100]; ease = new bool[100]; easeOut = new bool[100]; nbImg = 0; nbSound = 0; nbChoice = 0; theme = new SoundObject(); soundscape = new SoundObject(); DetailEditor dE = (DetailEditor)EditorWindow.GetWindow(typeof(DetailEditor)); dE.init(); }
public static List <ImageObject> GetSprites(SentenceObject sO) { List <ImageObject> sprites = new List <ImageObject>(); foreach (ImageObject iO in sO.images) { sprites.Add(iO); } return(sprites); }
public static SentenceObject GetSentence(int index) { SentenceObject res = new SentenceObject(); foreach (SentenceObject sO in texts.sentences) { if (sO.index == index) { res = sO; } } return(res); }
public static SentenceObject[] GetText(LocalizationManager.Languages newTrad) { LocalizationManager.currentTrad = newTrad; SentenceObject[] myList = new SentenceObject[texts.sentences.Count]; LoadTrueText(LocalizationManager.languagesNames [newTrad]); int i = 0; foreach (SentenceObject sO in texts.sentences) { myList[i] = sO; i++; } return(myList); }
void UpdateText(bool updateMusic) { myText = myList[count]; TextManager.currentIndex = count; if (myText.isSMS) { sMSHandler.ShowSMS(myText, false); } else { textWriter.WriteText(myText); } if (updateMusic) { SoundManager.Instance.HandleSounds(myText); } SetMenuButtonFront(); }
public void WriteText(SentenceObject message) { StopAllCoroutines(); currentMessage = message.text; currentCharacter = TextManager.getCharacter(message.characterName); characterName.color = currentCharacter.color; characterName.text = ""; characterName.fontSize = Options.Instance.nameSize; if (currentCharacter.isLeft) { characterName.alignment = TextAnchor.MiddleLeft; } else { characterName.alignment = TextAnchor.MiddleRight; } /*parent.transform.SetParent(null); * parent.transform.SetParent(canvas.transform);*/ text.color = currentCharacter.color; imageSentence.color = currentCharacter.color; imageScene.color = currentCharacter.color; isWriting = true; text.fontSize = Options.Instance.textSize; SetTextFront(); StartCoroutine(TypeText(currentMessage, message.delayBeforeAppear)); }
private static SentenceObject GetSentence(string dataString) { SentenceObject so = new SentenceObject(); string[] lines = Regex.Split(dataString, "\\n"); //Debug.Log ("words.Length"+lines.Length); foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } string[] words = Regex.Split(line, "\\t"); WordGroupObject obj = new WordGroupObject(); float.TryParse(words[0], out obj.time); //This is index 1 or 2 (dependend if the time is defined twice or not) obj.text = words[words.Length - 1]; so.wordGroups.Add(obj); //Debug.Log (line); } return(so); //return JsonUtility.FromJson<SentenceObject>(dataString); }
static void LoadTrueText(string name) { List <SentenceObject> mySentenceList = new List <SentenceObject>(); string fileData; //= System.IO.File.ReadAllText(Application.dataPath+"/Resources/Texts/"+name+".txt"); TextAsset temp = Resources.Load("Texts/" + name) as TextAsset; fileData = temp.text; fileData = fileData.Replace("\n", ""); string[] groups = fileData.Split("["[0]); foreach (string myGroup in groups) { if (myGroup.Length > 0) { string[] splited = myGroup.Split("]" [0]); string mySentence = splited[1]; int index1 = int.Parse(splited [0]); string[] st = mySentence.Split("<"[0]); foreach (string s in st) { if (s.Length > 0) { splited = s.Split(">" [0]); string news = splited[1]; int index2 = int.Parse(splited [0]); SentenceObject sentence = new SentenceObject(); sentence.index = index1 * 1000 + index2; sentence.text = news; mySentenceList.Add(sentence); } } } } if (texts.sentences.Count == 0) { texts.sentences = new List <SentenceObject> (); } for (int i = 0; i < mySentenceList.Count; i++) { bool found = false; for (int j = 0; j < texts.sentences.Count; j++) { if (texts.sentences [j].index == mySentenceList [i].index) { texts.sentences [j].text = mySentenceList [i].text; found = true; } } if (!found) { SentenceObject sO = new SentenceObject(); sO.text = mySentenceList [i].text; sO.index = mySentenceList [i].index; sO.keepPreviousImages = true; texts.sentences.Add(sO); } } for (int i = 0; i < texts.sentences.Count; i++) { bool found = false; for (int j = 0; j < mySentenceList.Count; j++) { if (texts.sentences [i].index == mySentenceList [j].index) { texts.sentences [i].text = mySentenceList [j].text; found = true; } } if (!found) { texts.sentences.Remove(texts.sentences [i]); } } texts.sentences.Sort(delegate(SentenceObject a, SentenceObject b) { return((a.index).CompareTo(b.index)); }); }