Beispiel #1
0
    /// <summary>
    /// 导出预处理数据
    /// </summary>
    /// <returns></returns>
    public MapSectorWrite GetOutData()
    {
        MapSectorWrite mw = new MapSectorWrite();

        // left
        if (sectorGateOnEdge.ContainsKey(Side.Left) == true)
        {
            List <PathNode> l = sectorGateOnEdge[Side.Left];
            foreach (PathNode n in l)
            {
                mw.Left.Add(n.GetOutData());
            }
        }
        // top
        if (sectorGateOnEdge.ContainsKey(Side.Top) == true)
        {
            List <PathNode> l = sectorGateOnEdge[Side.Top];
            foreach (PathNode n in l)
            {
                mw.top.Add(n.GetOutData());
            }
        }
        // right
        if (sectorGateOnEdge.ContainsKey(Side.Right) == true)
        {
            List <PathNode> l = sectorGateOnEdge[Side.Right];
            foreach (PathNode n in l)
            {
                mw.right.Add(n.GetOutData());
            }
        }
        // down
        if (sectorGateOnEdge.ContainsKey(Side.Down) == true)
        {
            List <PathNode> l = sectorGateOnEdge[Side.Down];
            foreach (PathNode n in l)
            {
                mw.down.Add(n.GetOutData());
            }
        }


        return(mw);
    }
Beispiel #2
0
    /// <summary>
    /// 构建扇区的边及way point及cost,由数据直接生成
    /// </summary>
    /// <param name="map"></param>
    public void BuildSectorEdgeWaypoint2Cost(Map map, MapSectorWrite ms)
    {
        foreach (PathNodeWrite pnw in ms.down)
        {
            PathNode node          = this.CreateWayPointInSector(map.GetMapTileSafe(pnw.pos), Side.Down, map);
            PathNode neighbourNode = Findneighbour(Side.Down, map).CreateWayPointInSector(map.GetMapTileSafe(pnw.pos.Down), Side.Top, map);
            node.LinkOtherSectorGate          = neighbourNode;
            neighbourNode.LinkOtherSectorGate = node;
            PathNode.LinkSectorNode(node, neighbourNode, 1, null);
        }

        foreach (PathNodeWrite pnw in ms.right)
        {
            PathNode node          = this.CreateWayPointInSector(map.GetMapTileSafe(pnw.pos), Side.Right, map);
            PathNode neighbourNode = Findneighbour(Side.Right, map).CreateWayPointInSector(map.GetMapTileSafe(pnw.pos.Right), Side.Left, map);
            node.LinkOtherSectorGate          = neighbourNode;
            neighbourNode.LinkOtherSectorGate = node;
            PathNode.LinkSectorNode(node, neighbourNode, 1, null);
        }

        List <PathNode> All = GetPathNodeInEdge();

        if (All == null || All.Count == 0)
        {
            return;
        }
        foreach (PathNode nodeA in All)
        {
            foreach (PathNode nodeB in All)
            {
                if (nodeA != nodeB)
                {
                    LinkInfo v = ms.GetDistance(nodeA.tileConnection.Pos, nodeB.tileConnection.Pos);
                    PathNode.LinkSectorNode(nodeA, nodeB, v.LinkDistance, v.ListCrossTile);
                }
            }
        }
    }