Enum in Dialogue?

This is towards the Alt speakers part in the RPG Dialogue system. I was just wondering when you say Enum you mean like:

enem Lines {Voice1,Voice2, Voice3};

then a bunch of extra code that told the Dialogue system witch of the 3 where talking?

I’m asking cause if I do I expand off this I want to know I’m on the right track.

1 Like

If I were implementing this, my Enum would be

public enum Speaker
{
     Speaker1,
     Player,
     Speaker2,
     Speaker3,
     Speaker4
}

This means tthat for AIConversants that use more than just SpeakerOne and Player, you’ll need to have some sort of means to identify the available speaker…
Since Speaker1 is always the AIConverant we’re interacting with and Player is… well… the player, then a simple list of alternate speakers should do the trick. Speaker2 would be alternateSpeaker[0], and so forth.

[SerializeField] List speakers = new List<string();

public void GetSpeakerName(Speaker speaker)
{
    if(speaker == Speaker.Speaker1) return gameObject.name;
    if(speaker == Speaker.Player) return player.name;
    return speakers[((int)speaker-2)];
}
5 Likes

Privacy & Terms