MUD Demo

"

Strange as it might seem, I keep trying to make the kit more powerful and impressive and the more attention it gets, the more people ask me about how suitable this kit is for making text based adventures. To that end I created this MUD to show exactly how versatile THE Dialogue Engine can be. As complex (Visual Novel) or as simple (MUD) as you need it to be…

This entire demo was created in 2 hours only. It consists of exactly 1 script and then the MUD text. I am including both so you can see exactly what it took to create this game. This game will remember your previous play throughs even after reloading the page, will change based on how often you die, provide a special path only for those who really suck 😛 and all the while demonstrates how to redirect the dialogue back and forth, keep track of past actions and modify the paths based on that…

using UnityEngine;

using UnityEngine.UI;

using MBS;



public class UDEAMUD : UDEA {



	public Text 

	narrative,

	options;



	public GameObject 

	start_button,

	text_objects;



	bool 

	can_continue;



	void Start () {

		OnSpeakEnd +=  DisplayNewText;

		OnDialogueEnded += Afterwards;

		OnTypewriterModeUpdate += UpdateText;

		GameKeys.Load("game_data");

	}



	public void StartGame()

	{

		start_button.SetActive(false);

		text_objects.SetActive(true);

		DisplayNewText( null, null );

		StartDialogue(0);

	}

	

	void DisplayNewText(object source, UDEAEvent e)

	{

		can_continue = false;

		narrative.text = options.text = string.Empty;

	}



	void UpdateText(object source, UDEAEvent e)

	{

		narrative.text = FormattedText;

		if (FormattedText == CurrentText)

		{

			options.text = CurrentLine.String("options");

			can_continue = true;

			GameKeys.Save("game_data");

		}

	}



	void Afterwards(object source, UDEAEvent e)

	{

		narrative.text = options.text = string.Empty;

		GameKeys.Save("game_data");

		start_button.SetActive(true);

		text_objects.SetActive(false);

	}



	void Choose(int option)

	{

		if ( option >= CurrentOptionCount) 

			return;

		OptionSelect(option);

		Speak();

	}

	override public void HandleInput ()

	{

		if (HasEnded || !can_continue) 

			return;



		if (CurrentIsChoice)

		{

			if (Input.GetKeyUp(KeyCode.Alpha1)) Choose(0);

			if (Input.GetKeyUp(KeyCode.Alpha2)) Choose(1);

			if (Input.GetKeyUp(KeyCode.Alpha3)) Choose(2);

			if (Input.GetKeyUp(KeyCode.Alpha4)) Choose(3);

			if (Input.GetKeyUp(KeyCode.Alpha5)) Choose(4);

			if (Input.GetKeyUp(KeyCode.Alpha6)) Choose(5);

		} else

			if (Input.GetKeyUp(KeyCode.Alpha1))

				Speak();

	}

}

And here is the actual text for the entire game. Try to beat the game before you look at the text just to avoid the spoilers 😉

mud_text