public void LoadLine(DialogLine Line)
    {
        ResponseButtons.ForEach(x =>
        {
            Destroy(x);
        });
        ResponseButtons.Clear();

        AssignSprites(Line);
        Character speaker = Character.GetCharacter(Line.SpeakerID);

        Line.SetFlags();

        SpeakerText.text = Character.CharactersByID[Line.SpeakerID].CharacterName;
        DialogText.text  = Line.GetDialog();
        float counter = 1.8f;
        float offset  = 90;

        Line.GetResponses().ForEach(x =>
        {
            DialogLine D = null;
            try{ D = DialogLine.DialogByLineID[x]; }catch {
                Debug.LogError("Invalid LineID: " + x);
            }

            GameObject g               = Instantiate(ResponseButtonPrefab, DialogParent.transform);
            RectTransform r            = g.GetComponent <RectTransform>();
            r.anchoredPosition         = new Vector2(ResponseButtonStartingTransform.anchoredPosition.x, ResponseButtonStartingTransform.anchoredPosition.y - (counter * offset));
            ResponseButtonController c = g.GetComponent <ResponseButtonController>();
            c.Assign(D);
            counter++;
        });
        if (Line.GetResponses().Count < 1)
        {
            GameObject    g = Instantiate(ResponseButtonPrefab, DialogParent.transform);
            RectTransform r = g.GetComponent <RectTransform>();
            r.anchoredPosition = new Vector2(ResponseButtonStartingTransform.anchoredPosition.x, ResponseButtonStartingTransform.anchoredPosition.y - counter * offset);
            ResponseButtonController c = g.GetComponent <ResponseButtonController>();
            c.AssignEnd();
        }
        DialogEvent.Invoke(Line.LineID);
    }
Exemplo n.º 2
0
 public void Assign(DialogLine L = null)
 {
     Line      = L;
     text.text = Line.GetDialog();
 }