예제 #1
0
        public void Initialize(CommandControllerUI controller, CommandUI parentCommand)
        {
            _controller   = controller;
            ParentCommand = parentCommand;

            _containerNestedMenu.gameObject.SetActive(false);
            _commandField.text = string.Empty;
        }
예제 #2
0
        public void DeleteCommand(CommandUI command)
        {
            if (command.ParentCommand != null)
            {
                command.ParentCommand.NestedCommands.Remove(command);
            }
            else
            {
                _firstLevelCommands.Remove(command);
            }

            command.gameObject.SetActive(false);
        }
예제 #3
0
        public void EditCommand(CommandUI commandUI, string newTextValue)
        {
            BaseCommand command;

            if (GameController.Instance().CommandsController.TryGetSimpleCommand(newTextValue, out command))
            {
                commandUI.ErrorWave.gameObject.SetActive(false);

                if (commandUI.HasNestedCommands && (command is DoCommand || command is WhileCommand))
                {
                    commandUI.MakeParent();
                }
            }
            else
            {
                commandUI.ErrorWave.gameObject.SetActive(true);
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        private CommandUI SpawnNewCommand()
        {
            CommandUI newInput = Instantiate(_defaultCommand.gameObject).GetComponent <CommandUI>();

            return(newInput);
        }