示例#1
0
        /// <summary>
        /// Returns a Collection of Tiles inside a Circle based on the Range Specified
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="request"></param>
        /// <param name="callback"></param>
        public static void FindCircleRange(this Tilemap grid, CircleRangeRequest request, System.Action <RangeResult> callback)
        {
            List <Tile>   circleTiles = new List <Tile>();
            List <ushort> distances   = new List <ushort>();

            Intersection originIntersection = grid.GetNearestIntersection(request.point);
            int          radius = request.range / 5;
            int          originX = originIntersection.x - radius, limitX = originIntersection.x + radius;
            int          originY = originIntersection.y - radius, limitY = originIntersection.y + radius;

            for (int y = originY; y <= limitY; y++)
            {
                for (int x = originX; x <= limitX; x++)
                {
                    if (y >= 0 && x >= 0 && y < (grid.Rows + 1) && x < (grid.Columns + 1))
                    {
                        if (GridUtility.GetDistanceBetweenIntersections(grid.Intersections[x, y], originIntersection) <= request.range)
                        {
                            circleTiles.Add(grid.GetEncompassedTile(grid.Intersections[x, y], originIntersection));
                            distances.Add((ushort)GridUtility.GetDistanceBetweenIntersections(grid.Intersections[x, y], originIntersection));
                        }
                    }
                }
            }

            CircleRange = circleTiles;
            callback(new CircleRangeResult(circleTiles.ToArray(), distances.ToArray(), request.callback));
        }
示例#2
0
        void Draw3DGrid()
        {
            int hash = GridUtility.GenerateHash(grid, Color.white);

            if (hash != gridHash || gridMesh == null)
            {
                DestroyGrid();
                gridMesh = GridUtility.GenerateGridMesh(grid, Color.white);
                gridHash = GridUtility.GenerateHash(grid, Color.white);
            }
            lineMaterial.SetPass(0);
            GL.PushMatrix();
            if (gridMesh.GetTopology(0) == MeshTopology.Lines)
            {
                GL.Begin(GL.LINES);
            }
            else
            {
                GL.Begin(GL.QUADS);
            }

            Graphics.DrawMeshNow(gridMesh, archi.transform.localToWorldMatrix);
            GL.End();
            GL.PopMatrix();
        }
示例#3
0
 private void OnEnable()
 {
     archi            = (Archi)target;
     lineMaterial     = Resources.Load <Material>("Materials/Line");
     grid             = archi.grid;
     gridHash         = GridUtility.GenerateHash(grid, Color.white);
     _rootElement     = new VisualElement();
     _visualTree      = Resources.Load <VisualTreeAsset>("UXML/MainWindow");
     materialPreviews = new List <GUIContent>(archi.materials.Count);
     tilePreviews     = new List <GUIContent>(archi.Tiles.Count);
     archi.tools      = new Tools.Tool[]
     {
         new Brush(Resources.Load <Texture2D>("Icons/brush")),
         new Rectangle(Resources.Load <Texture2D>("Icons/rectangle")),
         new FilledRectangle(Resources.Load <Texture2D>("Icons/filledrect")),
     };
     //print(archi.tools.Length);
     toolPreviews = new List <GUIContent>();
     for (int i = 0; i < archi.tools.Length; i++)
     {
         toolPreviews.Add(new GUIContent(archi.tools[i].icon, archi.tools[i].GetType().ToString()));
     }
     UpdateMaterialPreviews();
     UpdateTilePreviews();
     selectedTile      = archi.selectedTile;
     tiles             = archi.tiles;
     MouseCellWorldPos = Vector3.zero;
 }
示例#4
0
        public override IEnumerator Execute()
        {
            var centerTile       = GameManager.Instance.SelectionManager.SelectedTower.Tile;
            var centerTileHolder = GameManager.Instance.GridHolder.TileHolders[centerTile.Index];
            var zone             = GridUtility.SquaredZone(centerTile, range);

            zone.Remove(centerTile);
            var wait = new WaitForSeconds(animationTime);

            GameManager.Instance.SelectionManager.AddToBadTarget(centerTileHolder.gameObject);

            foreach (var tile in zone)
            {
                if (tile.GridObject is Tower tower)
                {
                    if (tower.Health == tower.MaxHealth)
                    {
                        continue;
                    }

                    var tileHolder = GameManager.Instance.GridHolder.TileHolders[tile.Index];
                    GameManager.Instance.SelectionManager.AddToGoodTarget(tileHolder.gameObject);
                    yield return(wait);

                    tower.Health += amount;
                    GameManager.Instance.SelectionManager.RemoveFromGoodTarget(tileHolder.gameObject);
                }
            }
            GameManager.Instance.SelectionManager.RemoveFromBadTarget(centerTileHolder.gameObject);
        }
示例#5
0
    /// <summary>
    /// Called when MouseUp event is fired.
    /// </summary>
    /// <param name="tile"> the tile we're placing </param>
    /// <param name="materials"> array of materials to apply to tile </param>
    /// <param name="closestCell"> closest cell to mouse position</param>
    /// <param name="archi"> reference to the Archi script </param>
    public override void MouseUp(GameObject tile, Material[] materials, Vector3Int closestCell, Archi.Core.Archi archi, bool erase) //man I really need a better naming convention...
    {
        mouseEnd = GridUtility.GetCellCenter(closestCell, archi.grid);
        Vector3 size   = (mouseStart - mouseEnd);
        Bounds  bounds = new Bounds(mouseStart - size / 2, vecAbs(size));

        for (int x = (int)bounds.min.x; x <= (int)bounds.max.x; x++)
        {
            for (int y = (int)bounds.min.z; y <= (int)bounds.max.z; y++)
            {
                Vector3Int cell = archi.grid.WorldToCell(new Vector3(x, 0, y));
                if (!archi.tiles.ContainsKey(cell) && !erase)
                {
                    archi.PlaceTile(cell, GridUtility.GetCellCenter(cell, archi.grid), tile);
                }
                else if (erase && archi.tiles.ContainsKey(cell))
                {
                    archi.RemoveTile(cell);
                }
            }
        }
        mouseEnd   = Vector3.zero;
        mouseStart = Vector3.zero;
        isDragging = false;
    }
示例#6
0
 public GameObject[,] Generate(int rows, int col)
 {
     grid = new GameObject[rows, col];
     for (int i = 0; i < rows; i++)
     {
         for (int j = 0; j < col; j++)
         {
             cell = new GameObject("cell[row]: " + i + "|[col]: " + j);
             cell.AddComponent <GridCell>();
             cell.GetComponent <GridCell>().rowIndex = i;
             cell.GetComponent <GridCell>().colIndex = j;
             if (i == rows - 1)
             {
                 //Debug.Log("Call Grid Cell Function");
                 cell.GetComponent <GridCell>().AddSouthWall();
             }
             if (j == col - 1)
             {
                 cell.GetComponent <GridCell>().AddEastWall();
             }
             grid[i, j] = cell;
             grid[i, j].transform.position = new Vector3(i, 0, j);
         }
     }
     GridUtility.SetUndefinedWalls(grid);
     return(grid);
 }
 public static void Translate(this TransformSelection selection, Vector3 translation)
 {
     for (var t = 0; t < selection.Transforms.Length; t++)
     {
         selection.Transforms[t].position = GridUtility.CleanPosition(selection.BackupPositions[t] + translation);
     }
 }
示例#8
0
 public frmProductLeftView()
 {
     InitializeComponent();
     Dock         = DockStyle.Fill;
     m_frmPrimary = Application.OpenForms["frmPrimary"] as frmPrimary;
     gridUtility  = new GridUtility(gridControl1);
 }
示例#9
0
    Vector2Int GetDirection()
    {
        if (currentIndex >= movementPattern.Count)
        {
            if (patternLoopType == PatternLoopType.loop)
            {
                currentIndex = 0;
            }
            else if (patternLoopType == PatternLoopType.pingPong)
            {
                patternDir   = -1;
                currentIndex = movementPattern.Count - 1;
            }
        }
        else if (currentIndex == -1)
        {
            if (patternLoopType == PatternLoopType.loop)
            {
                currentIndex = movementPattern.Count - 1;
            }
            else if (patternLoopType == PatternLoopType.pingPong)
            {
                currentIndex = 0;
                patternDir   = 1;
            }
        }

        return(GridUtility.DirToV2(movementPattern[currentIndex]));
    }
示例#10
0
        public WizardForm(PackForm parent)
        {
            InitializeComponent();

            _parent            = parent;
            gdItems.DataSource = _items;
            PopulateCombos();

            foreach (string type in Pack.SpawnItemConfig.AttachmentTypes.Keys)
            {
                for (int i = 0; i < PackForm.MaxAttachmentsForType; i++)
                {
                    var gc = gvItems.Columns.Add();
                    gc.Name        = String.Format("{0}{1}{2}", PackForm.AttachmentColNamePrefix, type, i);
                    gc.FieldName   = gc.Name;
                    gc.Caption     = type;
                    gc.UnboundType = UnboundColumnType.String;
                    gc.Width       = 30;
                    gc.Visible     = true;

                    _attachTypeColMap.Add(gc, type);
                }
            }

            // instant commit (will be detached automatically when form closes)
            foreach (var cmb in _parent.AttachmentEditorsByType.Values)
            {
                GridUtility.ConfigureInstantCommit(gvItems, cmb);
            }
        }
示例#11
0
    void Run()
    {
        if (!m_animation.IsPlaying("run"))
        {
            m_animation.CrossFade("run");
        }

        bool ok = GridUtility.MoveToTarget(m_finder, ref m_transform, m_speed * Time.deltaTime, 30);

        if (ok)
        {
            if (!m_finder.HasPath())
            {
                m_currentAction = Idle;
            }
            return;
        }

        if (!isControl)
        {
            m_currentAction = Idle;
        }
        else
        {
            ok = m_finder.BuildPath(GridUtility.VectorToPath(m_transform.position), GridUtility.VectorToPath(m_destination), 60, true, false, false);
            if (!m_finder.HasPath() || !ok)
            {
                m_currentAction = Idle;
            }
        }
    }
示例#12
0
        public frmEditQuotation(Quotation quotation)
        {
            InitializeComponent();
            IInitColumn quotationDetailColumn = new QuotationDetailColumn(gridView1, checkBoxCombobox1);

            gridUtility = new GridUtility(gridControl1, false, false, 35, colDescription);
            gridUtility.ColProductPicture       = colPhoto;
            gridUtility.ColProductPicturePath   = colImgPath;
            gridUtility.ColDimensionPicture     = colDimension;
            gridUtility.ColDimensionPicturePath = colDimensionPath;
            List <GridColumn> lstDefinedColumn = new List <GridColumn>()
            {
                colDimension, colDonvi
            };

            FormUtility.FormatForm(this);
            lblNotify1.Text     = "";
            m_Company           = null;
            m_Quotation         = quotation;
            m_Company           = m_Quotation.Company;
            gridView1.RowHeight = 150;
            isEdited            = false;
            this.checkBoxCombobox1.CheckStateChanged += new System.EventHandler(this.checkComboBox1_CheckStateChanged);
            quotationDetailColumn.InitColumn(lstDefinedColumn);
        }
示例#13
0
        public void uploadoptions_with_different_chunksize()
        {
            var opts = new UploadOptions
            {
                ChunkSizeBytes = 1024
            };

            var data = TestBytes.Generate(1024 * 2);

            var fileId = bucket.Upload(testfile, data, opts);

            fileId.Should().NotBeEmpty();

            var info = bucket.GetFileInfoByNameAsync(testfile, -1).WaitSync();

            info.ChunkSizeBytes.Should().Be(1024);

            //verify chunks
            var chunks = GridUtility.EnumerateChunks(bucket, info.Id).ToList();

            chunks.Count.Should().Be(2);

            foreach (var chunk in chunks)
            {
                chunk.Data.Length.Should().Be(1024);
            }
        }
示例#14
0
 public frmLookForQuotation(Model.Company company)
 {
     InitializeComponent();
     FormUtility.FormatForm(this);
     gridUtility = new GridUtility(gridControl1);
     m_Company   = company;
 }
示例#15
0
        void SetBrightnessOfNeighbors(TileNode starting, int depth, int maxDepth, ref List <Vector2Int> checkedN)
        {
            checkedN.Add(starting.position);
            List <TileNode> ns = new List <TileNode>(gridElement.tilemapManager.GetNeighborsTo(starting));

            foreach (TileNode n in ns)
            {
                if (depth <= maxDepth)
                {
                    if (!checkedN.Contains(n.position))
                    {
                        // if(holdingGrid.LineOfSight(this,n))
                        // {
                        n.brightness = gridElement.brightness - GridUtility.ManhattanDistance(position, n.position);
                        checkedN.Add(n.position);
                        //Recursion!
                        SetBrightnessOfNeighbors(n, depth + 1, maxDepth, ref checkedN);
                        // }else{Debug.Log("no line of sight,"+n.position);}
                    }
                    else
                    {
                        Debug.Log("already checked, " + n.position);
                    }
                }
                else
                {
                    Debug.Log("max depth past, " + depth + ", " + n.position);
                }
            }
        }
        public override IEnumerator Execute()
        {
            var targetTile = GameManager.Instance.SelectionManager.SelectedTower.Tile;
            var zone       = GridUtility.SquaredZone(targetTile, size);

            zone.Remove(targetTile);

            var wait             = new WaitForSeconds(animationTime);
            var targetTileHolder = GameManager.Instance.GridHolder.TileHolders[targetTile.Index];

            GameManager.Instance.SelectionManager.AddToBadTarget(targetTileHolder.gameObject);
            yield return(wait);

            foreach (var tile in zone)
            {
                var tileHolder = GameManager.Instance.GridHolder.TileHolders[tile.Index];
                GameManager.Instance.SelectionManager.AddToEnemyTarget(tileHolder.gameObject);
                yield return(wait);

                tile.Height += amount;
                GameManager.Instance.SelectionManager.RemoveFromEnemyTarget(tileHolder.gameObject);
            }

            GameManager.Instance.SelectionManager.RemoveFromBadTarget(targetTileHolder.gameObject);
        }
示例#17
0
    private void Update()
    {
        //Debug.Log(currentCell.visited);
        if (currentCell != null)
        {
            currentCell.visited = true;
        }

        neighborCells = GridUtility.GetUnvisitedCellNeighbors(grid, currentCell.rowIndex, currentCell.colIndex);
        if (neighborCells.Count > 0)
        {
            int r = UnityEngine.Random.Range(0, neighborCells.Count);
            RemoveWalls(currentCell, neighborCells[r]);
            currentCell = neighborCells[r];
            rowIndex    = currentCell.rowIndex;
            colIndex    = currentCell.colIndex;
            cellStack.Push(currentCell);
        }
        else if (cellStack.Count > 0)
        {
            currentCell = cellStack.Pop();
        }
        else
        {
            finishedAlgo = true;
        }
        if (finishedAlgo)
        {
            Destroy(gameObject.GetComponent <DsRecursiveBT>());
        }
    }
示例#18
0
 public frmProductProperty(Model.Product product)
 {
     InitializeComponent();
     gridUtility       = new GridUtility(gridControl1);
     lblNotify1.Text   = "";
     this.m_Product    = product;
     txtProductId.Text = product.ProductId.ToString();
 }
示例#19
0
        public void uploadfile_with_no_bytes_should_have_no_chunks()
        {
            var fileId = bucket.Upload(testfile, TestBytes.NoChunks);

            var chunks = GridUtility.EnumerateChunks(bucket, fileId).ToList();

            chunks.Count.Should().Be(0);
        }
示例#20
0
 public frmMaterialList()
 {
     InitializeComponent();
     gridUtility = new GridUtility(gridControl1, false, false, 35);
     gridUtility.ColProductPicture     = colPhoto;
     gridUtility.ColProductPicturePath = colImgPath;
     gridView1.RowHeight = 150;
 }
示例#21
0
        public void BindData()
        {
            List <Utility.Data.Utility> Utility = new List <Utility.Data.Utility>();

            Utility = GetAllUtilities();
            GridUtility.DataSource = Utility;
            GridUtility.DataBind();
        }
示例#22
0
 public frmCreateImportMaterial(ImportMaterialRequestDataBase importMaterialRequestDataBase)
 {
     InitializeComponent();
     gridutility = new GridUtility(gridControl2);
     listImportMaterialDetail       = new List <ImportMaterialDetail>();
     importMaterial                 = new ImportMaterial();
     _importMaterialRequestDataBase = importMaterialRequestDataBase;
 }
示例#23
0
        public override bool CorrectTarget(Tile tile)
        {
            var tower = GameManager.Instance.SelectionManager.SelectedTower;
            var zone  = GridUtility.SquaredZone(tower.Tile, range);

            zone.Remove(tower.Tile);
            return(zone.Contains(tile));
        }
示例#24
0
        public frmCreateDebt(Debt debt)
        {
            InitializeComponent();

            gridUtility = new GridUtility(gridControl1);
            FormUtility.FormatForm(this);
            m_Debt = debt;
        }
示例#25
0
        public static void TransformControlPoints(this BrushSelection selection, Matrix4x4 transform)
        {
            for (var t = 0; t < selection.Brushes.Length; t++)
            {
                var targetControlMesh = selection.BackupControlMeshes[t].Clone();
                if (!targetControlMesh.Valid)
                {
                    targetControlMesh.Valid = ControlMeshUtility.Validate(targetControlMesh, selection.Shapes[t]);
                }

                if (!targetControlMesh.Valid)
                {
                    continue;
                }

                var targetBrush     = selection.Brushes[t];
                var targetMeshState = selection.States[t];

                if (targetMeshState.BackupPoints == null)
                {
                    continue;
                }

                var targetShape        = selection.Shapes[t].Clone();
                var localToWorldMatrix = targetMeshState.BrushTransform.localToWorldMatrix;
                var worldToLocalMatrix = targetMeshState.BrushTransform.worldToLocalMatrix;

                var localCombinedMatrix = worldToLocalMatrix *
                                          transform *
                                          localToWorldMatrix;

                var selectedIndices = targetMeshState.GetSelectedPointIndices();

                for (var p = 0; p < targetMeshState.BackupPoints.Length; p++)
                {
                    if (!selectedIndices.Contains((short)p))
                    {
                        continue;
                    }

                    var point = targetMeshState.BackupPoints[p];

                    point = localCombinedMatrix.MultiplyPoint(point);

                    targetControlMesh.Vertices[p] = GridUtility.CleanPosition(point);
                }

                selection.ControlMeshes[t] = targetControlMesh;

                // This might create new controlmesh / shape
                ControlMeshUtility.MergeDuplicatePoints(targetBrush, ref targetControlMesh, ref targetShape);
                if (targetControlMesh.Valid)
                {
                    targetControlMesh.SetDirty();
                    ControlMeshUtility.RebuildShapeFrom(targetBrush, targetControlMesh, targetShape);
                }
            }
        }
示例#26
0
 public void FindPath(Vector3 targetpos)
 {
     m_finder.BuildPath(GridUtility.VectorToPath(m_transform.position), GridUtility.VectorToPath(targetpos), 60, true, false, false);
     if (m_finder.HasPath())
     {
         m_destination   = GridUtility.FloatToVector(m_finder.destination);
         m_currentAction = Run;
     }
 }
示例#27
0
        public frmDebtMain()
        {
            InitializeComponent();
            //FormUtility.FormatDatetimeCtrl(this);
            IGridviewContextMenu ctxMenu = new DebtContextMenu(gridControl1);

            gridUtility = new GridUtility(gridControl1, ctxMenu);
            txtSearch.Select();
        }
示例#28
0
 public frmLookForProduct()
 {
     InitializeComponent();
     Select();
     txtSearch.Select();
     gridUtility = new GridUtility(gridControl1);
     metroProgressBar1.Visible = false;
     lblMessage.Text           = string.Empty;
 }
示例#29
0
        /// <summary>
        /// Setup the grid as a water grid.
        /// </summary>
        private void AddCropColumns()
        {
            Color[] CropColors          = { Color.FromArgb(173, 221, 142), Color.FromArgb(247, 252, 185) };
            Color[] PredictedCropColors = { Color.FromArgb(233, 191, 255), Color.FromArgb(244, 226, 255) };

            //            DataGridViewColumn SAT = Grid.Columns["SAT\r\n(mm/mm)"];
            //            SAT.Frozen = true;
            Grid.Columns[Grid.ColumnCount - 1].Frozen = true;

            int CropIndex          = 0;
            int PredictedCropIndex = 0;

            foreach (string CropName in Soil.CropNames.Union(Soil.PredictedCropNames, StringComparer.OrdinalIgnoreCase))
            {
                SoilCrop Crop = Soil.Crop(CropName);

                bool  IsReadonly;
                Color CropColour;
                Color ForeColour = Color.Black;
                if (Crop.LLMetadata != null && Crop.LLMetadata.First() == "Estimated")
                {
                    CropColour = PredictedCropColors[PredictedCropIndex];
                    ForeColour = Color.Gray;
                    IsReadonly = true;
                    PredictedCropIndex++;
                    if (PredictedCropIndex >= PredictedCropColors.Length)
                    {
                        PredictedCropIndex = 0;
                    }
                }
                else
                {
                    CropColour = CropColors[CropIndex];
                    IsReadonly = false;
                    CropIndex++;
                    if (CropIndex >= CropColors.Length)
                    {
                        CropIndex = 0;
                    }
                }

                double[] PAWCmm = MathUtility.Multiply(Soil.PAWCCropAtWaterThickness(CropName),
                                                       Soil.Water.Thickness);

                DataGridViewColumn LL   = GridUtility.AddColumn(Grid, CropName + " LL\r\n(mm/mm)", Crop.LL, "f3", CropColour, ForeColour, ToolTips: Crop.LLMetadata, ReadOnly: IsReadonly);
                DataGridViewColumn PAWC = GridUtility.AddColumn(Grid, CropName + " PAWC\r\n", PAWCmm, "f1", CropColour, Color.Gray,
                                                                ReadOnly: true,
                                                                ToolTips: StringManip.CreateStringArray("Calculated from crop LL and DUL", PAWCmm.Length));
                DataGridViewColumn KL = GridUtility.AddColumn(Grid, CropName + " KL\r\n(/day)", Crop.KL, "f2", CropColour, ForeColour, ToolTips: Crop.KLMetadata, ReadOnly: IsReadonly);
                DataGridViewColumn XF = GridUtility.AddColumn(Grid, CropName + " XF\r\n(0-1)", Crop.XF, "f1", CropColour, ForeColour, ToolTips: Crop.XFMetadata, ReadOnly: IsReadonly);

                PAWC.ToolTipText = "Calculated from crop LL and DUL";
                PAWC.ReadOnly    = true;
                UpdateTotal(PAWC);
            }
        }
示例#30
0
 public frmDepartmentMain()
 {
     InitializeComponent();
     Dock         = DockStyle.Fill;
     gridUtility1 = new GridUtility(gridControl1);
     gridUtility2 = new GridUtility(gridControl2);
     gridUtility3 = new GridUtility(gridControl3);
     //FormUtility.LoadEventCommonControl(this);
     //lblNotify1.Text = string.Empty;
 }