MemeTexter/Assets/Scripts/MessageManager.cs
/// <summary>
/// Scrub through the MessageData text file to read in text messages as well as their messageTypes and senderTypes
/// </summary>
Scrub through the MessageData text file to read in text messages as well as their messageTypes and senderTypes
Scrub through the MessageData text file to read in text messages as well as their messageTypes and senderTypes
private static void FillGlobalDialogs()
    {
        TextAsset textFile = (TextAsset)Resources.Load("MemeFiles/MessageData");
        string[] lines = textFile.text.Split("\n"[0]);
        for (int i = 0; i < lines.Length; i++)
        {
            string[] messageData = lines[i].Split(","[0]);
            if (messageData.Length == 3)
            {
                string message;
                message = messageData[0].Trim();
                Type
                MessageType type = new MessageType();
                if (!Enum.TryParse(messageData[1].Trim(), true, out type))
                {
                    Debug.Log("Can't parse the message type on line: " + i);
                }
                SenderType sender = new SenderType();
                if (!Enum.TryParse(messageData[2].Trim(), true, out sender))
                {
                    Debug.Log("Can't parse the sender type on line: " + i);
                }
                Message m = new Message(message, type, sender);
                texts.Add(m);
            } else
            {
                Debug.Log("Problem with MessageData format on line: " + i);
            }
        }
    }
private static void FillGlobalDialogs ( ) { TextAsset textFile = ( TextAsset ) Resources . Load ( " " ) ; string [ ] lines = textFile . text . Split ( " \n " [ 0 ] ) ; for ( int i = 0 ; i < lines . Length ; i ++ ) { string [ ] messageData = lines [ i ] . Split ( " " [ 0 ] ) ; if ( messageData . Length == 3 ) { string message ; message = messageData [ 0 ] . Trim ( ) ; MessageType type = new MessageType ( ) ; if ( ! Enum . TryParse ( messageData [ 1 ] . Trim ( ) , true , out type ) ) { Debug . Log ( " " + i ) ; } SenderType sender = new SenderType ( ) ; if ( ! Enum . TryParse ( messageData [ 2 ] . Trim ( ) , true , out sender ) ) { Debug . Log ( " " + i ) ; } Message m = new Message ( message , type , sender ) ; texts . Add ( m ) ; } else { Debug . Log ( " " + i ) ; } } }
Scrub through the MessageData text file to read in text messages as well as their messageTypes and senderTypes
Scrub through the MessageData text file to read in text messages as well as their messageTypes and senderTypes
//for each line in MessageData.txt... //prepare the Message //prepare the MessageType //prepare the SenderType //build and add the message to our list