using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class TextController : MonoBehaviour { public Text text; Vertex curr_state; Map map; World world; // Use this for initialization void Start () { world = new World(); map = world.CurrentMap(); curr_state = map.StartPoint(); text.text = Message(curr_state); } // Update is called once per frame void Update () { if (world.HasEnded() && map.IsEnd(curr_state)) { text.text = "THE END"; } else if (map.IsEnd(curr_state)) { map = world.NextMap(); curr_state = map.StartPoint(); text.text = Message(curr_state); } else { foreach (Edge element in curr_state.Neighbors()) if (Input.inputString.ToUpper() == element.action.ToString()) { curr_state = element.RelatedVertex(); text.text = Message(curr_state); } } } string Message (Vertex state) { string msg = state.msg + "\n\n"; if (state.Neighbors().Count > 0) msg += "Press "; foreach (Edge element in state.Neighbors()) msg += "" + element.action + " for " + element.action_name + ". "; return msg; } }