﻿using UnityEngine;
using System.Collections;

public class SpeechDialogs : MonoBehaviour {

    public GameObject SpeechPrefab;

    public string dialog0;
    public string dialog1;
    public string dialog2;
    public string dialog3;
    public string dialog4;
    public string dialog5; 
	
    public void SpawnTextAt(Vector3 pos, int stateCode)
    {
        GameObject textClone =  (GameObject)Instantiate(SpeechPrefab, pos, Quaternion.Euler(new Vector3(0, 130, 0)));
        textClone.GetComponent<Rigidbody>().velocity = new Vector3(0, 0.5f, 0);
        switch (stateCode)
        {
            case 0:
                textClone.transform.GetChild(0).GetComponent<TextMesh>().text = dialog0;
                break;
            case 1:
                textClone.transform.GetChild(0).GetComponent<TextMesh>().text = dialog1;
                break;
            case 2:
                textClone.transform.GetChild(0).GetComponent<TextMesh>().text = dialog2;
                break;
            case 3:
                textClone.transform.GetChild(0).GetComponent<TextMesh>().text = dialog3;
                break;
            case 4:
                textClone.transform.GetChild(0).GetComponent<TextMesh>().text = dialog4;
                break;
            case 5:
                textClone.transform.GetChild(0).GetComponent<TextMesh>().text = dialog5;
                break;
        }
        Destroy(textClone, 3);
    }
}
