// This function will spawn a bubble within the bounds of minx,maxx,miny,maxy if it is time to do so // The way this function is set up it should make spawnRate act as a linear scale // between spawning never and spawning every single frame void TrySpawn() { // If the spawn timers is greater than or equal to 1 // then we spawn a bubble and reset the timer if (spawnTimer >= 1) { bubble.GetComponentInChildren <TextMesh>().text = nameText.GetName(); Instantiate(bubble, new Vector2(transform.position.x + Random.Range(minx, maxx), transform.position.y + Random.Range(miny, maxy)), Quaternion.identity, transform); spawnTimer = 0; } // Otherwise we add spawnRate to spawnTimer else { spawnTimer += spawnRate; } }
// Use this for initialization void Start() { GetComponentInChildren <TextMesh>().text = NameGen.GetName(); }
public static string Next() { return(JobTitleGen.GetJobTitle() + ": " + NameGen.GetName()); }
private void CreateNewName() { //this is how you get a name //you can call any function from the generator and immediately assign it to a string-variable exampleName = nameGenerator.GetName(); }
private void PopulateCredits(Text text, bool startingText = false) { const int linesPerScreen = 15; var sb = new StringBuilder(); if (startingText) { sb.AppendLine("Producer"); sb.AppendLine(BigNameSize + "Blair Knickerbocker" + EndSize); sb.AppendLine(); sb.AppendLine("Directed by"); sb.AppendLine(BigNameSize + "James Walker" + EndSize); sb.AppendLine(); sb.AppendLine("Sound Direction by"); sb.AppendLine(BigNameSize + "Katie Tarrant" + EndSize); sb.AppendLine(); sb.AppendLine("Art Direction by"); sb.AppendLine(BigNameSize + "Rachael Jones" + EndSize); sb.AppendLine(); } else { switch (Random.Range(0, 10)) { case 0: case 1: case 2: // Job Title // Name1 Name2 sb.AppendLine(BigNameSize + JobTitleGen.GetJobTitlePlural() + EndSize); sb.AppendLine(); var names2 = new KeyValuePair <string, string> [linesPerScreen - 2]; for (int i = 0; i < names2.Length; i++) { names2[i] = new KeyValuePair <string, string>(NameGen.GetName(), NameGen.GetName()); } var maxNameWidth = names2.SelectMany(n => new[] { n.Key, n.Value }).OrderByDescending(n => n.Length).First().Length; var format = string.Format("{{0,-{0}}} {{1,{0}}}", maxNameWidth); for (int i = 0; i < names2.Length; i++) { sb.AppendLine(string.Format(format, names2[i].Key, names2[i].Value)); } break; case 3: case 4: case 5: // Job Title // Name1 Name2 // Job Title // Name1 Name2 const int linesPerBlock = 4; for (int j = 0; j < 2; j++) { sb.AppendLine(BigNameSize + JobTitleGen.GetJobTitlePlural() + EndSize); sb.AppendLine(); var names3 = new KeyValuePair <string, string> [linesPerBlock]; for (int i = 0; i < linesPerBlock; i++) { names3[i] = new KeyValuePair <string, string>(NameGen.GetName(), NameGen.GetName()); } maxNameWidth = names3.SelectMany(n => new[] { n.Key, n.Value }).OrderByDescending(n => n.Length).First().Length; format = string.Format("{{0,-{0}}} {{1,{0}}}", maxNameWidth); for (int i = 0; i < names3.Length; i++) { sb.AppendLine(string.Format(format, names3[i].Key, names3[i].Value)); } sb.AppendLine(); } break; case 6: case 7: case 8: switch (Random.Range(0, 2)) { case 0: sb.AppendLine(LargeSize + "Special Thanks to" + EndSize); break; case 1: sb.AppendLine(LargeSize + "Extras" + EndSize); break; } sb.AppendLine(); names2 = new KeyValuePair <string, string> [linesPerScreen - 2]; for (int i = 0; i < names2.Length; i++) { names2[i] = new KeyValuePair <string, string>(JobTitleGen.GetJobTitle(), NameGen.GetName()); } maxNameWidth = names2.SelectMany(n => new[] { n.Key, n.Value }).OrderByDescending(n => n.Length).First().Length; format = string.Format("<b>{{0,-{0}}}</b> {{1,{0}}}", maxNameWidth); for (int i = 0; i < names2.Length; i++) { sb.AppendLine(string.Format(format, names2[i].Key, names2[i].Value)); } break; case 9: // Production babies! sb.AppendLine(LargeSize + "Production Babies!" + EndSize); sb.AppendLine(); names2 = new KeyValuePair <string, string> [linesPerScreen - 2]; for (int i = 0; i < names2.Length; i++) { names2[i] = new KeyValuePair <string, string>(NameGen.GetName(), NameGen.GetName()); } maxNameWidth = names2.SelectMany(n => new[] { n.Key, n.Value }).OrderByDescending(n => n.Length).First().Length; format = string.Format("{{0,-{0}}} {{1,{0}}}", maxNameWidth); for (int i = 0; i < names2.Length; i++) { sb.AppendLine(string.Format(format, names2[i].Key, names2[i].Value)); } break; case 10: break; } } text.text = sb.ToString(); }