Exemplo n.º 1
0
	public void init(DateTextReader.Word w){
		gameObject.AddComponent<BoxCollider2D> ();
		t.text = w._text;
		word = w;
		StartCoroutine (InterpolateRandomly ());
		t.color = Random.ColorHSV ();
	}
Exemplo n.º 2
0
	// Use this for initialization
	void Start () {
		wordsAdded = new Stack<Word> ();

		instance = this;
		sentences = new List<Sentence> ();
		FileInfo sourceFile = new FileInfo ("Assets\\" + TextFile + ".txt");
		StreamReader reader = sourceFile.OpenText ();

		string line;

		line = reader.ReadLine();
		do{
			List<Word> words = new List<Word>();
			List<WordType> slots = new List<WordType>();

			string prompt = line.Substring(0, line.IndexOf(":"));
			string comparison = prompt.Substring(0,1);
			prompt = prompt.Substring(line.IndexOf("|") + 1, prompt.Length - prompt.IndexOf("|") -1);
			string affectionString = prompt.Substring(0, prompt.IndexOf("|"));
			string promptString = prompt.Substring(prompt.IndexOf("|") + 1,prompt.Length - prompt.IndexOf("|") -1);
			int affectionNeeded = int.Parse(affectionString);

			prompt = prompt.Substring(prompt.IndexOf("|") + 1, prompt.Length - prompt.IndexOf("|") -1);

			string DatePrompt = prompt.Substring(0,prompt.IndexOf("}"));

			prompt = prompt.Substring(prompt.IndexOf("}") + 1, prompt.Length - prompt.IndexOf("}") - 1);

			string displayPrompt = "";

			int nextWord = 0;

			nextWord = prompt.IndexOf("[");
			bool buffer = true;
			while(nextWord != -1 || buffer){
				if(nextWord == -1){
					buffer = false;
					displayPrompt += prompt;

				}
				else{
					displayPrompt += prompt.Substring(0,nextWord) + "_____";
					string wordTypeString = prompt.Substring(nextWord + 1, prompt.IndexOf("]") - nextWord -1);

					switch(wordTypeString){
					case "adjective":
						slots.Add(WordType.Adjective);
						break;
					case "noun":
						slots.Add(WordType.Noun);
						break;
					case "verb":
						slots.Add(WordType.Verb);
						break;
					case "adverb":
						slots.Add(WordType.Adverb);
						break;
					case "interjection":
						slots.Add(WordType.Interjection);
						break;
					}


					prompt = prompt.Substring(prompt.IndexOf("]") + 1, prompt.Length - (prompt.IndexOf("]") + 1) );
					nextWord = prompt.IndexOf("[");

				}
			}

			prompt = line.Substring(line.IndexOf(":"),line.Length - line.IndexOf(":"));

			nextWord = prompt.IndexOf("<");
			while(nextWord != -1){
				string wordString = prompt.Substring(nextWord + 1, prompt.IndexOf("|") - nextWord - 1);

				prompt = prompt.Substring(prompt.IndexOf("|") + 1, prompt.Length - prompt.IndexOf("|") - 1);
				string s = prompt.Substring(0, prompt.IndexOf("|"));
				int points = int.Parse(s);
				prompt = prompt.Substring(prompt.IndexOf("|") + 1, prompt.Length - prompt.IndexOf("|") - 1);

				string wordTypeString = prompt.Substring(0, prompt.IndexOf(">"));
				switch(wordTypeString){
				case "adjective":
					words.Add(new Word(WordType.Adjective,wordString,points));
					break;
				case "noun":
					words.Add(new Word(WordType.Noun,wordString,points));
					break;
				case "verb":
					words.Add(new Word(WordType.Verb,wordString,points));
					break;
				case "adverb":
					words.Add(new Word(WordType.Adverb,wordString,points));
					break;

				case "interjection":
					words.Add(new Word(WordType.Interjection,wordString,points));
					break;
				case "weird":
					words.Add(new Word(WordType.Weird,wordString,points));
					break;
				}



				prompt = prompt.Substring(prompt.IndexOf(">") + 1, prompt.Length - (prompt.IndexOf(">") + 1) );
				nextWord = prompt.IndexOf("<");
			}

			string goodResponse = "";
			try{
				goodResponse = prompt.Substring(prompt.IndexOf("{") + 1, prompt.IndexOf("|") - prompt.IndexOf("{") - 1);
			}
			catch{
				goodResponse = "I agree";
			}

			string badResponse = "";
			try{
				badResponse = prompt.Substring(prompt.IndexOf("|") + 1,prompt.IndexOf("+") - prompt.IndexOf("|") - 1);
			}
			catch{
				badResponse = "I disagree";
			}

			string confusedRespons = "";
			try{
				confusedRespons = prompt.Substring(prompt.IndexOf("+") + 1, prompt.Length - prompt.IndexOf("+")-1);
			}
			catch{
				confusedRespons = "I am confused.";
			}

			line = reader.ReadLine();
			sentences.Add(new Sentence(comparison, affectionNeeded, DatePrompt,displayPrompt,slots,words,goodResponse,badResponse, confusedRespons));
		} while (line != null);

		StartCoroutine (Date ());
	}