public void RunCommands() { errorList = new List <CommandErrorStruct>(); AudioManager.Instance().Play(AudioClips.Click); GameController.Instance().CommandsController.CommandStartError += WriteError; GameController.Instance().CommandsController.TryStartCommandList(_commandsController._firstLevelCommands); GameController.Instance().CommandsController.CommandStartError -= WriteError; foreach (var t in GameController.Instance().CommandsController.CommandList) { Debug.Log($"Command: {t.GetType()}"); } if (errorList.Count > 0) { UIController.Instance().SetWindow(WindowsEnum.Error, config: new ErrorWindowConfig() { errors = errorList }); return; } GameController.Instance().StartCommands(); }
public CommandUI AddCommand(Transform parentTransform = null, CommandUI parentCommand = null) { AudioManager.Instance().Play(AudioClips.Click); CommandUI newCommand = FindDisableCommand(_firstLevelCommands); if (newCommand != null) { //If get disable command need remove it from parent command if (newCommand.ParentCommand == null) { _firstLevelCommands.Remove(newCommand); } else { newCommand.ParentCommand.NestedCommands.Remove(newCommand); } newCommand.gameObject.SetActive(true); } else { newCommand = SpawnNewCommand(); } if (parentTransform == null) { newCommand.transform.SetParent(transform, false); newCommand.Initialize(this, null); _firstLevelCommands.Add(newCommand); } else { newCommand.transform.parent = parentTransform; newCommand.Initialize(this, parentCommand); parentCommand.NestedCommands.Add(newCommand); } return(newCommand); }
public void SetWindow(WindowsEnum window, bool withEffect = false, BaseWindowConfig config = null) { if (withEffect) { AudioManager.Instance().Play(AudioClips.Click); } for (int i = 0; i < _windows.Length; i++) { if ((int)window == i) { _windows[i].Open(); _windows[i].SetWindowConfig(config); } else if (window != WindowsEnum.Error) { _windows[i].Close(); } } }