public static void RegisterShape(
            this IGridManager gridManager,
            Vector2Int coordinate,
            Shape currentShape,
            GameObject[,] blocks)
        {
            var size  = currentShape.Size;
            var sizeX = size.x;
            var sizeY = size.y;

            for (var y = 0; y < sizeY; y++)
            {
                for (var x = 0; x < sizeX; x++)
                {
                    var currentBlock = blocks[x, y];
                    gridManager.SetBlock(
                        new Vector2Int(
                            coordinate.x + x + currentShape.Offset.x,
                            coordinate.y + y + currentShape.Offset.y),
                        currentBlock);
                    if (currentBlock != null)
                    {
                        currentBlock.transform.parent = null;
                    }
                }
            }
        }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();
            _gridConfiguraitonRepository = new GridConfiguraitonRepository();

            _temperatures            = new ValueRepository <TemperatureValue>(MainWindow_CollectionChanged);
            _temperatureChartManager = new TemperatureChartManager(_temperatures);

            _pressures            = new ValueRepository <PressureValue>(MainWindow_CollectionChanged);
            _pressureChartManager = new PressureChartManager(_pressures);

            _vacuums            = new ValueRepository <VacuumValue>(MainWindow_CollectionChanged);
            _vacuumChartManager = new VacuumChartManager(_vacuums);


            _dataGridManager = new DataGridManager(_gridConfiguraitonRepository, _pressures, _temperatures, _vacuums);
            _controlManager  = new ControlManager(_gridConfiguraitonRepository);
            _gridManager     = new GridManager(_dataGridManager, _controlManager);

            _fileControl = new FileControl(_pressures, _temperatures, _vacuums);
            _pdfControl  = new PDFControl(_pressures, _temperatures, _vacuums,
                                          (PressureChartManager)_pressureChartManager, (TemperatureChartManager)_temperatureChartManager,
                                          (VacuumChartManager)_vacuumChartManager);

            gridValues.Children[2].Visibility = Visibility.Hidden;
            TotalTIme.Text = "Tempo total: " + _temperatures.getTotalTime().ToString();
            UpdateGrid();
            MainWindow_CollectionChanged();
        }
Beispiel #3
0
        public void ShowSolutionForEnteredWords(string searchWords, IGridManager gridManager, ConsoleColor foregroundColor, ConsoleColor backgroundColor)
        {
            string searchWord = "";

            _consoleWrapper.Clear();
            _consoleWrapper.WriteLine(searchWords);
            _consoleWrapper.WriteLine();
            WriteGridToConsole(gridManager.Grid, foregroundColor, backgroundColor);

            //search for individual words in puzzle and view solution, or press enter to jump back to menu
            do
            {
                _consoleWrapper.WriteLine();
                searchWord = PromptForSearchWord();
                if (!String.IsNullOrEmpty(searchWord))
                {
                    _consoleWrapper.Clear();
                    _consoleWrapper.WriteLine(searchWords);
                    _consoleWrapper.WriteLine();
                    var coordinatesOfSearchTarget = WriteSolvedPuzzleCoordinatesToConsole(searchWord, gridManager);
                    _consoleWrapper.WriteLine();
                    WriteGridToConsole(gridManager.Grid, foregroundColor, backgroundColor, coordinatesOfSearchTarget);
                }
            } while (searchWord != "");
        }
Beispiel #4
0
        public PointList WriteSolvedPuzzleCoordinatesToConsole(string searchString, IGridManager gridManager)
        {
            string[] searchWords = searchString.Split(',');

            PointList points = new PointList();

            _wordFinder.SetSearchOrientations(_searchOrientationManager.GetSearchOrientations(gridManager));

            foreach (var searchWord in searchWords)
            {
                var coordinatesOfSearchTarget = _wordFinder.GetCoordinatesOfSearchTarget(searchWord, $"Did not find {searchWord} in puzzle.");
                if (coordinatesOfSearchTarget != null && coordinatesOfSearchTarget.Count > 0)
                {
                    _consoleWrapper.WriteLine($"{searchWord}: " + $"{coordinatesOfSearchTarget.ToString()}");

                    //create list of all coordinates of grid that are part of the puzzle solution
                    foreach (var coordinate in coordinatesOfSearchTarget)
                    {
                        if (!points.Contains(coordinate))
                        {
                            points.Add(coordinate);
                        }
                    }
                }
            }

            return(points.Count > 0 ? points : null);
        }
 public void Configure(IGridManager manager, GridVariablesLoader loader, string ColumnName)
 {
     _columnName = ColumnName;
     _manager    = manager;
     _loader     = loader;
     InitEventHandlers();
 }
        // Constructor para "Formato de Columnas VISIBLES"
        public FrmGrillasOpcionesSuperiores(string processName, string taskName, Janus.Windows.GridEX.GridEX grilla, IGridManager manager)
        {
            InitializeComponent();
            _manager      = manager;
            _processName  = processName;
            _taskName     = taskName;
            _grillaName   = grilla.Name;
            _grilla       = grilla;
            _uiController = new GrillasOpcionesSuperioresController(_processName, _taskName, _grillaName, _manager.GetLayoutProperties(string.Empty));
            // Config de UI
            this.ultraExplorerBar1.Groups["OpcionesGenerales"].Visible = false;
            this.ultraExplorerBar1.Groups["OpcionesFormato"].Visible   = true;

            // InitData.
            comboColumna.Items.AddRange(_uiController.Columns.ToArray());

            // InitEventHandlers.
            this.comboColumna.SelectedIndexChanged     += new EventHandler(comboColumna_SelectedIndexChanged);
            this.comboAlineacion.SelectedIndexChanged  += new EventHandler(comboAlineacion_SelectedIndexChanged);
            this.comboFormato.SelectedIndexChanged     += new EventHandler(comboFormato_SelectedIndexChanged);
            this.comboTipoEdicion.SelectedIndexChanged += new EventHandler(comboTipoEdicion_SelectedIndexChanged);
            this.comboTipoColumna.SelectedIndexChanged += new EventHandler(comboTipoColumna_SelectedIndexChanged);
            _uiController.ObjectHasChanged             += new EventHandler(Refresh);

            if (comboColumna.Items.Count > 0)
            {
                //Autoselecciono el primer elemento del combo.
                comboColumna.SelectedIndex = 0;
                KeyValuePar kvp = (KeyValuePar)comboColumna.SelectedItem;
                _uiController.SelectedItem = kvp.Key;
            }
        }
        public static int[] TryCollectFullRows(this IGridManager gridManager)
        {
            var grid       = gridManager.Grid;
            var dimensions = grid.Dimensions;

            var fullRows = gridManager.GetFullRows().ToArray();

            foreach (var row in fullRows)
            {
                for (var x = 0; x < dimensions.x; x++)
                {
                    Object.Destroy(gridManager.GetBlock(new Vector2Int(x, row)));
                    for (var y = row; y >= 1; y--)
                    {
                        var currentRowCoordinate  = new Vector2Int(x, y);
                        var previousRowCoordinate = new Vector2Int(x, y - 1);

                        var currentBlock = gridManager.GetBlock(previousRowCoordinate);
                        gridManager.SetBlock(currentRowCoordinate, currentBlock);

                        if (currentBlock != null)
                        {
                            currentBlock.transform.position = grid.GetWorldCoordinate(currentRowCoordinate);
                        }

                        gridManager.SetBlock(previousRowCoordinate, null);
                    }
                }
            }
            return(fullRows);
        }
Beispiel #8
0
 public void Configure(IGridManager manager, GridVariablesLoader loader, Janus.Windows.GridEX.GridEX grilla)
 {
     _loader      = loader;
     _grilla      = grilla;
     this.Enabled = (_loader.AllowSortByMergeAgregateColumn && grilla.RootTable.Groups.Count > 0 && grilla.RecordCount > 0);
     _manager     = manager;
     InitEventHandlers();
 }
 private static void LoadAndCompare(byte[] array, IGridManager fmA)
 {
     using (var stream = new MemoryStream(array))
     {
         var fmB = Factory.Instance.LoadGridManager(stream);
         Assert.That(fmA.Equals(fmB));
     }
 }
Beispiel #10
0
        public void ShowPuzzleSolution(string searchWords, IGridManager gridManager, ConsoleColor foregroundColor, ConsoleColor backgroundColor)
        {
            _consoleWrapper.Clear();
            PointList solutionCoordinates = WriteSolvedPuzzleCoordinatesToConsole(searchWords, gridManager);

            _consoleWrapper.WriteLine();
            WriteGridToConsole(gridManager.Grid, foregroundColor, backgroundColor, solutionCoordinates);
            _consoleWrapper.WriteLine();
        }
Beispiel #11
0
        /// <summary>
        /// Gets the neighbour grid component to a given position in the given direction, if one exists.
        /// The predefined directions on the <see cref="DirectionVector"/> can be combined for more combinations.
        /// </summary>
        /// <param name="mgr">The grid manager.</param>
        /// <param name="position">The position.</param>
        /// <param name="direction">The direction.</param>
        /// <returns>The neighbouring grid, or null if no neighbour exists</returns>
        public static GridComponent GetNeighbourGrid(this IGridManager mgr, Vector3 position, DirectionVector direction)
        {
            var g = mgr.GetGridComponent(position);

            var bounds = g.bounds;
            var pos    = bounds.center + ((bounds.extents + Vector3.one) * direction);

            return(mgr.GetGridComponent(pos));
        }
Beispiel #12
0
 public void Dispose()
 {
     this.Ships = null;
     if (this.GridManager != null)
     {
         this.GridManager.Dispose();
         this.GridManager = null;
     }
 }
Beispiel #13
0
        public TetrisController()
        {
            m_shapeQueueController     = new     ShapeQueueController();
            m_shapePositionCoordinator = new     ShapePositionCoordinator();
            m_gridManager = new     GridManager();
            m_switcher    = new     Switcher();

            m_shapeSpawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <IShapeSpawner>();
        }
 public void Configure(IGridManager manager, GridVariablesLoader loader, string ExcludedColumns, string ProcessName, string TaskName, string GrillaName)
 {
     _loader          = loader;
     _manager         = manager;
     _excludedColumns = ExcludedColumns;
     _processName     = ProcessName;
     _taskName        = TaskName;
     _grillaName      = GrillaName;
 }
 public List <ISearchOrientation> GetSearchOrientations(IGridManager gridManager)
 {
     return(new List <ISearchOrientation>()
     {
         new SearchOrientation(new GridToLinearHorizontalStrategy(gridManager)),
         new SearchOrientation(new GridToLinearVerticalStrategy(gridManager)),
         new SearchOrientation(new GridToLinearDiagonalNWSEStrategy(gridManager)),
         new SearchOrientation(new GridToLinearDiagonalNESWStrategy(gridManager)),
     });
 }
        public static bool CheckIfGameOver(this IGridManager gridManager,
                                           Vector2Int coordinate, Shape shape)
        {
            if (CheckVerticalCollision(gridManager, coordinate, shape, 1))
            {
                return(true);
            }

            return(false);
        }
 public void Configure(IGridManager manager, GridVariablesLoader loader, string ExcludedColumns, string ProcessName, string TaskName)
 {
     _loader           = loader;
     _manager          = manager;
     _excludedColumns  = ExcludedColumns;
     _processName      = ProcessName;
     _taskName         = TaskName;
     btnColumns.Click += new EventHandler(btnColumns_Click);
     utbGuardar.Click += new EventHandler(utbGuardar_Click);
 }
Beispiel #18
0
 public ScoreManager(IGridWrapper grid, IBubbleSpawner spawner, IScoreCalculator calculator,
                     IBubbleCollector collector, IBubbleExploder exploder, IGridManager gridManager, ScoreRange scoreRange)
 {
     this.grid        = grid;
     this.spawner     = spawner;
     this.calculator  = calculator;
     this.collector   = collector;
     this.exploder    = exploder;
     this.gridManager = gridManager;
     this.scoreRange  = scoreRange;
 }
        public static bool CheckVerticalCollision(
            this IGridManager gridManager,
            Vector2Int coordinate,
            Shape shape,
            int step)
        {
            var sizeY = shape.Size.y;

            return
                (gridManager.Grid.CheckGround(coordinate.y + shape.Offset.y, sizeY, step) ||
                 CheckCollision(gridManager, coordinate, shape, new Vector2Int(0, step)));
        }
        public static bool CheckHorizontalCollision(
            this IGridManager gridManager,
            Vector2Int coordinate,
            Shape shape,
            int step)
        {
            var sizeX = shape.Size.x;

            return
                (gridManager.Grid.CheckSide(coordinate.x + shape.Offset.x, sizeX, step) ||
                 CheckCollision(gridManager, coordinate, shape, new Vector2Int(step, 0)));
        }
Beispiel #21
0
 public void Configure(IGridManager manager, GridVariablesLoader loader, string ExcludedColumns, string ProcessName, string TaskName)
 {
     _uiController         = new GridManagerViewExportExcelController(ProcessName, TaskName);
     _loader               = loader;
     _manager              = manager;
     _excludedColumns      = ExcludedColumns;
     _processName          = ProcessName;
     _taskName             = TaskName;
     _separator            = _uiController.Separator;
     _canExportToExcel     = _uiController.CanExportToExcel;
     utbExportar.Click    += new EventHandler(utbExportar_Click);
     btnFileChooser.Click += new EventHandler(btnFileChooser_Click);
 }
Beispiel #22
0
        private Janus.Windows.GridEX.GridEX _grillaActual = new Janus.Windows.GridEX.GridEX(); // guarda la grilla actual.
        //FinMatias 20101007 - Tarea 898
        #endregion

        public void Init(IGridManager manager, string ProcessName, string TaskName, GridVariablesLoader loader)
        {
            gridManagerColumns1.Enabled                   = false;
            gridManagerViewMark1.Enabled                  = false;
            gridManagerViewExportExcel1.Enabled           = false;
            gridManagerViewSortByAgregateColumn1.Enabled  = false;
            gridManagerViewConfigurarStyleGrilla1.Enabled = false;
            gridManagerViewSaveConfig1.Enabled            = true; //Matias 20101005 - Tarea 898 (visibilidad= true o false)
            gridManagerViewSortByAgregateColumn1.AddObjectListener(this);
            this.BackColor = Color.Transparent;
            _manager       = manager;
            _loader        = loader;
            _processName   = ProcessName;
            _taskName      = TaskName;
        }
Beispiel #23
0
        public SimManager(ILogger <SimManager> logger, IOptions <ApplicationSettings> appSettings,
                          IDeviceManager deviceManager, IGridManager gridManager)
        {
            _logger        = logger;
            _appSettings   = appSettings;
            _deviceManager = deviceManager;
            _gridManager   = gridManager;

            _people   = new List <Person>();
            _zones    = new List <Zone>();
            _vehicles = new List <Vehicle>();

            _gridManager.ZoneEntered += GridZoneEntered;
            _gridManager.ZoneExited  += GridZoneExited;
        }
        public static Vector2Int GetNearestVerticalCollision(
            this IGridManager gridManager,
            Vector2Int coordinate,
            GameObject[,] blocks)
        {
            var sizeX = blocks.GetUpperBound(0) + 1;
            var sizeY = blocks.GetUpperBound(1) + 1;

            var grid = gridManager.Grid;

            for (var x = 0; x < sizeX; x++)
            {
                for (var y = sizeY - 1; y >= 0; y--)
                {
                    //for (var gridY = )
                }
            }
            return(Vector2Int.down);
        }
Beispiel #25
0
        private void Start()
        {
            _blockInitializer = GetComponent <BlockInitializer>();
            _gridManager      = _blockInitializer.GridManager;
            _grid             = _gridManager.Grid;
            var currentShape = _blockInitializer.CurrentShape;

            var spawnGridPointX = (_grid.Dimensions.x - currentShape.Size.x) / 2;

            _gridCoordinate = new Vector2Int(spawnGridPointX, 0);

            if (_gridManager.CheckIfGameOver(_gridCoordinate, currentShape))
            {
                GameOverSignal.Dispatch();
            }
            UpdatePosition();

            ShapeVerticalMoveSignal.AddListener(ShiftVertical);
            ShapeHorizontalMoveSignal.AddListener(ShiftHorizontal);
            ShapeRotateSignal.AddListener(ShiftRotate);
        }
 public void Configure(IGridManager manager, GridVariablesLoader loader, ArrayList Columns, Janus.Windows.GridEX.GridEX Grilla, string ProcessName, string TaskName, string Formulario, string TituloFormularioPadre)
 {
     _loader      = loader;
     _manager     = manager;
     _columnas    = Columns;
     _grilla      = Grilla;
     _processName = ProcessName;
     _taskName    = TaskName;
     if (Formulario == null)
     {
         _formulario = string.Empty;
     }
     else
     {
         _formulario = Formulario;
     }
     _tituloFormularioPadre = TituloFormularioPadre;
     btnConfGrilla.Click   += new EventHandler(btnConfGrilla_Click);
     this.ObtenerConfiguracionGrilla();
     _grilla.FormattingRow += new Janus.Windows.GridEX.RowLoadEventHandler(_grilla_FormattingRow);
 }
        public static IEnumerable <int> GetFullRows(this IGridManager gridManager)
        {
            var grid       = gridManager.Grid;
            var dimensions = grid.Dimensions;

            for (var y = 0; y < dimensions.y; y++)
            {
                var isFullRow = true;
                for (var x = 0; x < dimensions.x; x++)
                {
                    if (gridManager.GetBlock(new Vector2Int(x, y)) == null)
                    {
                        isFullRow = false;
                        break;
                    }
                }

                if (isFullRow)
                {
                    yield return(y);
                }
            }
        }
        // Constructor para "Mas Opciones de configuracion"
        public FrmGrillasOpcionesSuperiores(GridVariablesLoader loader, IGridManager manager, string excludedColumns, string processName, string taskName, string grillaName)
        {
            InitializeComponent();
            _manager         = manager;
            _loader          = loader;
            _excludedColumns = excludedColumns;
            _processName     = processName;
            _taskName        = taskName;
            _grillaName      = grillaName;
            _uiController    = new GrillasOpcionesSuperioresController(_processName, _taskName, _grillaName);
            // Config de UI
            this.ultraExplorerBar1.Groups["OpcionesGenerales"].Visible = true;
            this.ultraExplorerBar1.Groups["OpcionesFormato"].Visible   = false;

            // InitData.
            chkBoxExportarSQL.Checked = _uiController.ExportarSQL;
            btnFileChooser.Visible    = _uiController.ExportarSQL;
            txtPathFile.Visible       = _uiController.ExportarSQL;

            // InitEventHandlers.
            this.btnFileChooser.Click             += new EventHandler(btnFileChooser_Click);
            this.chkBoxExportarSQL.CheckedChanged += new EventHandler(chkBoxExportarSQL_CheckedChanged);
        }
Beispiel #29
0
        public override bool Paint(float dt, IPaintable canvas, IGridManager gridManager, Painter.InputState inputState, float minVal, float maxVal, Rect rect, Matrix4x4 TRS)
        {
            bool dirty      = false;
            var  pos        = inputState.GridPosition;
            var  baseCell   = gridManager.GetCell(pos);
            int  stealCells = 2;

            float stolenValue = 0;

            for (var i = -stealCells; i <= stealCells; i += 1)
            {
                for (var j = -stealCells; j <= stealCells; j += 1)
                {
                    if (i == 0 && j == 0)
                    {
                        continue;
                    }

                    var offset = gridManager.GetOffset(i, j);
                    var value  = canvas.GetValue(baseCell + offset);

                    if (value <= 0)
                    {
                        continue;
                    }

                    var stealAmount = Mathf.Min(value, Strength);

                    stolenValue += stealAmount;
                    canvas.SetValue(baseCell + offset, value - stealAmount);
                    dirty = true;
                }
            }

            canvas.SetValue(baseCell, canvas.GetValue(baseCell) + stolenValue);
            return(dirty);
        }
        private static bool CheckCollision(
            this IGridManager gridManager,
            Vector2Int coordinate,
            Shape shape,
            Vector2Int step)
        {
            var sizeX = shape.Size.x;
            var sizeY = shape.Size.y;

            var dimensions = gridManager.Grid.Dimensions;
            var maxX       = dimensions.x - 1;
            var maxY       = dimensions.y - 1;

            for (var x = 0; x < sizeX; x++)
            {
                for (var y = 0; y < sizeY; y++)
                {
                    if (!shape.GetBlock(new Vector2Int(x, y)))
                    {
                        continue;
                    }

                    var resultX = coordinate.x + x + shape.Offset.x + step.x;
                    var resultY = coordinate.y + y + shape.Offset.y + step.y;

                    resultX = Mathf.Clamp(resultX, 0, maxX);
                    resultY = Mathf.Clamp(resultY, 0, maxY);

                    if (gridManager.GetBlock(new Vector2Int(resultX, resultY)) != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #31
0
        protected override void DrawSceneGizmos(IGridManager gridManager, Painter.InputState inputState, Rect rect, Matrix4x4 TRS)
        {
            var gridSize = gridManager.GetGridSize();

            Handles.color = Color.white * 0.5f;
            Handles.CircleHandleCap(-1, inputState.PlanePosition, Quaternion.LookRotation(Vector3.up), gridSize * Radius, EventType.Repaint);
            var scaledRad = gridSize * Radius;

            for (var i = -scaledRad; i <= scaledRad; i += gridSize)
            {
                for (var j = -scaledRad; j <= scaledRad; j += gridSize)
                {
                    var pos        = inputState.GridPosition + new Vector3(i, 0, j);
                    var circleDist = Vector2.Distance(inputState.GridPosition.xz(), pos.xz());
                    if (circleDist > scaledRad)
                    {
                        continue;
                    }
                    Handles.RectangleHandleCap(-1, pos, Quaternion.LookRotation(Vector3.up), gridSize / 2, EventType.Repaint);
                }
            }
            Handles.color = Color.white;
            Handles.CircleHandleCap(-1, inputState.GridPosition, Quaternion.LookRotation(Vector3.up), gridSize * Radius, EventType.Repaint);
        }
Beispiel #32
0
 private void ResetInner()
 {
     _gridManager = Factory.Instance.CreateNewGridManager();
     CurrentGrid = new Grid(_gridManager.CurrentGrid, this);
 }
Beispiel #33
0
 private void LoadInner()
 {
     var dlg = new OpenFileDialog { DefaultExt = "sudoku", Filter = "Sodoku | *.sudoku", CheckFileExists = true };
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         using (var file = new FileStream(dlg.FileName, FileMode.Open))
         {
             _gridManager = Factory.Instance.LoadGridManager(file);
             CurrentGrid = new Grid(_gridManager.CurrentGrid, this);
         }
     }
 }
        public List<PathNode> Calculate(IGridShape start, IGridShape end, IGridManager gridManager)
        {
            var startNode = new PathNode {Position = start};
            startNode = CalculateFGH(startNode, startNode, end);

            _openList.Add(startNode);

            while (true)
            {
                _openList.Sort();

                if (_openList.Count == 0)
                    //_openList.Add(_closedList[0]);
                    return _closedList;

                var current = _openList[0];

                if (current.Position.Equals(end))
                    return _closedList;

                _closedList.Add(current);
                _openList.Remove(current);

                var neighbours = gridManager.GetNeighbours(current.Position);

                foreach (var g in neighbours)
                {
                    if (g == null) continue;

                    var c1 = _closedList.Where(x => x.Position.Equals(g)).FirstOrDefault();

                    if (!g.Blocked && (c1 == null))
                    {
                        var newNode = new PathNode { Position = g, Parent = current };
                        newNode = CalculateFGH(current, newNode, end);

                        if (!_openList.Contains(newNode))
                        {
                            newNode.Parent = current;
                            newNode = CalculateFGH(current, newNode, end);
                            _openList.Add(newNode);
                        }
                        else
                        {
                            var existingNode = _openList.First(x => x.Position.Id == newNode.Position.Id);
                            if (newNode.G < existingNode.G)
                            {
                                _openList.Remove(existingNode);
                                existingNode.Parent = current;
                                existingNode = CalculateFGH(current, existingNode, end);
                                _openList.Add(existingNode);
                                _openList.Sort();

                            }
                        }

                    }

                    //if (!g.Blocked && (c1 != null))
                    //{
                    //    var newNode = new PathNode { Position = g, Parent = current };
                    //    newNode = CalculateFGH(current, newNode, end);

                    //    if (newNode.G < c1.G)
                    //    {
                    //        _openList.Remove(c1);
                    //        _openList.Add(newNode);
                    //    }
                    //}

                }

            }
        }
Beispiel #35
0
 private void Initialise()
 {
     _gridManager = new GridHexManager<GridHexFactory, GridHex>(new GridHexFactory());
 }