コード例 #1
0
        public void SetAsDestination()
        {
            cost     = 0;
            bestCost = 0;

            bestDirection = GridDirection.None;
        }
コード例 #2
0
        public void ResetCell()
        {
            cost     = 1;
            bestCost = ushort.MaxValue;

            bestDirection = GridDirection.None;
        }
コード例 #3
0
        public Cell(bool _walkable, Vector3 _worldPos, Vector2Int _gridIndex)
        {
            worldPos  = _worldPos;
            gridIndex = _gridIndex;

            cost = 1;

            bestCost = ushort.MaxValue;

            bestDirection = GridDirection.None;
        }
コード例 #4
0
        public void CreateFlowField()
        {
            foreach (Cell curCell in grid)
            {
                curCell.bestDirection = GridDirection.None;

                List <Cell> curNeighbors = GetNeighborCells(curCell.gridIndex, GridDirection.AllDirections);

                int bestCost = curCell.bestCost;

                foreach (Cell curNeighbor in curNeighbors)
                {
                    if (curNeighbor.bestCost < bestCost)
                    {
                        bestCost = curNeighbor.bestCost;
                        curCell.bestDirection = GridDirection.GetDirectionFromV2I(curNeighbor.gridIndex - curCell.gridIndex);
                    }
                }
            }
        }