private void Start()
 {
     jsonScript        = FindObjectOfType <ReadInDialogue>();
     globalDioTimeline = FindObjectOfType <DioTimeline>();
     UIPopUp           = FindObjectOfType <UIPopUp>();
     marriageMeter     = FindObjectOfType <MarriageMeter>();
 }
    // Use this for initialization
    private void OnEnable()
    {
        jsonScript        = FindObjectOfType <ReadInDialogue>();
        globalDioTimeline = FindObjectOfType <DioTimeline>();
        UIPopUp           = FindObjectOfType <UIPopUp>();
        marriageMeter     = FindObjectOfType <MarriageMeter>();

        //Spouce Image set code

        if (globalDioTimeline.spouceNum == 1)
        {
            if (marriageMeter.marriageMeter <= 100 && marriageMeter.marriageMeter > 75)
            {
                dioImage.GetComponent <Image>().sprite = spouce1[0];
            }
            else if (marriageMeter.marriageMeter <= 75 && marriageMeter.marriageMeter > 50)
            {
                dioImage.GetComponent <Image>().sprite = spouce1[1];
            }
            else if (marriageMeter.marriageMeter <= 50 && marriageMeter.marriageMeter > 25)
            {
                dioImage.GetComponent <Image>().sprite = spouce1[2];
            }
            else if (marriageMeter.marriageMeter <= 25 && marriageMeter.marriageMeter >= 0)
            {
                dioImage.GetComponent <Image>().sprite = spouce1[3];
            }
        }
        else if (globalDioTimeline.spouceNum == 2)
        {
            if (marriageMeter.marriageMeter <= 100 && marriageMeter.marriageMeter > 75)
            {
                dioImage.GetComponent <Image>().sprite = spouce2[0];
            }
            else if (marriageMeter.marriageMeter <= 75 && marriageMeter.marriageMeter > 50)
            {
                dioImage.GetComponent <Image>().sprite = spouce2[1];
            }
            else if (marriageMeter.marriageMeter <= 50 && marriageMeter.marriageMeter > 25)
            {
                dioImage.GetComponent <Image>().sprite = spouce2[2];
            }
            else if (marriageMeter.marriageMeter <= 25 && marriageMeter.marriageMeter >= 0)
            {
                dioImage.GetComponent <Image>().sprite = spouce2[3];
            }
        }
        else if (globalDioTimeline.spouceNum == 3)
        {
            if (marriageMeter.marriageMeter <= 100 && marriageMeter.marriageMeter > 75)
            {
                dioImage.GetComponent <Image>().sprite = spouce3[0];
            }
            else if (marriageMeter.marriageMeter <= 75 && marriageMeter.marriageMeter > 50)
            {
                dioImage.GetComponent <Image>().sprite = spouce3[1];
            }
            else if (marriageMeter.marriageMeter <= 50 && marriageMeter.marriageMeter > 25)
            {
                dioImage.GetComponent <Image>().sprite = spouce3[2];
            }
            else if (marriageMeter.marriageMeter <= 25 && marriageMeter.marriageMeter >= 0)
            {
                dioImage.GetComponent <Image>().sprite = spouce3[3];
            }
        }

        if (currentDio != globalDioTimeline.globalDio)
        {
            currentDio  = globalDioTimeline.globalDio;
            pointsAdded = false;
        }

        currentText = "";
        gameObject.GetComponent <Text>().text = currentText;
        fullText = jsonScript.dialogues[currentDio].text;

        if (jsonScript.dialogues[currentDio].type == "question")
        {
            question = true;
        }
        else
        {
            question = false;
            if (pointsAdded == false)
            {
                marriageMeter.marriageMeter = marriageMeter.marriageMeter + 5;
                pointsAdded = true;
            }
        }


        correctResponse = jsonScript.dialogues[currentDio].answer;


        StartCoroutine(ShowText());
        // AudioSource.PlayClipAtPoint(speech, gameObject.transform.position, 2.0f);
    }
    // Start is called before the first frame update
    void Start()
    {
        globalDioTimeline = FindObjectOfType <DioTimeline>();
        string text = json.text;

        //handle names
        string name = names[(int)Random.Range(0, names.Length)];

        while (text.Contains("%Name%"))
        {
            text = text.Replace("%Name%", name);
        }
        List <string> n = new List <string>(names);

        n.Remove(name);
        names = n.ToArray();
        while (text.Contains("%RandName%"))
        {
            name = names[(int)Random.Range(0, names.Length)];
            text = text.Replace("%RandName%", name);
            n    = new List <string>(names);
            n.Remove(name);
            names = n.ToArray();
        }


        //handle colors
        string color = colors[(int)Random.Range(0, colors.Length)];

        while (text.Contains("%Color%"))
        {
            text = text.Replace("%Color%", color);
        }
        n = new List <string>(colors);
        n.Remove(color);
        colors = n.ToArray();
        while (text.Contains("%RandColor%"))
        {
            color = colors[(int)Random.Range(0, colors.Length)];
            text  = text.Replace("%RandColor%", color);
            n     = new List <string>(colors);
            n.Remove(color);
            colors = n.ToArray();
        }

        //handle events
        Debug.Log("events " + events.Length);
        string event1 = events[(int)Random.Range(0, events.Length)];

        while (text.Contains("%Event%"))
        {
            text = text.Replace("%Event%", event1);
        }
        n = new List <string>(events);
        n.Remove(event1);
        events = n.ToArray();
        while (text.Contains("%RandEvent%"))
        {
            event1 = events[(int)Random.Range(0, events.Length)];
            text   = text.Replace("%RandEvent%", event1);
            n      = new List <string>(events);
            n.Remove(event1);
            events = n.ToArray();
        }

        //handle foods
        string food = foods[(int)Random.Range(0, foods.Length)];

        while (text.Contains("%Food%"))
        {
            text = text.Replace("%Food%", food);
        }
        n = new List <string>(foods);
        n.Remove(food);
        foods = n.ToArray();
        while (text.Contains("%RandFood%"))
        {
            food = foods[(int)Random.Range(0, foods.Length)];
            text = text.Replace("%RandFood%", food);
            n    = new List <string>(foods);
            n.Remove(food);
            foods = n.ToArray();
        }

        //handle dates
        string date = dates[(int)Random.Range(0, dates.Length)];

        while (text.Contains("%Date%"))
        {
            text = text.Replace("%Date%", date);
        }
        n = new List <string>(dates);
        n.Remove(date);
        dates = n.ToArray();
        while (text.Contains("%RandDate%"))
        {
            date = dates[(int)Random.Range(0, dates.Length)];
            text = text.Replace("%RandDate%", date);
            n    = new List <string>(dates);
            n.Remove(date);
            dates = n.ToArray();
        }

        DialogueRead dr = JsonUtility.FromJson <DialogueRead>(json.text);

        dialogues = dr.dialogue;
        globalDioTimeline.ReadInReady();
    }