当前位置: 首页>>代码示例>>C#>>正文


C# GridNode类代码示例

本文整理汇总了C#中GridNode的典型用法代码示例。如果您正苦于以下问题:C# GridNode类的具体用法?C# GridNode怎么用?C# GridNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GridNode类属于命名空间,在下文中一共展示了GridNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

 // Use this for initialization
 void Start()
 {
     m_Grid = GameObject.FindGameObjectWithTag("Grid").GetComponent<Grid>();
     m_target = m_Grid.GetRandGrid();
     m_actor = GetComponent<IActor>();
     m_path = new List<GridNode>();
 }
开发者ID:OnionMoeCat,项目名称:AI-Assignments,代码行数:8,代码来源:PathfollowingController.cs

示例2: PathRequest

 public PathRequest(GridNode start, GridNode end, List<List<GridNode>> grid, Action<GridNode[], bool> callback)
 {
     pathStart = start;
     pathEnd = end;
     pathGrid = grid;
     this.callback = callback;
 }
开发者ID:Richy321,项目名称:TowerDefenseSolver,代码行数:7,代码来源:PathRequestManager.cs

示例3: RequestPath

    public static void RequestPath(GridNode pathStart, GridNode pathEnd, List<List<GridNode>> pathGrid, Action<GridNode[], bool> callback)
    {
        PathRequest newRequest = new PathRequest(pathStart, pathEnd, pathGrid, callback);

        Instance.pathRequestQueue.Enqueue(newRequest);
        Instance.TryProcessNext();
    }
开发者ID:Richy321,项目名称:TowerDefenseSolver,代码行数:7,代码来源:PathRequestManager.cs

示例4: getDistanceBetween

 public int getDistanceBetween(GridNode current, GridNode goal)
 {
     int dx = Math.Abs(goal.gridPositionX - current.gridPositionX);
     int dy = Math.Abs(goal.gridPositionY - current.gridPositionY);
     int h = (int)(10*Math.Sqrt(dx*dx + dy*dy));
     return h;
 }
开发者ID:kyawt2196,项目名称:RTSEngine,代码行数:7,代码来源:Grid.cs

示例5: getHeuristic

 public int getHeuristic(GridNode current, GridNode goal)
 {
     int dx = Math.Abs(goal.gridPositionX - current.gridPositionX);
     int dy = Math.Abs(goal.gridPositionY - current.gridPositionY);
     int h = (int)(10*(dx+dy)+(14-2*10)+Math.Min(dx,dy));
     return h;
 }
开发者ID:kyawt2196,项目名称:RTSEngine,代码行数:7,代码来源:Grid.cs

示例6: getManhattanHeuristic

 public int getManhattanHeuristic(GridNode current, GridNode goal)
 {
     int dx = Math.Abs(goal.gridPositionX - current.gridPositionX);
     int dy = Math.Abs(goal.gridPositionY - current.gridPositionY);
     int h = (int)(dx + dy);
     return h;
 }
开发者ID:kyawt2196,项目名称:RTSEngine,代码行数:7,代码来源:Grid.cs

示例7: createGrid

    // Use this for initialization
    protected void createGrid(MeshRenderer f)
    {
        // get the mesh renderer to calculate the floor bounds
        floor = f;
        floor_width = floor.bounds.size.x;
        floor_depth = floor.bounds.size.z;

        // init grid array
        grid = new GridNode[blockRows, blockColumns];

        // calculate the block width & depth
        block_width = floor_width / blockRows;
        block_depth = floor_depth / blockColumns;

        // get the top left point to draw from
        Vector3 TopLeftPoint = new Vector3(transform.position.x - (floor_width/2), transform.position.y, transform.position.z + (floor_depth / 2));

        // the current position of the new block in the loop
        Vector3 currentPosition = TopLeftPoint;

        // loop through to add the blocks (nodes) to the grid
        for (int i = 0; i < blockRows; i++)
        {
            for (int j = 0; j < blockColumns; j++)
            {
                grid[i, j] = new GridNode(currentPosition, new Vector2(block_width, block_depth)); // add a node at the current position
                currentPosition.x += block_width; // move to the right one block
            }
            // move to the next row
            currentPosition.x = TopLeftPoint.x;
            currentPosition.z -= block_depth;
        }
    }
开发者ID:AdamDWalker,项目名称:CapsuleKiller,代码行数:34,代码来源:MyGrid.cs

示例8: AStar

    public AStar(int width, int height)
    {
        w = width;
        h = height;

        //MAKE THE ARRAY OF COORDINATES SO THAT WE SEARCH THEM IN THE RIGHT ORDER
        coords = new System.Collections.Generic.List<Vector2>();
        coords.Add(new Vector2(0,-1)); // UP
        coords.Add(new Vector2(1,0)); // RIGHT
        coords.Add(new Vector2(0,1)); // DOWN
        coords.Add(new Vector2(-1,0)); // LEFT

        if(allowDiagonals)
        {
            coords.Add(new Vector2(-1,-1)); // UP-LEFT
            coords.Add(new Vector2(1,-1)); // UP-RIGHT
            coords.Add(new Vector2(1,1)); // DOWN-RIGHT
            coords.Add(new Vector2(-1,1)); // DOWNLEFT
        }

        relCurrent = new Vector2();
        relLast = new Vector2();

        startNode = new GridNode();
        endNode = new GridNode();

        open = new NodeList(w*h);
        closed = new NodeList(w*h);

        createGrid(w,h);

        r = new RandomSeed(THE_SEED);
    }
开发者ID:snotwadd20,项目名称:UnityLevelGen,代码行数:33,代码来源:AStar.cs

示例9: Update

    // Update is called once per frame
    void Update()
    {
        Vector2 steering = Vector2.zero;
        GridNode m_current = m_Grid.GetGridForPosition(transform.position);
        if (!m_target.Passable || m_current == m_target || m_path.Count == 0)
        {
            m_target = m_Grid.GetRandGrid();
            m_needToCalPath = true;
        }

        if (m_current != null && m_needToCalPath)
        {
            m_needToCalPath = false;
            if (m_path.Count > 0 && m_showPath)
            {
                m_path.First().Start = false;
                m_path.Last().End = false;
                foreach (GridNode node in m_path)
                {
                    node.Path = false;
                }
            }
            AStar.GetShortestPath(m_current, m_target, m_Grid.diagnoal, out m_path);
            if (m_path.Count > 0 && m_showPath)
            {
                m_path.First().Start = true;
                m_path.Last().End = true;
                foreach (GridNode node in m_path)
                {
                    node.Path = true;
                }
            }
            m_path_index = 1;
        }

        if (m_path.Count > 1)
        {
            GridNode seeking = m_path[m_path_index];
            if (m_current == seeking)
            {
                m_path_index += 1;
                seeking = m_path[m_path_index];
            }
            if (seeking == m_target)
            {
                Renderer renderer = seeking.GetComponent<Renderer>();
                if (renderer != null)
                {
                    steering = SteeringHelper.GetArriveSteering(m_actor, seeking.transform.position, renderer.bounds.size.x);
                }
            }
            else
            {
                steering = SteeringHelper.GetSeekSteering(m_actor, seeking.transform.position);
            }
        }

        m_actor.SetInput(steering.x, steering.y);
    }
开发者ID:OnionMoeCat,项目名称:AI-Assignments,代码行数:60,代码来源:PathfollowingController.cs

示例10: Start

 public override void Start()
 {
     base.Start();
     node = AstarPath.active.GetNearest(this.transform.position).node as GridNode;
     _bounds = new Bounds(transform.position, new Vector3(1.5f, 3f, 1.5f));
     //_bounds.extents = new Vector3(1.5f, 3f, 1.5f);
     //gameObject.collider.enabled = false;
 }
开发者ID:Inteligencia-Artificial-UNS,项目名称:iaj,代码行数:8,代码来源:Building.cs

示例11: GetDistance

    int GetDistance(GridNode nodeA, GridNode nodeB)
    {
        int distX = Mathf.Abs(nodeA.gridX - nodeB.gridX);
        int distY = Mathf.Abs(nodeA.gridY - nodeB.gridY);

        if (distX > distY)
            return 14 * distY + 10 * (distX - distY);
        return 14 * distX + 10 * (distY - distX);
    }
开发者ID:louisditzel,项目名称:Unity,代码行数:9,代码来源:LongPathNavigation.cs

示例12: connections

 public static List<int> connections(GridNode node)
 {
     Node[] nodes = node.connections;
     List<int> indexes = new List<int>();
     foreach (Node n in new PerceivableNode(node)){
         indexes.Add(n.GetNodeIndex());
     }
     return indexes;
 }
开发者ID:Inteligencia-Artificial-UNS,项目名称:iaj,代码行数:9,代码来源:PerceivableNode.cs

示例13: FindPath

    public IEnumerator FindPath(GridNode start, GridNode end, List<List<GridNode>> grid)
    {
        List<GridNode> path;
        bool success = FindPathImmediate(start, end, grid, out path);

        yield return null;

        requestManager.FinishedProcessingPath(path.ToArray(), success);
    }
开发者ID:Richy321,项目名称:TowerDefenseSolver,代码行数:9,代码来源:PathFinder.cs

示例14: Arrive

 public void Arrive(GridNode i_seeking)
 {
     Vector2 steering = Vector2.zero;
     Renderer renderer = i_seeking.GetComponent<Renderer>();
     if (renderer != null)
     {
         steering = SteeringHelper.GetArriveSteering(m_actor, i_seeking.transform.position, renderer.bounds.size.x);
     }
     m_actor.SetInput(steering.x, steering.y);
 }
开发者ID:OnionMoeCat,项目名称:AI-Assignments,代码行数:10,代码来源:PathfollowingController.cs

示例15: Execute

 /// <summary>
 /// Implement this method as an external command for Revit.
 /// </summary>
 /// <param name="commandData">An object that is passed to the external application 
 /// which contains data related to the command, 
 /// such as the application object and active view.</param>
 /// <param name="message">A message that can be set by the external application 
 /// which will be displayed if a failure or cancellation is returned by 
 /// the external command.</param>
 /// <param name="elements">A set of elements to which the external application 
 /// can add elements that are to be highlighted in case of failure or cancellation.</param>
 /// <returns>Return the status of the external command. 
 /// A result of Succeeded means that the API external method functioned as expected. 
 /// Cancelled can be used to signify that the user cancelled the external operation 
 /// at some point. Failure should be returned if the application is unable to proceed with 
 /// the operation.</returns>
 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
 {
     Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application;
     Document doc = commandData.Application.ActiveUIDocument.Document;
     Parameter param = null;
     Bitmap image = new Bitmap(doc.PathName + "_grayscale.bmp");
     FilteredElementCollector collector = new FilteredElementCollector(doc);
     ICollection<Element> collection = collector.OfClass(typeof(DividedSurface)).ToElements();
     foreach (Element element in collection)
     {
         DividedSurface ds = element as DividedSurface;
         GridNode gn = new GridNode();
         for (int u = 0; u < ds.NumberOfUGridlines; u++)
         {
             gn.UIndex = u;
             for (int v = 0; v < ds.NumberOfVGridlines; v++)
             {
                 gn.VIndex = v;
                 if (ds.IsSeedNode(gn))
                 {
                     FamilyInstance familyinstance = ds.GetTileFamilyInstance(gn, 0);
                     if (familyinstance != null)
                     {
                         param = familyinstance.get_Parameter("Grayscale");
                         if (param == null) throw new Exception("Panel family must have a Grayscale instance parameter");
                         else
                         {
                             System.Drawing.Color pixelColor = new System.Drawing.Color();
                             try
                             {
                                 pixelColor = image.GetPixel(image.Width - v, image.Height - u);
                                 double grayscale = 255 - ((pixelColor.R + pixelColor.G + pixelColor.B) / 3);
                                 if (grayscale == 0)
                                 {
                                     doc.Delete(familyinstance);
                                 }
                                 else
                                 {
                                     param.Set(grayscale / 255);
                                 }
                             }
                             catch (System.Exception)
                             {
                                 //       MessageBox.Show("Exception: " + u + ", " + v);
                             }
                         }
                     }
                 }
             }
         }
     }
     doc.Regenerate(); ;
     return Result.Succeeded;
 }
开发者ID:AMEE,项目名称:revit,代码行数:70,代码来源:Command.cs


注:本文中的GridNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。