Beispiel #1
0
        public GridNodeType[,] RenderNodeTypes(Vector2Int? start = null, Vector2Int? end = null)
        {
            GridNodeType[,] nodeTypeGrid = new GridNodeType[Grid.GetLength(0), Grid.GetLength(1)];

            for (int x = 0; x < Grid.GetLength(0); x++)
            {
                for (int y = 0; y < Grid.GetLength(1); y++)
                {
                    nodeTypeGrid[x, y] = Grid[x, y].Walkable ? GridNodeType.Empty : GridNodeType.Wall;
                }
            }

            // Start / End node addition
            if (start.HasValue)
            {
                nodeTypeGrid[start.Value.x, start.Value.y] = GridNodeType.Start;
            }

            if (end.HasValue)
            {
                nodeTypeGrid[end.Value.x, end.Value.y] = GridNodeType.End;
            }

            return(nodeTypeGrid);
        }
Beispiel #2
0
        private void SetGridNodeType(GridNodeType type)
        {
            _type = type;
            switch (type)
            {
            case GridNodeType.Ground:
                _image.color = SearchSettings.Instance.GroundNodeColor;
                break;

            case GridNodeType.Wall:
                _image.color = SearchSettings.Instance.WallNodeColor;
                break;

            case GridNodeType.Forest:
                _image.color = SearchSettings.Instance.ForestNodeColor;
                break;

            case GridNodeType.Rought:
                _image.color = SearchSettings.Instance.RoughtNodeColor;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Beispiel #3
0
 public Change(int x, int y, GridNodeType newType, GridNodeType oldType)
 {
     this.X    = x;
     this.Y    = y;
     this.New  = newType;
     this.Old  = oldType;
     this.Time = UnityEngine.Time.realtimeSinceStartup;
 }