コード例 #1
0
        private void RePath()
        {
            for (int x = 0; x < Size; x++)
            {
                for (int y = 0; y < Size; y++)
                {
                    OpenTile.SetAsPathMember(new Vector2Int(x, y), false);
                }
            }

            Vector2Int[] path = TofuUnity.Vector2IntPathfinder.GetPath(_fromCoord, _toCoord, (Vector2Int coord) =>
            {
                bool toReturn = coord.x >= 0 && coord.x < PathFinder.Size && coord.y >= 0 && coord.y < PathFinder.Size && Obstacle.CanOccupy(coord);
                toReturn     |= coord == _toCoord;
                return(toReturn);
            });

            for (int i = 0; i < path.Length; i++)
            {
                OpenTile.SetAsPathMember(path[i], true);
            }
        }