/// <summary>
        /// Processes all incoming commands from user console.
        /// </summary>
        /// <param name="userInput">The user input to parse.</param>
        private void ProcessCommand(string userInput)
        {
            var executionResult = _commandsManager.Execute(userInput);

            switch (executionResult)
            {
            case ExecutionResult.Success:
            {
                break;
            }

            case ExecutionResult.EmptyCommand:
            {
                WriteEmptyCommandMessage();
                break;
            }

            case ExecutionResult.CommandNotFound:
            {
                WriteCommandNotFoundMessage();
                break;
            }

            case ExecutionResult.InvalidCommandFormat:
            {
                WriteInvalidCommandFormatMessage();
                break;
            }
            }
        }
Exemplo n.º 2
0
        public void OnLeftClick()
        {
            switch (_actionName)
            {
            case "attack":
                CommandsManager.SelectCommand(new AttackCommand(HommGame.Instance.GetCurrentBattle().GetCurrentStack()));
                break;

            case "wait":
                CommandsManager.Execute(new WaitCommand(HommGame.Instance.GetCurrentBattle().GetCurrentStack()));
                break;

            case "defend":
                CommandsManager.Execute(new DefendCommand(HommGame.Instance.GetCurrentBattle().GetCurrentStack()));
                break;

            case "surrender":
                CommandsManager.Execute(new SurrenderCommand(HommGame.Instance.GetCurrentBattle().GetCurrentArmy()));
                break;

            case "use_skill":
                CommandsManager.SelectCommand(new UseSkillCommand(HommGame.Instance.GetCurrentBattle().GetCurrentStack(), _skillName));
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            CommandsManager.onMessage         += Console.WriteLine;
            CommandsManager.onExceptionThrown += exception => Console.WriteLine(exception.Message);

            Configuration configuration = new Configuration(true, "Test", "CommandSystem-Unity");

            manager = new CommandsManager(configuration);
            manager.LoadCommands();
            Func <float, float, float> action = (a, b) => {
                if (a > b)
                {
                    return(a);
                }
                else
                {
                    return(b);
                }
            };

            manager.Add(command = new FuncCommand <float, float, float>(action));
            manager.Add(command = new FuncCommand <float[], float>(Max));
            manager.Add(command = new FuncCommand <int[], float>(Max));
            Console.WriteLine(manager.Execute("Max \"(int[])2 3\""));
        }
Exemplo n.º 4
0
        public object ExecuteAsync(Type type, object key)
        {
            StartWait();
            object r = commandsManager.Execute(type, key);

            WaitBroadcasting();
            return(r);
        }
Exemplo n.º 5
0
        public void AddGroup(string name)
        {
            Group    group   = new Group(name);
            ICommand command = new AddGroupCommand(university, group);

            commandsManager.Execute(command);
            uiManager.UpdateUI();
        }
Exemplo n.º 6
0
        public void AddUniversityMember(IUniversityMember member)
        {
            ICommand command = new AddUniversityMemberCommand(university, member);

            commandsManager.Execute(command);
            uiManager.UpdateUI();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Processes message (done in derived class) and prepares a response.
 /// </summary>
 /// <param name="command">The command to process.</param>
 public override void ProcessCommand(Command command)
 {
     CommandsManager.Execute(command);
 }