示例#1
0
        private void RegisterAction(CommandTypes type,
                                    int?XBlock = null,
                                    int?YBlock = null,
                                    char?F     = null)
        {
            BoardAction action = ActionsTranslator.TranslateAction(type, XBlock, YBlock, F);

            ActionsManager.RegisterAction(action);
        }
示例#2
0
        public void Execute()
        {
            var actions = ActionsManager.GetActions();

            if (actions.Count() == 0)
            {
                MessageBox.Show("No actions to execute",
                                "Information",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }

            Logger.LogExecutionStart();

            foreach (var action in actions)
            {
                if (!action.IsExecutable)
                {
                    Logger.LogExecution(action);
                    continue;
                }

                if (action.CommandType == CommandTypes.PLACE)
                {
                    if (!RobotStatus.GetIsPlaced())
                    {
                        RobotStatus.SetIsPlaced(true);
                    }
                }
                else if (action.Position == null)
                {
                    action.Position = ActionsTranslator.TranslatePosition(action.CommandType);

                    if (action.CommandType == CommandTypes.MOVE)
                    {
                        ActionsValidationManager.ValidateAction(action);

                        if (!action.IsExecutable)
                        {
                            Logger.LogExecution(action);
                            continue;
                        }
                    }
                }

                Logger.LogExecution(action);
                RobotStatus.Update(position: action.Position);
                UIRobotManager.Update();
            }

            ActionsManager.ClearActions();
            Logger.LogExecutionEnd();
        }