public GameMenuStateMachine(MenuOption[] options) { for (int i = 0; i < options.Length; ++i) { int down = (i == options.Length - 1) ? 0 : i + 1; int up = (i == 0) ? options.Length - 1 : i - 1; transitions.Add(new StateTransition(options[i], Command.Down), options[down]); transitions.Add(new StateTransition(options[i], Command.Up), options[up]); } Current = options[0]; Current.Active(); }
private void Update() { if (Input.GetKeyDown(m_active)) { Current.Active(); } if (Input.GetKeyDown(m_ui)) { Current.UIPress(); } if (Input.GetKeyDown(m_select)) { Current.Select(); } }