Пример #1
0
            public bool TryMakeMove(IMovableComponent component)
            {
                var parent = component.getParent(); // Checking if a move from the parent is possible

                if (!IsMoveValid(parent))
                {
                    return(false);                      // Return that worker can't move
                }
                var targetCell = NextComponent(parent); // Getting to the next location

                // Return if we can move to the mext cell (i.e. valid) and make move
                if (targetCell.Accept(this))
                {
                    // Downcast the traget Cell to be a cell (since this is the only option to move)
                    m_movementService.MoveComponent(parent, (Cell)targetCell);

                    return(true);
                }
                return(false);
            }