/// <summary> /// When a chat message is pressed, show the chat. /// </summary> /// <param name="index"></param> public void OnMessageButtonPressed(int index) { // Enable the chat canvas. GameManager.Instance.ChatCanvas.gameObject.SetActive(true); ChatScreen.SetActive(false); // Get the list of conversations so we know what to display var conversations = ProgressManager.Instance.GetCurrentTextConversationsForLevel(GameManager.Instance.CurrentLevel); // Set data on the chat canvas. GameManager.Instance.ChatCanvas.NameText.text = MessageButtons[index].GetPersonName(); // Create the conversation TextManager.Instance.ClearConversation(); var conversationObj = GameObject.Instantiate(TextConversationPrefab, GameManager.Instance.ChatCanvas.transform); TextConversation conversation = conversationObj.GetComponent <TextConversation>(); conversation.Initialize(GameManager.Instance.ChatCanvas.GetComponent <Canvas>(), MessageButtons[index].ConversationFileName); MessageButtons[index].Read(); // If all of the chats at this level have been read, advance the dialog. if (MessageButtons.ToList().All(b => b.HasBeenRead || b.Inactive)) { ProgressManager.Instance.AdvanceDialogProgress(); foreach (var button in MessageButtons) { button.HasBeenRead = false; } } }
// Example: Send a conversation text message // // Note: A message to a single contact sent immediately public static void SendTextMessage() { var client = new StagingRestClient(); try { // if you already have the user's authorization token, you can use it, like this: // client.SetAccessToken("pass in the token here"); // or prompt the user for their Text-Em-All username/password client.SetAccessTokenByPromptingForLogin(); // enter a phone number to text // e.g. your own Console.Write($"Please enter a phone number to text: "); var phoneNumber = Console.ReadLine(); // enter a text to send // please make it not spammy or salesy Console.Write($"Please enter a text message to send: "); var text = Console.ReadLine(); // if you already have the ID stored for the toll free text-number // that you want to send the message out on (e.g. 18885551234), you can use that // or you can look up one that the user has access to: var textNumbers = client.Get <Feed <TextNumber> >("/v1/textnumbers"); var textNumber = textNumbers.Items.FirstOrDefault(); if (textNumber == null) { throw new Exception("The user does not have a toll free text number set up yet."); } var textMessageToSend = new TextMessage { Message = text, Contact = new Person { PrimaryPhone = phoneNumber } }; var conversation = new TextConversation { TextNumberID = textNumber.TextNumberID, LastMessage = textMessageToSend }; // create broadcast var result = client.Post("/v1/conversations", conversation); } catch (Exception exception) { Console.WriteLine($"There was an error: {exception}"); } Console.WriteLine("Press any key to close..."); Console.ReadKey(); }
public void Start() { DinnerPartyGlobals dinnerPartyGlobals = FindObjectOfType <DinnerPartyGlobals>(); string[] guestNames = new string[dinnerPartyGlobals.Guests.Count]; for (int i = 0; i < dinnerPartyGlobals.Guests.Count; i++) { guestNames[i] = dinnerPartyGlobals.Guests[i].name; } Regex setRegex = new Regex(SetRegex); Regex convoRegex = new Regex(ConversationRegex); for (int relativeIndex = 0; relativeIndex < textAssets.Length; relativeIndex++) { string inputText = textAssets[relativeIndex].text; TextConversation inputConversation = new TextConversation(); MatchCollection setMatches = setRegex.Matches(inputText); for (int i = 0; i < setMatches.Count; i++) { MatchCollection convoMatches = convoRegex.Matches(setMatches[i].Groups["Content"].Value); List <string[]> conversation = new List <string[]>(); for (int j = 0; j < convoMatches.Count; j++) { string relative = convoMatches[j].Groups["Relative"].Value; string text = convoMatches[j].Groups["Text"].Value; text = ReplaceRelativeNames(text, guestNames); //if (relativeIndex == 5) //{ // text = text.Replace("[allergy]", ); //} conversation.Add(new string[] { relative, text }); } switch (setMatches[i].Groups["Category"].Value) { case "History": inputConversation.texts[(int)TextType.History] = conversation; break; case "Seating": inputConversation.texts[(int)TextType.SeatingReq] = conversation; break; case "Food": inputConversation.texts[(int)TextType.FoodReq] = conversation; break; case "Bringing": inputConversation.texts[(int)TextType.Bringing] = conversation; break; } } inputConversation.relative = FindObjectOfType <DinnerPartyGlobals>().Persons[relativeIndex].name; textConversations[relativeIndex] = inputConversation; } //Display Granny texts DisplayReceivedTexts(0); }