Пример #1
0
		// Use this for initialization
		void Awake () {
			MySpeechBubble = gameObject.GetComponent <SpeechHandler> ();
			if (MySpeechBubble != null) {
				MySpeechBubble.MyDialogueText.gameObject.transform.parent.gameObject.SetActive (false);
				MySpeechBubble.SetCharacter(this);
			}
			Transform MyCharacterLabel = MySpeechBubble.MyDialogueText.transform.parent.parent.FindChild ("Label");
			if (MyCharacterLabel != null) {
				MyCharacterLabel.gameObject.transform.GetChild(0).gameObject.GetComponent<Text>().text = name;
			}
		}
Пример #2
0
		public static bool ReadDialogue(string FileName, SpeechHandler NewSpeech) {
			bool HasLoaded = false;
			List<string> MyLines = new List<string>();
			NewSpeech.Clear ();
			string CharacterName = FileName;
			//if (!FileName.Contains (".txt"))
			//	FileName += ".txt";
			string TemporaryFileName = Application.dataPath;
			
			// i can see this going bad
			if (TemporaryFileName.Contains("Assets")) {
				TemporaryFileName = TemporaryFileName.Remove(TemporaryFileName.IndexOf ("Assets"), "Assets".Length);
			}
			
			if (TemporaryFileName [TemporaryFileName.Length - 1] != '/')
				TemporaryFileName += '/';
			TemporaryFileName =  TemporaryFileName+ "Resources/"+FileName;

			
			
			TextAsset MyText = (TextAsset)Resources.Load(CharacterName, typeof(TextAsset));
			if (MyText == null)
				return false;
			//PrintText("Done: " + MyText.text);
			string[] linesInFile = MyText.text.Split('\n');
			for (int i = 0; i < linesInFile.Length; i++) {
				//Application.ExternalCall("console.log", "Loaded:" + i + ": " + linesInFile[i]);
				MyLines.Add (linesInFile[i]);
			}

			//NewSpeech.MyFile = WWW.UnEscapeURL(TemporaryFileName);
			if (MyLines.Count > 0) {
				HasLoaded = true;
			}
			//NewSpeech.MyFile = TemporaryFileName;
			LoadFile (CharacterName, NewSpeech, MyLines);
			//NewSpeech.MyFile = CharacterName;
			return HasLoaded;
		}
Пример #3
0
		public static void LoadFile(string CharacterName, SpeechHandler NewSpeech, List<string> MyLines) {
			List<string> SavedData = new List<string> ();//used to break up commands
			bool IsReadingID = false;
			bool IsReadingQuest = false;
			
			for (int i = 0; i < MyLines.Count; i++) {
				string line = MyLines[i];
				if (ContainsMainTag(line)) {
					if (IsReadingID) {
						//Debug.LogError("Adding new dialog! at line: " + line);
						DialogueLine NewDialogue = new DialogueLine(SavedData, NewSpeech.DialogueSize()+1, CharacterName);
						NewSpeech.AddDialogue (NewDialogue);
					} else if (IsReadingQuest) {
						Quest NewQuest = new Quest (SavedData);
						//Debug.LogError("Adding new quest: " + NewQuest.Name);
						if (NewSpeech.GetMainTalker())
							NewSpeech.GetMainTalker().AddQuest(NewQuest);
						else
							Debug.LogError("No main talker in conversation: " + NewSpeech.name);
					}
					SavedData.Clear();
					IsReadingID = (line.Contains ("/id"));
					IsReadingQuest =(line.Contains ("/quest"));
				}
				else {
					SavedData.Add (line);
				}
			}
			if (IsReadingID ) {
				DialogueLine NewDialogue = new DialogueLine(SavedData, NewSpeech.DialogueSize()+1, CharacterName);
				NewSpeech.AddDialogue (NewDialogue);
			}
			if (IsReadingQuest) {
				Quest NewQuest = new Quest (SavedData);
				NewSpeech.GetMainTalker().MyQuests.Add (NewQuest);
			}
		}
Пример #4
0
 public void BeginSpeech(SpeechHandler MySpeech2, bool IsFirstSpeaker)
 {
 }
Пример #5
0
        // Use this for initialization
        void Awake()
        {
            MySource = gameObject.GetComponent<AudioSource> ();
            if (MySource == null)
                MySource = gameObject.AddComponent<AudioSource> ();
            // Grab my speech handler!
            MySpeechBubble = gameObject.GetComponent <SpeechHandler> ();
            if (MySpeechBubble != null) {
                MySpeechBubble.MyDialogueText.gameObject.transform.parent.gameObject.SetActive (false);
                MySpeechBubble.SetCharacter(this);
            }

            // Title gui
            Transform MyCharacterLabel = MySpeechBubble.MyDialogueText.transform.parent.parent.FindChild ("Label");
            if (MyCharacterLabel != null) {
                MyCharacterLabel.gameObject.transform.GetChild(0).gameObject.GetComponent<Text>().text = name;
            }
        }