public static void Main()
        {
            var commandHolder      = new CommandHolder(typeof(HarvestingFields));
            var commandInterpreter = new CommandInterpreter(commandHolder);

            commandInterpreter.StartExecuting();
        }
Exemplo n.º 2
0
 public Connection(TcpClient client, Server server, CommandHolder cmdHolder)
 {
     this.client    = client;
     stream         = client.GetStream();
     this.server    = server;
     this.cmdHolder = cmdHolder;
 }
Exemplo n.º 3
0
 private void FileManagerCommandsRegister(CommandHolder holder) => holder
 .Register(new ChangeDirectoryCommand(_filesManager))
 .Register(new CopyPathCommand(_filesManager))
 .Register(new DeletePathCommand(_filesManager))
 .Register(new ExitCommand(this))
 .Register(new ShowDetailsCommand(_filesManager, _consoleHandler))
 ;
Exemplo n.º 4
0
    public override IEnumerator executeTurn()
    {
        BattleCommand curCommand = pickAttack();

        if (curCommand == null)//can't attack
        {
            selectedTile = pickRandomMoveTile();
            if (selectedTile == null)
            {
                curCommand = waitCommand;
            }
            else
            {
                curCommand = moveCommand;
            }
        }

        List <Tile> possibleTargetTiles = new List <Tile>();

        curCommand.rangePattern.selectTargets(targeter.grid.tiles, possibleTargetTiles, this, curTile.x, curTile.y);

        for (int i = possibleTargetTiles.Count - 1; i >= 0; i--)
        {
            if (curCommand.isValidTargetTile(this, possibleTargetTiles[i]))
            {
                possibleTargetTiles[i].setTileState(TileState.range);
            }
        }

        //Debug.Log("selected " + selectedTile.gameObject);
        yield return(new WaitForSeconds(.5f));

        foreach (var possibleTargetTile in possibleTargetTiles)
        {
            possibleTargetTile.setTileState(TileState.normal);
        }
        chosenCommand.init(curCommand, this, selectedTile);

        possibleTargetTiles.Clear();
        possibleTargetTiles.Add(selectedTile);
        chosenCommand.command.damagePattern.selectTargets(targeter.grid.tiles, possibleTargetTiles, this, selectedTile.x, selectedTile.y);
        foreach (var possibleTargetTile in possibleTargetTiles)
        {
            possibleTargetTile.setTileState(TileState.target);
            //Debug.Log("target" + possibleTargetTile.gameObject);
        }

        yield return(StartCoroutine(chosenCommand.command.playFX(possibleTargetTiles)));

        yield return(StartCoroutine(curCommand.execute(chosenCommand.user, chosenCommand.target)));

        foreach (var possibleTargetTile in possibleTargetTiles)
        {
            possibleTargetTile.setTileState(TileState.normal);
        }
        yield return(new WaitForSeconds(.1f));

        stats.increaseStrain(chosenCommand.command.strainBoost);
        delay = chosenCommand.command.calcDelay(this);
    }
Exemplo n.º 5
0
 public void updateCommand()
 {
     CommandHolder.updateCommand(ts, ts, true);
     Assert.True(CommandHolder.getCommandEnabled(ts, ts));
     CommandHolder.updateCommand(ts, ts, false);
     Assert.False(CommandHolder.getCommandEnabled(ts, ts));
 }
Exemplo n.º 6
0
 public void addCommandNullThrows()
 {
     Assert.Throws <NullReferenceException>(() =>
                                            CommandHolder.updateCommand(ts, null, true));
     Assert.Throws <NullReferenceException>(() =>
                                            CommandHolder.updateCommand(null, ts, true));
 }
Exemplo n.º 7
0
    private void DoNextCmd()
    {
        if (_runningHolder != null)
        {
            _runningHolder.PreviewRunning(false);
        }
        _runningHolder = _holders[_nextCmdIndex];
        _runningHolder.PreviewRunning(true);

        var e = new CommandEvent();

        e.CommandType = _runningHolder.CommandType;
        e.TimelineId  = TimelineId;

        if (_nextCmdIndex == 0)
        {
            e.PhaseType = CommandPhaseType.Start;
            EventBus.Trigger(e);
        }

        e.PhaseType = CommandPhaseType.Run;
        EventBus.Trigger(e);

        if (++_nextCmdIndex >= ActiveHolderCount)
        {
            _nextCmdIndex = 0;
            e.PhaseType   = CommandPhaseType.End;
            EventBus.Trigger(e);
        }
    }
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        // get animator, rb
        animator = GetComponent <Animator>();
        rb2D     = this.GetComponent <Rigidbody2D>();

        // init state
        state = STATE.NORMAL;

        // init skills
        Skill dash   = new DashSkill();
        Skill magnet = new MagnetSkill(number);

        skills = new Skill[] { dash, magnet };

        foreach (Skill skl in skills)
        {
            skl.Init();
        }

        item = null;

        // get skill board
        myTextBoard = GameObject.Find(textBoardName[number]).GetComponent <Text>();

        // init cmdHolder
        cmdHolder = new CommandHolderKeyboard(number);
    }
Exemplo n.º 9
0
        public Task SendCommandsToUser()
        {
            string message
                = ClientInfo.getGroup(Context.ConnectionId).Equals("")
                    ? ""
                    : CommandHolder.getEnabledCommands(ClientInfo.getGroup(Context.ConnectionId));

            return(Clients.Caller.SendAsync("CommandUpdate", message));
        }
Exemplo n.º 10
0
 public void unregisteredNamesDNT()
 {
     Assert.DoesNotThrow(() => CommandHolder.removeClient(""));
     Assert.DoesNotThrow(() => CommandHolder.updateCommand("", "", true));
     Assert.DoesNotThrow(() => CommandHolder.updateCommand(ts, "", true));
     Assert.DoesNotThrow(() => CommandHolder.getCommandEnabled("", ""));
     Assert.DoesNotThrow(() => CommandHolder.getCommandEnabled(ts, ""));
     Assert.DoesNotThrow(() => CommandHolder.getEnabledCommands(""));
 }
Exemplo n.º 11
0
 private void CommandModeCommandsRegister(CommandHolder holder) => holder
 .Register(new AppendCharToCommandLineCommand(_commandHolder, _consoleHandler))
 .Register(new ExecuteFileManagerCommand(_commandHolder))
 .Register(new MoveCursorLeftCommand(_consoleHandler))
 .Register(new MoveCursorRightCommand(_commandHolder, _consoleHandler))
 .Register(new NextCommandCommand(_commandHolder))
 .Register(new PreviousCommandCommand(_commandHolder))
 .Register(new RemovePreviousCharFromCommandLineCommand(_commandHolder, _consoleHandler))
 ;
Exemplo n.º 12
0
        public void changeClientName()
        {
            string newName = ts + "0";

            CommandHolder.updateCommand(ts, ts, true);
            CommandHolder.changeClientID(ts, newName);
            Assert.DoesNotThrow(() => CommandHolder.getCommandEnabled(newName, ts));
            Assert.True(CommandHolder.getCommandEnabled(newName, ts));
            Assert.DoesNotThrow(() => CommandHolder.updateCommand(newName, ts, false));
            Assert.False(CommandHolder.getCommandEnabled(newName, ts));
        }
Exemplo n.º 13
0
        public Task JoinGroup(string group)
        {
            ClientInfo.setGroup(Context.ConnectionId, group);
            string message
                = ClientInfo.getGroup(Context.ConnectionId).Equals("")
                    ? ""
                    : CommandHolder.getEnabledCommands(ClientInfo.getGroup(Context.ConnectionId));

            Groups.AddToGroupAsync(Context.ConnectionId, group);
            return(Clients.Caller.SendAsync("CommandUpdate", message));
        }
Exemplo n.º 14
0
    public IEnumerator getTargets(CommandHolder command)
    {
        canSelectTiles = true;
        while (selectedTile == null)
        {
            yield return(null);
        }

        command.target = selectedTile;
        targetPreviewList.Clear();
        targetPreviewList.Add(selectedTile);
        command.command.damagePattern.selectTargets(grid.tiles, targetPreviewList, command.user, selectedTile.x, selectedTile.y);

        foreach (var tile in targetPreviewList)
        {
            tile.setTileState(TileState.target);
        }

        selectedTile   = null;
        canSelectTiles = false;
    }
Exemplo n.º 15
0
        public FilesManagerSystem()
        {
            _config = new();
            _config.CommandLineConfiguration = new()
            {
                X = 4,
                Y = _config.WindowHeight - 4
            };

            _consoleHandler = new(_config);
            _messenger      = new(_consoleHandler);
            _filesManager   = new(_messenger);
            _filesManager.OnDirectoryChanged += FilesManagerOnDirectoryChanged;
            _commandHolder = new (_config.InputMode, _messenger);
            _commandHolder.OnCommandChanged         += _commandHolder_OnCommandChanged;
            _commandHolder.OnCommandExecuted        += _commandHolder_OnCommandExecuted;
            _commandHolder.OnInputHandleModeChanged += CommandHolderOnOnInputHandleModeChanged;
            FileManagerCommandsRegister(_commandHolder);
            CommandModeCommandsRegister(_commandHolder);
            ViewModeCommandsRegister(_commandHolder);
            SharedCommandsRegister(_commandHolder);
        }
Exemplo n.º 16
0
 public void duplicateAddDNT()
 {
     Assert.DoesNotThrow(() => CommandHolder.addClient(ts));
 }
Exemplo n.º 17
0
 public MoveCursorRightCommand(CommandHolder holder, ConsoleHandler handler)
 {
     _holder  = holder;
     _handler = handler;
 }
Exemplo n.º 18
0
 public NextCommandCommand(CommandHolder holder) => _holder = holder;
 public AppendCharToCommandLineCommand(CommandHolder holder, ConsoleHandler handler)
 {
     _holder  = holder;
     _handler = handler;
 }
Exemplo n.º 20
0
 public void duplicateRemoveDNT()
 {
     Assert.DoesNotThrow(() => CommandHolder.removeClient(ts));
     Assert.DoesNotThrow(() => CommandHolder.removeClient(ts));
 }
Exemplo n.º 21
0
 public void addClientNullThrows()
 {
     Assert.Throws <NullReferenceException>(() => CommandHolder.addClient(null));
 }
Exemplo n.º 22
0
 public void Setup()
 {
     CommandHolder.addClient(ts);
 }
Exemplo n.º 23
0
 public void nameChangeNullThrows()
 {
     Assert.Throws <NullReferenceException>(() => CommandHolder.changeClientID(ts, null));
     Assert.Throws <NullReferenceException>(() => CommandHolder.changeClientID(null, ts));
 }
Exemplo n.º 24
0
 private void SharedCommandsRegister(CommandHolder holder) => holder
 .Register(new SwitchInputHandleModeCommand(holder), InputHandleMode.Shared)
 ;
Exemplo n.º 25
0
 public void TearDown()
 {
     CommandHolder.removeClient(ts);
 }
Exemplo n.º 26
0
 private void ViewModeCommandsRegister(CommandHolder holder) => holder
 .Register(new MoveCursorToNextLineCommand(_consoleHandler), InputHandleMode.List)
 .Register(new MoveCursorToPreviousLineCommand(_consoleHandler), InputHandleMode.List)
 .Register(new ShowSelectedLineInfoCommand(_filesManager, _consoleHandler), InputHandleMode.List)
 ;
Exemplo n.º 27
0
 public void SetUp()
 {
     _testClass = new CommandHolder();
 }
 public SwitchInputHandleModeCommand(CommandHolder holder)
 {
     _holder = holder;
 }
Exemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        // get animator, rb
        animator = GetComponent<Animator>();
        rb2D = this.GetComponent<Rigidbody2D>();

        // init state
        state = STATE.NORMAL;

        // init skills
        Skill dash = new DashSkill();
        Skill magnet = new MagnetSkill(number);
        skills = new Skill[] { dash, magnet };

        foreach (Skill skl in skills) {
            skl.Init();
        }

        item = null;

        // get skill board
        myTextBoard = GameObject.Find(textBoardName[number]).GetComponent<Text>();

        // init cmdHolder
        cmdHolder = new CommandHolderKeyboard(number);
    }
Exemplo n.º 30
0
        public void CanConstruct()
        {
            var instance = new CommandHolder();

            Assert.That(instance, Is.Not.Null);
        }
 public ExecuteFileManagerCommand(CommandHolder holder) => _holder = holder;